Prev Next atomic_two_reverse

@(@\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}} }@)@ This is cppad-20221105 documentation. Here is a link to its current documentation .
Atomic Reverse Mode

Syntax

Base
ok = afun.reverse(qtxtypxpy)
This syntax is used by f.Forward where f has prototype
    ADFun<
Basef
and afun is used in f .

AD<Base>
ok = afun.reverse(qatxatyapxapy)
This syntax is used by af.Forward where af has prototype
    ADFun< AD<
Base> , Base > af
and afun is used in af (see base2ad ).

Purpose
This function is used by reverse to compute derivatives.

Implementation
If you are using reverse mode, this virtual function must be defined by the atomic_user class. It can just return ok == false (and not compute anything) for values of q that are greater than those used by your reverse mode calculations.

q
The argument q has prototype
    size_t 
q
It specifies the highest order Taylor coefficient that computing the derivative of.

tx
The argument tx has prototype
    const CppAD::vector<
Base>& tx
and tx.size() == (q+1)*n . For @(@ j = 0 , \ldots , n-1 @)@ and @(@ k = 0 , \ldots , q @)@, we use the Taylor coefficient notation @[@ \begin{array}{rcl} x_j^k & = & tx [ j * ( q + 1 ) + k ] \\ X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^q t^q \end{array} @]@ Note that superscripts represent an index for @(@ x_j^k @)@ and an exponent for @(@ t^k @)@. Also note that the Taylor coefficients for @(@ X(t) @)@ correspond to the derivatives of @(@ X(t) @)@ at @(@ t = 0 @)@ in the following way: @[@ x_j^k = \frac{1}{ k ! } X_j^{(k)} (0) @]@

atx
The argument atx has prototype
    const CppAD::vector< AD<
Base> >& atx
Otherwise, atx specifications are the same as for tx .

ty
The argument ty has prototype
    const CppAD::vector<
Base>& ty
and tx.size() == (q+1)*m . For @(@ i = 0 , \ldots , m-1 @)@ and @(@ k = 0 , \ldots , q @)@, we use the Taylor coefficient notation @[@ \begin{array}{rcl} Y_i (t) & = & f_i [ X(t) ] \\ Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^q t^q + o ( t^q ) \\ y_i^k & = & ty [ i * ( q + 1 ) + k ] \end{array} @]@ where @(@ o( t^q ) / t^q \rightarrow 0 @)@ as @(@ t \rightarrow 0 @)@. Note that superscripts represent an index for @(@ y_j^k @)@ and an exponent for @(@ t^k @)@. Also note that the Taylor coefficients for @(@ Y(t) @)@ correspond to the derivatives of @(@ Y(t) @)@ at @(@ t = 0 @)@ in the following way: @[@ y_j^k = \frac{1}{ k ! } Y_j^{(k)} (0) @]@

aty
The argument aty has prototype
    const CppAD::vector< AD<
Base> >& aty
Otherwise, aty specifications are the same as for ty .

F
We use the notation @(@ \{ x_j^k \} \in \B{R}^{n \times (q+1)} @)@ for @[@ \{ x_j^k \W{:} j = 0 , \ldots , n-1, k = 0 , \ldots , q \} @]@ We use the notation @(@ \{ y_i^k \} \in \B{R}^{m \times (q+1)} @)@ for @[@ \{ y_i^k \W{:} i = 0 , \ldots , m-1, k = 0 , \ldots , q \} @]@ We define the function @(@ F : \B{R}^{n \times (q+1)} \rightarrow \B{R}^{m \times (q+1)} @)@ by @[@ y_i^k = F_i^k [ \{ x_j^k \} ] @]@ Note that @[@ F_i^0 ( \{ x_j^k \} ) = f_i ( X(0) ) = f_i ( x^0 ) @]@ We also note that @(@ F_i^\ell ( \{ x_j^k \} ) @)@ is a function of @(@ x^0 , \ldots , x^\ell @)@ and is determined by the derivatives of @(@ f_i (x) @)@ up to order @(@ \ell @)@.

G, H
We use @(@ G : \B{R}^{m \times (q+1)} \rightarrow \B{R} @)@ to denote an arbitrary scalar valued function of @(@ \{ y_i^k \} @)@. We use @(@ H : \B{R}^{n \times (q+1)} \rightarrow \B{R} @)@ defined by @[@ H ( \{ x_j^k \} ) = G[ F( \{ x_j^k \} ) ] @]@

py
The argument py has prototype
    const CppAD::vector<
Base>& py
and py.size() == m * (q+1) . For @(@ i = 0 , \ldots , m-1 @)@, @(@ k = 0 , \ldots , q @)@, @[@ py[ i * (q + 1 ) + k ] = \partial G / \partial y_i^k @]@

apy
The argument apy has prototype
    const CppAD::vector< AD<
Base> >& apy
Otherwise, apy specifications are the same as for py .

px
The px has prototype
    CppAD::vector<
Base>& px
and px.size() == n * (q+1) . The input values of the elements of px are not specified (must not matter). Upon return, for @(@ j = 0 , \ldots , n-1 @)@ and @(@ \ell = 0 , \ldots , q @)@, @[@ \begin{array}{rcl} px [ j * (q + 1) + \ell ] & = & \partial H / \partial x_j^\ell \\ & = & ( \partial G / \partial \{ y_i^k \} ) \cdot ( \partial \{ y_i^k \} / \partial x_j^\ell ) \\ & = & \sum_{k=0}^q \sum_{i=0}^{m-1} ( \partial G / \partial y_i^k ) ( \partial y_i^k / \partial x_j^\ell ) \\ & = & \sum_{k=\ell}^q \sum_{i=0}^{m-1} py[ i * (q + 1 ) + k ] ( \partial F_i^k / \partial x_j^\ell ) \end{array} @]@ Note that we have used the fact that for @(@ k < \ell @)@, @(@ \partial F_i^k / \partial x_j^\ell = 0 @)@.

apx
The argument apx has prototype
    CppAD::vector< AD<
Base> >& apx
Otherwise, apx specifications are the same as for px .

ok
The return value ok has prototype
    bool 
ok
If it is true, the corresponding evaluation succeeded, otherwise it failed.
Input File: include/cppad/core/atomic/two/reverse.hpp