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 .
Multiple Directions Forward Mode

Syntax
yq = f.Forward(qrxq)

Purpose
We use @(@ F : \B{R}^n \rightarrow \B{R}^m @)@ to denote the AD function corresponding to f . Given a function @(@ X : \B{R} \rightarrow \B{R}^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<
Basef
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 
Vectorxq
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} = @)@ xqr * 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)} = @)@ xkj ] where xk corresponds to the previous call
    
f.Forward(kxk)
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} = @)@ xkr * j + ell ] where xk corresponds to the previous call
    
f.Forward(krxk)
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{R} \rightarrow \B{R}^n @)@ is defined using the Taylor coefficients @(@ x^{(k),\ell} \in \B{R}^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{R} \rightarrow \B{R}^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{R}^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} = @)@ yqr * 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: include/cppad/core/forward/forward_dir.omh