Prev | Next |
dw = f.Reverse(2, w)
f
.
Reverse mode computes the derivative of the Forward
mode
Taylor coefficients
with respect to the domain variable @(@
x
@)@.
x_k
in the previous call (counting this call) of the form
f.Forward(k, x_k)
If there is no previous call with @(@
k = 0
@)@,
@(@
x^{(0)}
@)@ is the value of the independent variables when the
corresponding
AD of
Base
operation sequence
was recorded.
f
has prototype
const ADFun<Base> f
Before this call to Reverse
, the value returned by
f.size_order()
must be greater than or equal two (see size_order
).
w
has prototype
const Vector &w
(see Vector
below)
and its size
must be equal to
m
, the dimension of the
range
space for
f
.
dw
has prototype
Vector dw
(see Vector
below).
It contains both the derivative
@(@
W^{(1)} (x)
@)@ and the derivative @(@
U^{(1)} (x)
@)@.
The size of
dw
is equal to @(@
n \times 2
@)@,
where @(@
n
@)@ is the dimension of the
domain
space for
f
.
dw
contains the same values as are returned
by reverse_one
.
Vector
must be a SimpleVector
class with
elements of type
Base
.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
i
-th elementary vector.
It follows that for @(@
j = 0, \ldots, n-1
@)@
@[@
\begin{array}{rcl}
dw[ j * 2 + 1 ]
& = &
w_i \sum_{\ell=0}^{n-1}
\DD{F_i}{ u_j }{ u_\ell } \left( x^{(0)} \right) x_\ell^{(1)}
\\
& = &
\left[ F_i^{(2)} \left( x^{(0)} \right) * x^{(1)} \right]_j
\end{array}
@]@
Thus the vector @(@
( dw[1], dw[3], \ldots , dw[ n * q - 1 ] )
@)@
is equal to the Hessian of @(@
F_i (x)
@)@ times the direction
@(@
x^{(1)}
@)@.
In the special case where
@(@
x^{(1)}
@)@ is the l
-th
elementary vector
,
@[@
dw[ j * 2 + 1 ] = \DD{ F_i }{ x_j }{ x_\ell } \left( x^{(0)} \right)
@]@