\(\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}} }\)
atomic_two_reverse
Atomic Reverse Mode
Syntax
Base
ok = afun .
reverse
( q , tx , ty , px , py )
This syntax is used by f . Forward
where f has prototype
ADFun
< Base > f
and afun is used in f .
AD<Base>
ok = afun .
reverse
( q , atx , aty , apx , apy )
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
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:
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
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:
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
We use the notation \(\{ y_i^k \} \in \B{R}^{m \times (q+1)}\) for
We define the function \(F : \B{R}^{n \times (q+1)} \rightarrow \B{R}^{m \times (q+1)}\) by
Note that
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
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\),
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\),
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.