Prev Next

Declare Independent Variables and Start Recording

Syntax
Independent(x)

Purpose
Start a recording the AD of Base operations with x as the vector of independent variables. Once the AD of Base operation sequence is completed, it must be transferred to a function object; see below.

Variables for a Tape
A tape is create by the call
     Independent(
x)
The corresponding operation sequence is transferred to a function object, and the tape is deleted, using either (see ADFun<Base> f(x, y) )
     ADFun<
Basefxy)
or using (see f.Dependent(x, y) )
     
f.Dependent( xy)
Between when the tape is created and when it is destroyed, we refer to the elements of x, and the values that depend on the elements of x, as variables for the tape created by the call to Independent.

x
The vector x has prototype
     
VectorAD &x
(see VectorAD below). The size of the vector x, must be greater than zero, and is the number of independent variables for this AD operation sequence.

VectorAD
The type VectorAD 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.

Memory Leak
A memory leak will result if a tape is create by a call to Independent and not deleted by a corresponding call to
     ADFun<
Basefxy)
or using
     
f.Dependent( xy)

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
The file Independent.cpp contains an example and test of this operation. It returns true if it succeeds and false otherwise.
Input File: cppad/local/independent.hpp