![]() |
Prev | Next | atomic_two_reverse |
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
.
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
).
ok == false
(and not compute anything) for values
of
q
that are greater than those used by your
reverse
mode calculations.
q
has prototype
size_t q
It specifies the highest order Taylor coefficient that
computing the derivative of.
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
has prototype
const CppAD::vector< AD<Base> >& atx
Otherwise,
atx
specifications are the same as for
tx
.
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
has prototype
const CppAD::vector< AD<Base> >& aty
Otherwise,
aty
specifications are the same as for
ty
.
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
has prototype
const CppAD::vector< AD<Base> >& apy
Otherwise,
apy
specifications are the same as for
py
.
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
has prototype
CppAD::vector< AD<Base> >& apx
Otherwise,
apx
specifications are the same as for
px
.
ok
has prototype
bool ok
If it is true
, the corresponding evaluation succeeded,
otherwise it failed.