Prev | Next | chkpoint_one |
checkpoint
class has been deprecated.
Use chkpoint_two
instead.
checkpoint<Base> atom_fun(
name, algo, ax, ay, sparsity, optimize
)
sv = atom_fun.size_var()
atom_fun.option(option_value)
algo(ax, ay)
atom_fun(ax, ay)
checkpoint<Base>::clear()
Base
is an AD type, it is possible to record
Base
operations.
Note that
atom_fun
will treat
algo
as an atomic
operation while recording
AD<Base>
operations, but not while
recording
Base
operations.
See the chkpoint_one_mul_level.cpp
example.
checkpoint
class is derived from atomic_base
and makes this easy.
It implements all the atomic_base
virtual functions
and hence its source code cppad/core/chkpoint_one/chkpoint_one.hpp
provides an example implementation of atomic_two
.
The difference is that chkpoint_one.hpp
uses AD
instead of user provided derivatives.
checkpoint<Base> atom_fun(name, algo, ax, ay)
AD<Base>
operations when the constructor is called.
atom_fun
must not be destructed for as long
as any
ADFun<Base>
object uses its atomic operation.
atomic_base
.
Base
specifies the base type for AD operations.
ADVector
must be a
simple vector class
with elements of type
AD<Base>
.
checkpoint
constructor argument has prototype
const char* name
It is the name used for error reporting.
The suggested value for
name
is
atom_fun
; i.e.,
the same name as used for the object being constructed.
const ADVector& ax
and size must be equal to
n
.
It specifies vector @(@
x \in \B{R}^n
@)@
at which an
AD<Base>
version of
@(@
y = f(x)
@)@ is to be evaluated.
ADVector& ay
Its input size must be equal to
m
and does not change.
The input values of its elements do not matter.
Upon return, it is an
AD<Base>
version of
@(@
y = f(x)
@)@.
atomic_base<Base>::option_enum sparsity
It specifies sparsity
in the atomic_base
constructor and must be either
atomic_base<Base>::pack_sparsity_enum
,
atomic_base<Base>::bool_sparsity_enum
, or
atomic_base<Base>::set_sparsity_enum
.
This argument is optional and its default value is unspecified.
bool optimize
It specifies if the recording corresponding to the atomic function
should be optimized
.
One expects to use a checkpoint function many times, so it should
be worth the time to optimize its operation sequence.
For debugging purposes, it may be useful to use the
original operation sequence (before optimization)
because it corresponds more closely to
algo
.
This argument is optional and its default value is true.
size_var
member function return value has prototype
size_t sv
It is the size_var
for the
ADFun<Base>
object is used to store the operation sequence
corresponding to
algo
.
option
syntax can be used to set the type of sparsity
pattern used by
atom_fun
.
This is an
atomic_base<Base>
function and its documentation
can be found at atomic_two_option
.
algo
is arbitrary, except for the fact that
the syntax
algo(ax, ay)
must evaluate the function @(@
y = f(x)
@)@ using
AD<Base>
operations.
In addition, we assume that the
operation sequence
does not depend on the value of
ax
.
ax
it computes the corresponding value of
ay
using the operation sequence corresponding to
algo
.
If
AD<Base>
operations are being recorded,
it enters the computation as single operation in the recording
see start recording
.
(Currently each use of
atom_fun
actually corresponds to
m+n+2
operations and creates
m
new variables,
but this is not part of the CppAD specifications and my change.)
clear
routine cannot be called
while in parallel
execution mode.
atomic_base
class holds onto static work space
that is not connected to a particular object
(in order to increase speed by avoiding system memory allocation calls).
This call makes to work space available
to
for other uses by the same thread.
This should be called when you are done using the
atomic functions for a specific value of
Base
.