Prev | Next |
yq = f.Forward(q, r, xq)
f
.
Given a function @(@
X : \B{R} \rightarrow \B{R}^n
@)@,
defined by its
Taylor coefficients
,
forward mode computes the Taylor coefficients for the function
@[@
Y (t) = F [ X(t) ]
@]@
This version of forward mode computes multiple directions as the same
time (reducing the number of passes through the tape). This requires more
memory, but might be faster in some cases.
n
to denote the dimension of the
domain
space for
f
.
m
to denote the dimension of the
range
space for
f
.
f
has prototype
ADFun<Base> f
Note that the ADFun
object
f
is not const
.
After this call we will have
f.size_order() == q + 1
f.size_direction() == r
size_t q
It specifies the order of Taylor Coefficient that we are calculating
and must be greater than zero.
The zero order coefficients can only have one direction computed
and stored in
f
so use forward_zero
to compute the zero order coefficients.
size_t r
It specifies the number of directions that are computed together.
If (
r == 1
), you are only using one direction and
forward_order
is simpler, and should be faster,
than this more general case.
xq
has prototype
const Vector& xq
and its size must be
n*r
(see Vector
below).
For @(@
\ell = 0 , \ldots , r-1
@)@,
@(@
j = 0 , \ldots , n-1
@)@,
the j
-th component of the q
-th order Taylor coefficient
for @(@
X_\ell (t)
@)@ is defined by
@(@
x_j^{(q),\ell} =
@)@
xq[ r * j + ell ]
j
-th component of the zero order Taylor coefficient
for @(@
X_\ell (t)
@)@ is defined by
@(@
x_j^{(0)} =
@)@
xk[ j ]
where
xk
corresponds to the previous call
f.Forward(k, xk)
with
k = 0
.
j
-th component of the k
-th order Taylor coefficient
for @(@
X_\ell (t)
@)@ is defined by
@(@
x_j^{(k),\ell} =
@)@
xk[ r * j + ell ]
where
xk
corresponds to the previous call
f.Forward(k, r, xk)
Note that
r
must have the same value in this previous call.
k
-th derivative of @(@
X_\ell (t)
@)@ is related to
its Taylor coefficients by
@[@
\begin{array}{rcl}
x^{(0)} & = & X_\ell (0)
\\
x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0)
\end{array}
@]@
for @(@
k = 1 , \ldots , q
@)@.
k
-th derivative of @(@
Y_\ell (t)
@)@ is related to
its Taylor coefficients by
@[@
\begin{array}{rcl}
y^{(0)} & = & Y_\ell (0)
\\
y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0)
\end{array}
@]@
for @(@
k = 1 , \ldots , q
@)@.
yq
has prototype
Vector yq
and its size is
m*r
(see Vector
below).
For @(@
\ell = 0 , \ldots , r-1
@)@,
@(@
i = 0 , \ldots , m-1
@)@,
the i
-th component of the q
-th order Taylor coefficient
for @(@
Y_\ell (t)
@)@ is given by
@(@
y_i^{(q),\ell} =
@)@
yq[ r * i + ell ]
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.