Prev | Next |
f.capacity_order(c)
yq = f.Forward(q, xq)
where
q > 0
and
xq.size() == f.Domain()
,
uses the lower order Taylor coefficients and
computes the q
-th order Taylor coefficients for all
the variables in the operation sequence corresponding to
f
.
The capacity_order
operation allows you to control that
amount of memory that is retained by an AD function object
(to hold Forward
results for subsequent calculations).
f
has prototype
ADFun<Base> f
c
has prototype
size_t c
It specifies the number of Taylor coefficient orders that are allocated
in the AD operation sequence corresponding to
f
.
Forward
with the maximum value of
q
equal to
Q
,
it should be faster to pre-allocate memory for these calls using
f.capacity_order(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.
Note that each call to Dependent
frees the old memory
connected to the function object and sets the corresponding
taylor capacity to zero.
q
and higher (that are stored in
f
),
you can reduce the memory allocated to
f
using
f.capacity_order(c)
with
c
equal to
q
.
Note that, if ta_hold_memory
is true, this memory is not actually
returned to the system, but rather held for future use by the same thread.
f
is constructed
with the syntax
ADFun<Base> f(x, y)
,
there is an implicit call to forward_zero
with
xq
equal to
the value of the
independent variables
when the AD operation sequence was recorded.
This corresponds to
c == 1
.