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 .
Evaluate a Function Defined in Terms of an ODE

Syntax
# include <cppad/speed/ode_evaluate.hpp>
ode_evaluate(xpfp)

Purpose
This routine evaluates a function @(@ f : \B{R}^n \rightarrow \B{R}^n @)@ defined by @[@ f(x) = y(x, 1) @]@ where @(@ y(x, t) @)@ solves the ordinary differential equation @[@ \begin{array}{rcl} y(x, 0) & = & x \\ \partial_t y (x, t ) & = & g[ y(x,t) , t ] \end{array} @]@ where @(@ g : \B{R}^n \times \B{R} \rightarrow \B{R}^n @)@ is an unspecified function.

Inclusion
The template function ode_evaluate is defined in the CppAD namespace by including the file cppad/speed/ode_evaluate.hpp (relative to the CppAD distribution directory).

Float

Operation Sequence
The type Float must be a NumericType . The Float operation sequence for this routine does not depend on the value of the argument x , hence it does not need to be retaped for each value of @(@ x @)@.

fabs
If y and z are Float objects, the syntax
    
y = fabs(z)
must be supported. Note that it does not matter if the operation sequence for fabs depends on z because the corresponding results are not actually used by ode_evaluate; see fabs in Runge45 .

x
The argument x has prototype
    const CppAD::vector<
Float>& x
It contains he argument value for which the function, or its derivative, is being evaluated. The value @(@ n @)@ is determined by the size of the vector x .

p
The argument p has prototype
    size_t 
p

p == 0
In this case a numerical method is used to solve the ode and obtain an accurate approximation for @(@ y(x, 1) @)@. This numerical method has a fixed that does not depend on x .

p = 1
In this case an analytic solution for the partial derivative @(@ \partial_x y(x, 1) @)@ is returned.

fp
The argument fp has prototype
    CppAD::vector<
Float>& fp
The input value of the elements of fp does not matter.

Function
If p is zero, fp has size equal to @(@ n @)@ and contains the value of @(@ y(x, 1) @)@.

Gradient
If p is one, fp has size equal to n^2 and for @(@ i = 0 , \ldots 1 @)@, @(@ j = 0 , \ldots , n-1 @)@ @[@ \D{y[i]}{x[j]} (x, 1) = fp [ i \cdot n + j ] @]@

Example
The file ode_evaluate.cpp contains an example and test of ode_evaluate.hpp.

Source Code
The file ode_evaluate.hpp contains the source code for this template function.
Input File: include/cppad/speed/ode_evaluate.hpp