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}} }@)@
Jacobian Sparsity Pattern: Reverse Mode

Syntax
s = f.RevSparseJac(qr)
s = f.RevSparseJac(qrtransposedependency)

Purpose
We use @(@ F : B^n \rightarrow B^m @)@ to denote the AD function corresponding to f . For a fixed matrix @(@ R \in B^{q \times m} @)@, the Jacobian of @(@ R * F( x ) @)@ with respect to @(@ x @)@ is @[@ S(x) = R * F^{(1)} ( x ) @]@ Given a sparsity pattern for @(@ R @)@, RevSparseJac returns a sparsity pattern for the @(@ S(x) @)@.

f
The object f has prototype
     ADFun<
Basef

x
If the operation sequence in f is independent of the independent variables in @(@ x \in B^n @)@, the sparsity pattern is valid for all values of (even if it has CondExp or VecAD operations).

q
The argument q has prototype
     size_t 
q
It specifies the number of rows in @(@ R \in B^{q \times m} @)@ and the Jacobian @(@ S(x) \in B^{q \times n} @)@.

transpose
The argument transpose has prototype
     bool 
transpose
The default value false is used when transpose is not present.

dependency
The argument dependency has prototype
     bool 
dependency
If dependency is true, the dependency pattern (instead of sparsity pattern) is computed.

r
The argument s has prototype
     const 
VectorSetr
see VectorSet below.

transpose false
If r has elements of type bool, its size is @(@ q * m @)@. If it has elements of type std::set<size_t>, its size is q and all its set elements are between zero and @(@ m - 1 @)@. It specifies a sparsity pattern for the matrix @(@ R \in B^{q \times m} @)@.

transpose true
If r has elements of type bool, its size is @(@ m * q @)@. If it has elements of type std::set<size_t>, its size is m and all its set elements are between zero and @(@ q - 1 @)@. It specifies a sparsity pattern for the matrix @(@ R^\R{T} \in B^{m \times q} @)@.

s
The return value s has prototype
     
VectorSet s
see VectorSet below.

transpose false
If it has elements of type bool, its size is @(@ q * n @)@. If it has elements of type std::set<size_t>, its size is q and all its set elements are between zero and @(@ n - 1 @)@. It specifies a sparsity pattern for the matrix @(@ S(x) \in {q \times n} @)@.

transpose true
If it has elements of type bool, its size is @(@ n * q @)@. If it has elements of type std::set<size_t>, its size is n and all its set elements are between zero and @(@ q - 1 @)@. It specifies a sparsity pattern for the matrix @(@ S(x)^\R{T} \in {n \times q} @)@.

VectorSet
The type VectorSet must be a SimpleVector class with elements of type bool or std::set<size_t>; see sparsity pattern for a discussion of the difference.

Entire Sparsity Pattern
Suppose that @(@ q = m @)@ and @(@ R @)@ is the @(@ m \times m @)@ identity matrix. In this case, the corresponding value for s is a sparsity pattern for the Jacobian @(@ S(x) = F^{(1)} ( x ) @)@.

Example
The file rev_sparse_jac.cpp contains an example and test of this operation. It returns true if it succeeds and false otherwise.
Input File: cppad/core/rev_sparse_jac.hpp