Speed Testing Sparse Hessian

Prototype
extern bool link_sparse_hessian(      size_t                        size      ,      size_t                        repeat    ,      CppAD::vector<double>&        x         ,      const CppAD::vector<size_t>&  row       ,      const CppAD::vector<size_t>&  col       ,      CppAD::vector<double>&        hessian   ,      size_t                        n_sweep ); 
Method
Given a row index vector $row$ and a second column vector $col$, the corresponding function $f : \B{R}^n \rightarrow \B{R}$ is defined by sparse_hes_fun . The non-zero entries in the Hessian of this function have one of the following forms: $$\DD{f}{x[row[k]]}{x[row[k]]} \; , \; \DD{f}{x[row[k]]}{x[col[k]]} \; , \; \DD{f}{x[col[k]]}{x[row[k]]} \; , \; \DD{f}{x[col[k]]}{x[col[k]]}$$ for some $k$ between zero and $K-1$. All the other terms of the Hessian are zero.

size
The argument size , referred to as $n$ below, is the dimension of the domain space for $f(x)$.

repeat
The argument repeat is the number of times to repeat the test (with a different value for x corresponding to each repetition).

x
The argument x has prototype          CppAD::vector<double>& x  and its size is $n$; i.e., x.size() == size . The input value of the elements of x does not matter. On output, it has been set to the argument value for which the function, or its derivative, is being evaluated. The value of this vector need not change with each repetition.

row
The argument row has prototype       const CppAD::vector<size_t> row  Its size defines the value $K$. It contains the row indices for the corresponding function $f(x)$. All the elements of row are between zero and $n-1$.

col
The argument col has prototype       const CppAD::vector<size_t> col  Its size must be the same as row ; i.e., $K$. It contains the column indices for the corresponding function $f(x)$. All the elements of col are between zero and $n-1$. There are no duplicated entries requested, to be specific, if k1 != k2 then       ( row[k1] , col[k1] ) != ( row[k2] , col[k2] )  Furthermore, the entries are lower triangular; i.e.,       col[k] <= row[k]  .

hessian
The argument hessian has prototype       CppAD::vector<double>&  hessian  and its size is K . The input value of its elements does not matter. The output value of its elements is the Hessian of the function $f(x)$. To be more specific, for $k = 0 , \ldots , K-1$, $$\DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = \R{hessian} [k]$$

n_sweep
The input value of n_sweep does not matter. On output, it is the value n_sweep corresponding to the evaluation of hessian . This is also the number of colors corresponding to the coloring method , which can be set to colpack , and is otherwise cppad.

double
In the case where package is double, only the first element of hessian is used and it is actually the value of $f(x)$ (derivatives are not computed).