\(\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}} }\)
rev_jac_sparsity¶
View page sourceReverse Mode Jacobian Sparsity Patterns¶
Syntax¶
rev_jac_sparsity
(Purpose¶
We use \(F : \B{R}^n \rightarrow \B{R}^m\) to denote the AD Function corresponding to the operation sequence stored in f . Fix \(R \in \B{R}^{\ell \times m}\) and define the function
Given the Sparsity Pattern for \(R\),
rev_jac_sparsity
computes a sparsity pattern for \(J(x)\).
x¶
Note that the sparsity pattern \(J(x)\) corresponds to the operation sequence stored in f and does not depend on the argument x . (The operation sequence may contain CondExp and VecAD operations.)
SizeVector¶
The type SizeVector is a SimpleVector class with
elements of type
size_t
.
f¶
The object f has prototype
ADFun
< Base > f
pattern_in¶
The argument pattern_in has prototype
const sparse_rc
< SizeVector >& pattern_in
see sparse_rc . If transpose it is false (true), pattern_in is a sparsity pattern for \(R\) (\(R^\R{T}\)).
transpose¶
This argument has prototype
bool
transpose
See pattern_in above and pattern_out below.
dependency¶
This argument has prototype
bool
dependency
see pattern_out below.
internal_bool¶
If this is true, calculations are done with sets represented by a vector of boolean values. Otherwise, a vector of sets of integers is used.
pattern_out¶
This argument has prototype
sparse_rc
< SizeVector >& pattern_out
This input value of pattern_out does not matter. If transpose it is false (true), upon return pattern_out is a sparsity pattern for \(J(x)\) (\(J(x)^\R{T}\)). If dependency is true, pattern_out is a Dependency Pattern instead of sparsity pattern.
Sparsity for Entire Jacobian¶
Suppose that \(R\) is the \(m \times m\) identity matrix. In this case, pattern_out is a sparsity pattern for \(F^{(1)} ( x )\) ( \(F^{(1)} (x)^\R{T}\) ) if transpose is false (true).
Example¶
The file rev_jac_sparsity.cpp contains an example and test of this operation.