Prev Next

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@This is cppad-20221105 documentation. Here is a link to its current documentation .
Declare Independent Variables and Start Recording

Syntax
Independent(x)
Independent(xdynamic)
Independent(xabort_op_index)
Independent(xabort_op_indexrecord_compare)
Independent(xabort_op_indexrecord_comparedynamic)

Start Recording
The syntax above starts recording AD of Base operations with x as the independent variable vector. Once the operation sequence is completed, it must be transferred to a function object or aborted; see below.

Stop Recording
The recording is stopped, and the operation sequence is transferred to the AD function object f , using either the function constructor
    ADFun<
Basef(xy)
or the dependent variable specifier
    
f.Dependent(xy)
The only other way to stop a recording is using abort_recording . Between when the recording is started and when it stopped, we refer to the elements of x , and the values that depend on the elements of x , as AD<Base> variables.

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

abort_op_index
If this argument has prototype
    size_t 
abort_op_index
If it is present, it specifies the operator index at which the execution will aborted by calling the CppAD error handler . When this error handler leads to an assert, the user can inspect the call stack to see the source code corresponding to this operator index; see purpose for op_index and NDEBUG . No abort will occur if abort_op_index is zero. If this argument is not present, the default value zero is used for abort_index .

record_compare
This argument has prototype
    bool 
record_compare
If it is present, it specifies if AD compare operations are recorded. It takes extra time and memory to record these operations. On the other hand, they can be useful for detecting when and why a functions recording would change; see abort_op_index above and compare_change . If this argument is not present, the default value true is used for record_compare . If this argument is false, abort_op_index must be zero.

dynamic
If this argument is present, it has prototype
    const 
ADVectordynamic
(see Vector below). It specifies the independent dynamic parameters. The value of these parameters, in the ADFun object f , that can be changed using new_dynamic .

Efficiency
Any operations that use dynamic parameters will be recorded. We use other dynamic parameters to denote parameters that depend on the independent dynamic parameters dynamic , and do not depend on x . It is more efficient to compute other dynamic parameters before calling Independent and include them in the independent dynamic parameter vector dynamic .

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

Parallel Mode
Each thread can have one, and only one, active recording. A call to Independent starts the recording for the current thread. The recording must be stopped by a corresponding call to
    ADFun<
Basefxy)
or
    
f.Dependent( xy)
or abort_recording preformed by the same thread; i.e., thread_alloc::thread_num must be the same.

Example
The file independent.cpp contains an example and test of this operation.
Input File: include/cppad/core/independent/user.omh