![]() |
Prev | Next |
# include <cppad/speed/ode_evaluate.hpp>
ode_evaluate(x, m, fm)
\[
\begin{array}{rcl}
y(x, 0) & = & b(x)
\\
\partial_t y ( x , t ) & = & g[ x , y(x,t) , t ]
\end{array}
\]
where
b : \R^n \rightarrow \R^n
and
g : \R^n \times \R^n \times \R \rightarrow \R
are not any further specified.
A numerical method is used to solve the ode and obtain an accurate
approximation for
y(x, 1)
.
This in turn is used to compute values and gradients for the
function
f : \R^n \rightarrow \R
defined by
\[
f(x) = y_n ( x , 1)
\]
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
must be a NumericType
.
In addition, if
y
and
z
are
Float
objects,
y = exp(z)
must set the
y
equal the exponential of
z
, i.e.,
the derivative of
y
with respect to
z
is equal to
y
.
b(x)
,
g(x, y, t)
and
the ODE solver are chosen so that the
Float
operation sequence does not depend on the value of
x
.
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
.
size_t m
It is either zero or one and
specifies the order of the derivative of
f(x)
,
with respect to
x
,
that is being evaluated.
m = 1
,
the following extended system is solved:
\[
\begin{array}{rcl}
y(x, 0) & = & b(x)
\\
\partial_t y ( x , t ) & = & g[ x , y(x,t) , t ]
\\
y_x (x, 0) & = & b^{(1)} (x)
\\
partial_t y_x (x, t) & = & \partial_x g[ x , y(x,t) , t ]
+ \partial_y g[ x , y(x,t) , t ] y_x
\end{array}
\]
CppAD::vector<Float> &fm
The input value of the elements of
fm
does not matter.
m
is zero, fm has size equal to one
and
fm[0]
is the value of
y(x, 1)
.
m
is one, fm has size equal to n
and for
j = 0 , \ldots , n-1
\[
\D{y}{x[j]} (x, 1) = fm [ j ]
\]
ode_evaluate.hpp
.
It returns true if it succeeds and false otherwise.