Prev | Next |
ADFun<Base> f(x, y);
ADFun<Base> f
f.swap(g)
f = g
ADFun<Base>
object
f
stores an AD of
Base
operation sequence
.
It can then be used to calculate derivatives of the corresponding
AD function
@[@
F : \B{R}^n \rightarrow \B{R}^m
@]@
where @(@
B
@)@ is the space corresponding to objects of type
Base
.
x
is present, it has prototype
const ADVector &x
It must be the vector argument in the previous call to
Independent
.
Neither its size, or any of its values, are allowed to change
between calling
Independent(x)
and
ADFun<Base> f(x, y)
y
is present, it has prototype
const ADVector &y
The sequence of operations that map
x
to
y
are stored in the ADFun object
f
.
ADVector
must be a SimpleVector
class with
elements of type
AD<Base>
.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
ADFun<Base> g
creates an
AD<Base>
object with no corresponding operation sequence; i.e.,
g.size_var()
returns the value zero (see size_var
).
ADFun<Base> f(x, y)
creates the
AD<Base>
object
f
,
stops the recording of AD of
Base
operations
corresponding to the call
Independent(x)
and stores the corresponding operation sequence in the object
f
.
It then stores the zero order Taylor coefficients
(corresponding to the value of
x
) in
f
.
This is equivalent to the following steps using the default constructor:
f
with the default constructor
ADFun<Base> f;
f.Dependent(x, y);
(see Dependent
).
f.Forward(p, x_p)
with
p
equal to zero and the elements of
x_p
equal to the corresponding elements of
x
(see Forward
).
ADFun<Base>
copy constructor;
i.e., the following syntax is not allowed:
ADFun<Base> g(f)
where
f
is an
ADFun<Base>
object.
Use its default constructor
instead
and its assignment operator.
%f%.swap(%g%)%
exchanges the contents of
the two
ADFun<Base>
functions; i.e.,
f
(
g
) before the swap is identical to
g
(
f
) after the swap.
ADFun<Base>
assignment operation
g = f
makes a copy of the operation sequence currently stored in
f
in the object
g
.
The object
f
is not affected by this operation and
can be const
.
All of information (state) stored in
f
is copied to
g
and any information originally in
g
is lost.
f
is a temporary object
(and enough C++11 features are supported by the compiler)
this assignment will use move semantics.
This avoids the overhead of the copying all the information from
f
to
g
.
f
(computed by f.Forward
) is
copied to
g
.
Hence, directly after this operation
g.size_order() == f.size_order()
f
(computed by f.ForSparseJac
) is
copied to
g
.
Hence, directly after this operation
g.size_forward_bool() == f.size_forward_bool()
g.size_forward_set() == f.size_forward_set()
Independent
,
and the corresponding call to
ADFun<Base> f( x, y)
or
f.Dependent( x, y)
or abort_recording
,
must be preformed by the same thread; i.e.,
thread_alloc::thread_num
must be the same.
ADFun<Base>
assignment operator.