Prev Next

f2cad Common Interface to Adolc, CppAD, and Fadbad

Syntax
void f2cad::Independent(nx)
void f2cad::Dependent(my)
double f2cad::Partial<doublereal>(ij)
double f2cad::Value(z)
double f2cad::Sign(xy)

Purpose
These routines provide a common f2cad interface to the more efficient routines documented as part of the Adolc , CppAD , and Fadbad packages. They are not efficient and should only be used the example and tests of routines that have been converted from Fortran to an AD type by f2cad.

doublereal
The type doublereal is the C++ type that corresponds to Fortran single and double precision. This type is mapped to an AD type that depends on the library being used:
Library typedef
libf2c_adolc.a typedef adouble         doublereal
libf2c_cppad.a typedef CppAD::<double> doublereal
libf2c_fadbad.a typedef F<double>       doublereal

integer
The type integer is the C++ type that corresponds to Fortran integers.

Vector Elements

Tape State
Each doublereal type has a tape state and the initial tape state is Empty.

Independent
The argument n has prototype
     integer 
n
It specifies the dimension of the domain space for the function being defined. The argument x has prototype
     doublereal *
x
It is a vector of length n that contains the independent variables (and values) for this function recording. The value of the elements of x are not affected by calling this routine. (The elements are not const in the prototype because the AD information connected to them may be affected.)

Tape State
The tape state must be either Empty or Complete when this routine is called. After this routine is called, the tape state will be Recording,

Dependent
The argument m has prototype
     integer 
m
It specifies the dimension of the range space for the function being defined. The argument y has prototype
     doublereal *
x
It is a vector of length m that contains the dependent variables (and values) for this function recording. The value of the elements of y are not affected by calling this routine. (The elements are not const in the prototype because the AD information connected to them may be affected.)

Tape State
The tape state must be Recording when this routine is called. After this routine is called, the tape state will be Complete,

Partial
The argument i has prototype
     integer 
i
It must be greater than or equal zero and less than the dimension of the range space for the function. The argument j has prototype
     integer 
j
It must be greater than or equal zero and less than the dimension of the domain space for the function. The return value from Partial is the partial derivative of the i-th dependent variable with respect to the j-th dependent variable (i-th function value with respect to j-th function argument).

Tape State
The tape state must be Complete when this routine is called. The tape state is not affected by this call.

Value
The argument z has prototype
     const doublereal &
z
This function returns the value corresponding to the doublereal object z .

Sign
The arguments x and y have prototypes
     doublereal* 
x
     doublereal* 
y
This function returns  \[
\left\{ \begin{array}{ll}
     + |x| & \R{if} \; y \geq 0
     \\
     - |x| & \R{otherwise}
\end{array} \right.
\] 


Tape State
The tape state must be either Empty or Complete when this routine is called. The tape state is not affected by this call.

Source Code
The following table contains links to the source code for each AD type:

Contents
AdolcLinkf2cad Common Interface for Adolc
CppADLinkf2cad Common Interface for CppAD
FadbadLinkf2cad Common Interface for Fadbad

Input File: omh/f2cad_link.omh