CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
template<class Base >
void CppAD::local::reverse_sweep ( size_t  d,
size_t  n,
size_t  numvar,
const local::player< Base > *  play,
size_t  J,
const Base *  Taylor,
size_t  K,
Base *  Partial,
bool *  cskip_op,
const pod_vector< addr_t > &  var_by_load_op,
const pod_vector< addr_t > &  subgraph 
)

Compute derivative of arbitrary order forward mode Taylor coefficients.

Template Parameters
Basethis operation sequence was recorded using AD<Base> and computations by this routine are done using type Base.
Parameters
dis the highest order Taylor coefficients that we are computing the derivative of.
nis the number of independent variables on the tape.
numvaris the total number of variables on the tape. This is also equal to the number of rows in the matrix Taylor; i.e., play->num_var_rec().
playThe information stored in play is a recording of the operations corresponding to the function

\[ F : {\bf R}^n \rightarrow {\bf R}^m \]

where $ n $ is the number of independent variables and $ m $ is the number of dependent variables. We define $ u^{(k)} $ as the value of x_k in the previous call of the form f.Forward(k, x_k) We define $ X : {\bf R}^{n \times d} \rightarrow {\bf R}^n $ by

\[ X(t, u) = u^{(0)} + u^{(1)} t + \cdots + u^{(d)} t^d \]

We define $ Y : {\bf R}^{n \times d} \rightarrow {\bf R}^m $ by

\[ Y(t, u) = F[ X(t, u) ] \]

We define the function $ W : {\bf R}^{n \times d} \rightarrow {\bf R} $ by

\[ W(u) = \sum_{k=0}^{d} ( w^{(k)} )^{\rm T} \frac{1}{k !} \frac{\partial^k}{\partial t^k} Y(0, u) \]

(The matrix $ w \in {\bf R}^m $, is defined below under the heading Partial.) Note that the scale factor 1 / k converts the k-th partial derivative to the k-th order Taylor coefficient. This routine computes the derivative of $ W(u) $ with respect to all the Taylor coefficients $ u^{(k)} $ for $ k = 0 , ... , d $.
JIs the number of columns in the coefficient matrix Taylor. This must be greater than or equal d + 1.
TaylorFor i = 1 , ... , numvar, and for k = 0 , ... , d, Taylor [ i * J + k ] is the k-th order Taylor coefficient corresponding to variable with index i on the tape. The value $ u \in {\bf R}^{n \times d} $, at which the derivative is computed, is defined by $ u_j^{(k)} $ = Taylor [ j * J + k ] for j = 1 , ... , n, and for k = 0 , ... , d.
KIs the number of columns in the partial derivative matrix Partial. It must be greater than or equal d + 1.
PartialInput: The last $ m $ rows of Partial are inputs. The matrix $ w $, used to define $ W(u) $, is specified by these rows. For i = 0 , ... , m - 1, for k = 0 , ... , d, Partial [ (numvar - m + i ) * K + k ] = w[i,k].

Temporary: For i = n+1 , ... , numvar - 1 and for k = 0 , ... , d, the value of Partial [ i * K + k ] is used for temporary work space and its output value is not defined.

Output: For j = 1 , ... , n and for k = 0 , ... , d, Partial [ j * K + k ] is the partial derivative of $ W( u ) $ with respect to $ u_j^{(k)} $.
cskip_opIs a vector with size play->num_op_rec(). If cskip_op[i] is true, the operator index i in the recording does not affect any of the dependent variable (given the value of the independent variables). Note that all the operators in an atomic function call are skipped as a block, so only the last UserOp fore each call needs to have cskip_op[i] true.
var_by_load_opis a vector with size play->num_load_op_rec(). It contains the variable index corresponding to each load instruction. In the case where the index is zero, the instruction corresponds to a parameter (not variable).
subgraphis the set of operators over which the reverse mode calculations will be preformed. For k = 0, ... , subgraph.size() - 1, subgraph[k] is an operator index and
play->num_op_rec() > subgraph[k] > subgraph[k-1]
If i_var is a variable index, and play->var2op(i_var) is not in the subgraph, then the partials with respect to i_var are not modified and need to be initialized as zero. Note that this means the partial for the independent varaibles, that are not in the subgraph are not calculated. If part of an atomic function call is in the subgraph, the entire atomic function call must be in the subgraph.
Assumptions
The first operator on the tape is a BeginOp, and the next n operators are InvOp operations for the corresponding independent variables; see play->check_inv_op(n_ind).

Definition at line 183 of file reverse_sweep.hpp.

Referenced by CppAD::ADFun< Base >::Reverse(), and CppAD::ADFun< Base >::subgraph_reverse().