Purpose
The Taylor coefficients calculated by Forward mode calculations
are retained in an ADFun
object for subsequent use during
Reverse
mode or higher order Forward mode calculations.
This operation allow you to control that amount of memory
that is retained by an AD function object
(for subsequent calculations).
c
The argument c has prototype
size_t c It specifies the number of Taylor coefficients that are allocated for
each variable in the AD operation sequence corresponding to f.
Discussion
A call to Forward
with the syntax
y_p = f.Forward(p, x_p) uses the lower order Taylor coefficients and
computes the p-th order Taylor coefficients for all
the variables in the operation sequence corresponding to f.
(You can determine the number of variables in the operation sequence
using the size_var
function.)
Pre-Allocating Memory
If you plan to make calls to Forward with the maximum value of
p equal to q,
it should be faster to pre-allocate memory for these calls using
f.capacity_taylor(c) with c equal to q + 1
.
If you do no do this, Forward will automatically allocate memory
and will copy the results to a larger buffer, when necessary.
Freeing Memory
If you no longer need the Taylor coefficients of order q
and higher (that are stored in f),
you can reduce the memory allocated to f using
f.capacity_taylor(c) with c equal to q.
Original State
If f is constructed
with the syntax
ADFun<Base> f(x, y) ,
there is an implicit call to Forward with p equal to zero
and x_p equal to
the value of the
independent variables
when the AD operation sequence was recorded.
Example
The file
Forward.cpp
contains an example and test of these operations.
It returns true if it succeeds and false otherwise.
Input File: cppad/local/cap_taylor.hpp