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}} }@)@

*f*.subgraph_jac_rev(*x*, *subset*)

*f*.subgraph_jac_rev(

*select_domain*, *select_range*, *x*, *matrix_out*

)

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)
@]@
The first syntax computes the sparsity pattern and the value
of the Jacobian at the same time.
If one only wants the sparsity pattern,
it should be faster to use subgraph_sparsity
.
This routine uses a subgraph technique. To be specific, for each dependent variable, it a subgraph of the operation sequence to determine which independent variables affect it. This avoids to overhead of performing set operations that is inherent in other methods for computing sparsity patterns.

The type

*BaseVector*

is a SimpleVector
class with
elements of type
*Base*

.
The type

*SizeVector*

is a SimpleVector
class with
elements of type
`size_t`

.
The type

*BoolVector*

is a SimpleVector
class with
elements of type
`bool`

.
This object has prototype

ADFun<*Base*> *f*

Note that the Taylor coefficients stored in
*f*

are affected
by this operation; see
uses forward
below.
This argument has prototype

const *BaseVector*& *x*

It is the value of
*x*

at which we are computing the Jacobian.
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.
This argument has prototype

sparse_rcv<*SizeVector*, *BaseVector*>& *subset*

Its row size is
*subset*.nr() == *m*

,
and its column size is
*subset*.nc() == *n*

.
It specifies which elements of the Jacobian are computed.
The input elements in its value vector
*subset*.val()

do not matter.
Upon return it contains the value of the corresponding elements
of the Jacobian.
The argument

*select_domain*

has prototype

const *BoolVector*& *select_domain*

It has size @(@
n
@)@ and specifies which independent variables
to include.
The argument

*select_range*

has prototype

const *BoolVector*& *select_range*

It has size @(@
m
@)@ and specifies which components of the range
to include in the calculation.
A subgraph is built for each dependent variable and the selected set
of independent variables.
This argument has prototype

sparse_rcv<*SizeVector*, *BaseVector*>& *matrix_out*

This input value of
*matrix_out*

does not matter.
Upon return
*matrix_out*

is
sparse matrix
representation of @(@
F^{(1)} (x)
@)@.
The matrix has @(@
m
@)@ rows, @(@
n
@)@ columns.
If
*select_domain*[*j*]

is true,
*select_range*[*i*]

is true, and
@(@
F_i (x)
@)@ depends on @(@
x_j
@)@,
then the pair @(@
(i, j)
@)@ is in
*matrix_out*

.
For each
*k* = 0 , *...*, *matrix_out*.nnz()

, let

*i* = *matrix_out*.row()[*k*]

*j* = *matrix_out*.col()[*k*]

*v* = *matrix_out*.val()[*k*]

It follows that the partial of @(@
F_i (x)
@)@ with respect to
@(@
x_j
@)@ is equal to @(@
v
@)@.
The files subgraph_jac_rev.cpp and subgraph_hes2jac.cpp are examples and tests using

`subgraph_jac_rev`

.
They returns `true`

for success and `false`

for failure.
Input File: cppad/core/subgraph_jac_rev.hpp