\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\)
cpp_fun_forward#
View page sourceForward Mode AD#
Syntax#
yp = f.forward ( p , xp )
Taylor Coefficient#
For a function \(g(t)\) of a scalar argument \(t \in \B{R}\),
the p-th order Taylor coefficient is its
p -th order derivative divided by p factorial
and evaluated at \(t = 0\); i.e.,
f#
This is either a d_fun or a_fun function object. Note that its state is changed by this operation because all the Taylor coefficient that it calculates for every variable in recording are stored. See more discussion of this fact under the heading p below.
f(x)#
We use the notation \(f: \B{R}^n \rightarrow \B{R}^m\) for the function corresponding to f . Note that n is the size of ax and m is the size of ay in to the constructor for f .
X(t)#
We use the notation \(X : \B{R} \rightarrow \B{R}^n\) for a function that the calling routine chooses.
Y(t)#
We define the function \(Y : \B{R} \rightarrow \B{R}^n\) by \(Y(t) = f(X(t))\).
p#
This argument has prototype
int pand is non-negative.
It is the order of the Taylor coefficient being calculated.
If there was no call to forward for this f ,
the value of p must be zero.
Otherwise, it must be between zero and one greater that its
value for the previous call using this f .
After this call, the Taylor coefficients for orders zero though p ,
and for every variable in the recording, will be stored in f .
size_order#
After this call, f_size_order() is p +1 .
xp#
If f is a d_fun or a_fun ,
this argument has prototype
const vec_double& xpconst vec_a_double& xprespectively and its size must be n . It specifies the p-th order Taylor coefficients for X(t ) .
yp#
If f is a d_fun or a_fun ,
the result has prototype
vec_double& ypvec_a_double& yprespectively and its size is m . It is the p-th order Taylor coefficients for \(Y(t)\).