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}} }@)@
Reverse Mode Using Subgraphs

Syntax
f.subgraph_reverse(select_domain)
f.subgraph_reverse(qellcoldw)

Purpose
We use @(@ F : B^n \rightarrow B^m @)@ to denote the AD function corresponding to f . Reverse mode computes the derivative of the Forward mode Taylor coefficients with respect to the domain variable @(@ x @)@.

Notation
We use the reverse mode notation with the following change: the vector w^(k) is defined @[@ w_i^{(k)} = \left\{ \begin{array}{ll} 1 & {\rm if} \; k = q-1 \; \R{and} \; i = \ell \\ 0 & {\rm otherwise} \end{array} \right. @]@

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 is a SimpleVector class with elements of type bool.

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

select_domain
The argument select_domain has prototype
     const 
BoolVectorselect_domain
It has size @(@ n @)@ and specifies which independent variables to include in the calculation. If select_domain[j] is false, it is assumed that @(@ u^{(k)}_j = 0 @)@ for @(@ k > 0 @)@; i.e., the j-th component of the Taylor coefficient for @(@ x @)@, with order greater that zero, are zero; see u^(k) .

q
The argument q has prototype
     size_t 
q
and specifies the number of Taylor coefficient orders to be differentiated.

ell
The argument ell has prototype
     size_t 
ell
and specifies the dependent variable index that we are computing the derivatives for; i.e. @(@ \ell @)@. This index can only be used once per, and after, a call that selects the independent variables using select_domain .

col
This argument col has prototype
     
SizeVector col
The input size and value of its elements do not matter. The col.resize member function is used to change its size to the number the number of possible non-zero derivative components. For each c ,
     
select_domaincol[c] ] == true
     
col[c+1] >= col[c]
and the derivative with respect to the j-th independent variable is possibly non-zero where j = col[c] .

dw
The argument dw has prototype
     
Vector dw
Its input size and value does not matter. Upon return, it is a vector with size @(@ n \times q @)@. For @(@ c = 0 , \ldots , %col%.size()-1 @)@, and @(@ k = 0, \ldots , q-1 @)@, @[@ dw[ j * q + k ] = W^{(1)} ( x )_{j,k} @]@ is the derivative of the specified Taylor coefficients w.r.t the j-th independent variable where j = col[c] . Note that this corresponds to the reverse_any convention when w has size m * q .

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