Prev Next Index-> contents reference index search external Up-> CppAD ADFun Forward forward_dir 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 Forward-> forward_zero forward_one forward_two forward_order forward_dir size_order compare_change capacity_order number_skip forward_dir-> forward_dir.cpp Headings-> Syntax Purpose Reverse Mode Notation ---..n ---..m f q r xq Zero Order Non-Zero Lower Orders X(t) Y(t) yq Vector Example

$\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}} }$
Multiple Directions Forward Mode

Syntax
yq = f.Forward(q, r, xq) 
Purpose
We use $F : B^n \rightarrow B^m$ to denote the AD function corresponding to f . Given a function $X : B \rightarrow B^n$, defined by its Taylor coefficients , forward mode computes the Taylor coefficients for the function $$Y (t) = F [ X(t) ]$$ This version of forward mode computes multiple directions as the same time (reducing the number of passes through the tape). This requires more memory, but might be faster in some cases.

Reverse Mode
Reverse mode for multiple directions has not yet been implemented. If you have speed tests that indicate that multiple direction forward mode is faster, and you want to try multiple direction reverse mode, contact the CppAD project manager.

Notation

n
We use n to denote the dimension of the domain space for f .

m
We use m to denote the dimension of the range space for f .

f
The ADFun object f has prototype       ADFun<Base> f  Note that the ADFun object f is not const. After this call we will have       f.size_order()     == q + 1      f.size_direction() == r 
q
This argument has prototype       size_t q  It specifies the order of Taylor Coefficient that we are calculating and must be greater than zero. The zero order coefficients can only have one direction computed and stored in f so use forward_zero to compute the zero order coefficients.

r
This argument has prototype       size_t r  It specifies the number of directions that are computed together. If ( r == 1 ), you are only using one direction and forward_order is simpler, and should be faster, than this more general case.

xq
The argument xq has prototype       const Vector& xq  and its size must be n*r (see Vector below). For $\ell = 0 , \ldots , r-1$, $j = 0 , \ldots , n-1$, the j-th component of the q-th order Taylor coefficient for $X_\ell (t)$ is defined by        $x_j^{(q),\ell} =$ xq[ r * j + ell ]

Zero Order
For $j = 0 , \ldots , n-1$, the j-th component of the zero order Taylor coefficient for $X_\ell (t)$ is defined by        $x_j^{(0)} =$ xk[ j ] where xk corresponds to the previous call       f.Forward(k, xk)  with k = 0 .

Non-Zero Lower Orders
For $\ell = 0 , \ldots , r-1$, $j = 0 , \ldots , n-1$, $k = 1, \ldots , q-1$, the j-th component of the k-th order Taylor coefficient for $X_\ell (t)$ is defined by        $x_j^{(k),\ell} =$ xk[ r * j + ell ] where xk corresponds to the previous call       f.Forward(k, r, xk)  Note that r must have the same value in this previous call.

X(t)
For $\ell = 0 , \ldots , r-1$, the function $X_\ell : B \rightarrow B^n$ is defined using the Taylor coefficients $x^{(k),\ell} \in B^n$: $$X_\ell (t) = x^{(0)} + x^{(1),\ell} * t^1 + \cdots + x^{(q),\ell} t^q$$ Note that the k-th derivative of $X_\ell (t)$ is related to its Taylor coefficients by $$\begin{array}{rcl} x^{(0)} & = & X_\ell (0) \\ x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0) \end{array}$$ for $k = 1 , \ldots , q$.

Y(t)
For $\ell = 0 , \ldots , r-1$, the function $Y_\ell : B \rightarrow B^m$ is defined by $Y_\ell (t) = F[ X_\ell (t) ]$. We use $y^{(0)}$ for the zero order coefficient and $y^{(k),\ell} \in B^m$ to denote the hight order coefficients; i.e., $$Y_\ell (t) = y^{(0)} + y^{(1),\ell} * t^1 + \cdots + y^{(q),\ell} * t^q + o( t^q )$$ where $o( t^q ) * t^{-q} \rightarrow 0$ as $t \rightarrow 0$. Note that the k-th derivative of $Y_\ell (t)$ is related to its Taylor coefficients by $$\begin{array}{rcl} y^{(0)} & = & Y_\ell (0) \\ y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) \end{array}$$ for $k = 1 , \ldots , q$.

yq
The argument yq has prototype       Vector yq  and its size is m*r (see Vector below). For $\ell = 0 , \ldots , r-1$, $i = 0 , \ldots , m-1$, the i-th component of the q-th order Taylor coefficient for $Y_\ell (t)$ is given by        $y_i^{(q),\ell} =$ yq[ r * i + ell ]

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

Example
The file forward_dir.cpp contains an example and test using one order (multiple orders). They return true if they succeed and false otherwise.
Input File: omh/forward/forward_dir.omh