Prev Next

@(@\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}} }@)@
Computing Sparse Jacobians

n_sweep = f.sparse_jac_for(
n_sweep = f.sparse_jac_rev(

We use @(@ F : \B{R}^n \rightarrow \B{R}^m @)@ to denote the function corresponding to f . Here n is the domain size, and m is the range size, or f . The syntax above takes advantage of sparsity when computing the Jacobian @[@ J(x) = F^{(1)} (x) @]@ In the sparse case, this should be faster and take less memory than Jacobian . We use the notation @(@ J_{i,j} (x) @)@ to denote the partial of @(@ F_i (x) @)@ with respect to @(@ x_j @)@.

The type SizeVector is a SimpleVector class with elements of type size_t.

The type BaseVector is a SimpleVector class with elements of type size_t.

This function uses first order forward mode sweeps forward_one to compute multiple columns of the Jacobian at the same time.

This uses function first order reverse mode sweeps reverse_one to compute multiple rows of the Jacobian at the same time.

This object has prototype
Note that the Taylor coefficients stored in f are affected by this operation; see uses forward below.

This argument has prototype
and must be greater than zero. It specifies the maximum number of colors to group during a single forward sweep. If a single color is in a group, a single direction for of first order forward mode forward_one is used for each color. If multiple colors are in a group, the multiple direction for of first order forward mode forward_dir is used with one direction for each color. This uses separate memory for each direction (more memory), but my be significantly faster.

This argument has prototype
and its size is n . It specifies the point at which to evaluate the Jacobian @(@ J(x) @)@.

This argument has prototype
SizeVectorBaseVector>& subset
Its row size is == m , and its column size is == n . It specifies which elements of the Jacobian are computed. The input value of its value vector subset.val() does not matter. Upon return it contains the value of the corresponding elements of the Jacobian. All of the row, column pairs in subset must also appear in pattern ; i.e., they must be possibly non-zero.

This argument has prototype
     const sparse_rc<
SizeVector>& pattern
Its row size is == m , and its column size is == n . It is a sparsity pattern for the Jacobian @(@ J(x) @)@. This argument is not used (and need not satisfy any conditions), when work is non-empty.

The coloring algorithm determines which rows (reverse) or columns (forward) can be computed during the same sweep. This field has prototype
     const std::string& 
This value only matters when work is empty; i.e., after the work constructor or work.clear() .

This uses a general purpose coloring algorithm written for Cppad.

If colpack_prefix is specified on the cmake command line, you can set coloring to colpack. This uses a general purpose coloring algorithm that is part of Colpack.

This argument has prototype
We refer to its initial value, and its value after work.clear() , as empty. If it is empty, information is stored in work . This can be used to reduce computation when a future call is for the same object f , the same member function sparse_jac_for or sparse_jac_rev, and the same subset of the Jacobian. If any of these values change, use work.clear() to empty this structure.

The return value n_sweep has prototype
If sparse_jac_for (sparse_jac_rev) is used, n_sweep is the number of first order forward (reverse) sweeps used to compute the requested Jacobian values. It is also the number of colors determined by the coloring method mentioned above. This is proportional to the total computational work, not counting the zero order forward sweep, or combining multiple columns (rows) into a single sweep.

Uses Forward
After each call to Forward , the object f contains the corresponding Taylor coefficients . After a call to sparse_jac_forward or sparse_jac_rev, the zero order coefficients correspond to
f.Forward(0, x)
All the other forward mode coefficients are unspecified.

The files sparse_jac_for.cpp and sparse_jac_rev.cpp are examples and tests of sparse_jac_for and sparse_jac_rev. They return true, if they succeed, and false otherwise.
Input File: cppad/core/sparse_jac.hpp