Prev Next Index-> contents reference index search external Up-> CppAD ADFun drivers ForTwo CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix ADFun-> record_adfun drivers Forward Reverse sparsity_pattern sparse_derivative optimize abs_normal FunCheck check_for_nan drivers-> Jacobian Hessian ForOne RevOne ForTwo RevTwo ForTwo-> for_two.cpp Headings-> Syntax Purpose f x j k ddy VectorBase VectorSize_t ForTwo Uses Forward Examples

$\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}} }$
Forward Mode Second Partial Derivative Driver

Syntax
ddy = f.ForTwo(xjk)

Purpose
We use $F : B^n \rightarrow B^m$ to denote the AD function corresponding to f . The syntax above sets $$ddy [ i * p + \ell ] = \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x)$$ for $i = 0 , \ldots , m-1$ and $\ell = 0 , \ldots , p$, where $p$ is the size of the vectors j and k .

f
The object f has prototype
Basef
Note that the ADFun object f is not const (see ForTwo Uses Forward below).

x
The argument x has prototype
const
VectorBase &x
(see VectorBase below) and its size must be equal to n , the dimension of the domain space for f . It specifies that point at which to evaluate the partial derivatives listed above.

j
The argument j has prototype
const
VectorSize_t &j
(see VectorSize_t below) We use p to denote the size of the vector j . All of the indices in j must be less than n ; i.e., for $\ell = 0 , \ldots , p-1$, $j[ \ell ] < n$.

k
The argument k has prototype
const
VectorSize_t &k
(see VectorSize_t below) and its size must be equal to p , the size of the vector j . All of the indices in k must be less than n ; i.e., for $\ell = 0 , \ldots , p-1$, $k[ \ell ] < n$.

ddy
The result ddy has prototype

VectorBase ddy
(see VectorBase below) and its size is $m * p$. It contains the requested partial derivatives; to be specific, for $i = 0 , \ldots , m - 1$ and $\ell = 0 , \ldots , p - 1$ $$ddy [ i * p + \ell ] = \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x)$$

VectorBase
The type VectorBase must be a SimpleVector class with elements of type Base . The routine CheckSimpleVector will generate an error message if this is not the case.

VectorSize_t
The type VectorSize_t must be a SimpleVector class with elements of type size_t . The routine CheckSimpleVector will generate an error message if this is not the case.

ForTwo Uses Forward
After each call to Forward , the object f contains the corresponding Taylor coefficients . After a call to ForTwo, the zero order Taylor coefficients correspond to f.Forward(0, x) and the other coefficients are unspecified.

Examples
The routine ForTwo is both an example and test. It returns true, if it succeeds and false otherwise.