Evaluate a Function Defined in Terms of an ODE
Keywords: evaluate function defined terms ode ode_evaluate syntax purpose inclusion float operation sequence fabs x p == 0 = 1 fp gradient example source code

| Prev | Next |  |  |  |  |  |  |

Evaluate a Function Defined in Terms of an ODE
Syntax
`# include <cppad/speed/ode_evaluate.hpp>
` `ode_evaluate(x, p, fp)`
Purpose
This routine evaluates a function f : R n → R n defined by f ( x ) = y ( x , 1 ) where y ( x , t ) solves the ordinary differential equation y ( x , 0 ) = x ∂ t y ( x , t ) = g [ y ( x , t ) , t ] where g : R n × R → 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .
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 ∂ 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 , … and n -1 , j = 0 , … , n -1 ∂ y [ i ] ∂ x [ j ] ( x , 1 ) = fp [ i · n + j ]
Example
The file ode_evaluate.cpp contains an example and test of `ode_evaluate.hpp`. It returns true if it succeeds and false otherwise.
Source Code
The file ode_evaluate.hpp contains the source code for this template function.

Input File: cppad/speed/ode_evaluate.hpp