Prev Next

Sparse Jacobian: Easy Driver

Syntax
jac = f.SparseJacobian(x)
jac = f.SparseJacobian(xp)

Purpose
We use  F : B^n \rightarrow B^m do denote the AD function corresponding to f . The syntax above sets jac to the Jacobian  \[
     jac = F^{(1)} (x) 
\] 
This is a preliminary implementation of a method for using the fact that the matrix is sparse to reduce the amount of computation necessary. One should use speed tests to verify that results are computed faster than when using the routine Jacobian .

f
The object f has prototype
     ADFun<
Basef
Note that the ADFun object f is not const (see Uses Forward below).

x
The argument x has prototype
     const 
BaseVector &x
(see BaseVector below) and its size must be equal to n , the dimension of the domain space for f . It specifies that point at which to evaluate the Jacobian.

p
The argument p is optional and has prototype
     const 
BoolVector &p
(see BoolVector below) and its size is  m * n . It specifies a sparsity pattern for the Jacobian; i.e., for  i = 0 , \ldots , m-1 and  j = 0 , \ldots , n-1 .  \[
     \D{ F_i }{ x_j } \neq 0 ; \Rightarrow \; p [ i * n + j ] = {\rm true}
\] 


If this sparsity pattern does not change between calls to SparseJacobian , it should be faster to calculate p once and pass this argument to SparseJacobian .

jac
The result jac has prototype
     
BaseVector jac
and its size is  m * n . For  i = 0 , \ldots , m - 1 , and  j = 0 , \ldots , n - 1   \[
     jac [ i * n + j ] = \D{ F_i }{ x_j }
\] 


BaseVector
The type BaseVector must be a SimpleVector class with elements of type Base . The routine CheckSimpleVector will generate an error message if this is not the case.

BoolVector
The type BoolVector must be a SimpleVector class with elements of type bool . The routine CheckSimpleVector will generate an error message if this is not the case. In order to save memory, you may want to use a class that packs multiple elements into one storage location; for example, vectorBool .

Uses Forward
After each call to Forward , the object f contains the corresponding Taylor coefficients . After SparseJacobian, the previous calls to Forward are undefined.

Example
The routine sparse_jacobian.cpp is examples and tests of sparse_jacobian. It return true, if it succeeds and false otherwise.
Input File: cppad/local/sparse_jacobian.hpp