Prev Next FunConstruct

Construct an ADFun Object and Stop Recording

Syntax
ADFun<Basef
ADFun<Basef(xy)

Purpose
The AD<Base> object f can store an AD of Base operation sequence . It can then be used to calculate derivatives of the corresponding AD function  \[
     F : B^n \rightarrow B^m
\] 
where  B is the space corresponding to objects of type Base.

x
If the argument x is present, 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<
Basef(xy)
.

y
The sequence of operations that map x to y are stored in the AD function object f.

Default Constructor
The default constructor
     ADFun<
Basef
creates an AD<Base> object with no corresponding operation sequence; i.e.,
     
f.size_var()
returns the value zero (see size_var ).

Sequence Constructor
The sequence constructor
     ADFun<
Basef(xy)
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 first order taylor_ coefficients (corresponding to the value of x) in f. This is equivalent to the following steps using the default constructor:
  1. Create f with the default constructor
         ADFun<
    Basef;
  2. Stop the tape and storing the operation sequence using
         
    f.Dependent(xy);
    (see Dependent ).
  3. Calculating the first order taylor_ coefficients for all the variables in the operation sequence using
         
    f.Forward(px_p)
    with p equal to zero and the elements of x_p equal to the corresponding elements of x (see Forward ).


OpenMP
In the case of multi-threading with OpenMP, the call to Independent and the corresponding call to
     ADFun<
Basefxy)
or
     
f.Dependent( xy)
must be preformed by the same thread.

Example

Sequence Constructor
The file Independent.cpp contains an example and test of the sequence constructor. It returns true if it succeeds and false otherwise.

Default Constructor
The files FunCheck.cpp and HesLagrangian.cpp contain an examples and tests using the default constructor. They return true if they succeed and false otherwise.
Input File: cppad/local/fun_construct.hpp