Prev Next link_sparse_jacobian

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
Speed Testing Sparse Jacobian

Prototype
extern bool link_sparse_jacobian(
     size_t                       
size      ,
     size_t                       
repeat    ,
     size_t                       
m         ,
     const CppAD::vector<size_t>& 
row       ,
     const CppAD::vector<size_t>& 
col       ,
           CppAD::vector<double>& 
x         ,
           CppAD::vector<double>& 
jacobian  ,
           size_t&                
n_sweep
);

Method
Given a range space dimension m the row index vector @(@ row @)@, and column index vector @(@ col @)@, a corresponding function @(@ f : \B{R}^n \rightarrow \B{R}^m @)@ is defined by sparse_jac_fun . The non-zero entries in the Jacobian of this function have the form @[@ \D{f[row[k]]}{x[col[k]]]} @]@ for some @(@ k @)@ between zero and K = row.size()-1 . All the other terms of the Jacobian 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).

m
Is the dimension of the range space for the function @(@ f(x) @)@.

row
The size of the vector row defines the value @(@ K @)@. All the elements of row are between zero and @(@ m-1 @)@.

col
The argument col is a vector with size @(@ K @)@. The input value of its elements does not matter. On output, it has been set the column index vector for the last repetition. All the elements of col are between zero and @(@ n-1 @)@. There are no duplicate row and column entires; i.e., if j != k ,
     
row[j] != row[k] || col[j] != col[k]

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 and placed in jacobian . The value of this vector need not change with each repetition.

jacobian
The argument jacobian has prototype
        CppAD::vector<double>& 
jacobian
and its size is K . The input value of its elements does not matter. The output value of its elements is the Jacobian of the function @(@ f(x) @)@. To be more specific, for @(@ k = 0 , \ldots , K - 1 @)@, @[@ \D{f[ \R{row}[k] ]}{x[ \R{col}[k] ]} (x) = \R{jacobian} [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 jacobian . 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 @(@ m @)@ elements of jacobian are used and they are set to the value of @(@ f(x) @)@.
Input File: speed/src/link_sparse_jacobian.cpp