![]() |
Prev | Next |
# include <cppad/speed/sparse_evaluate.hpp>
sparse_evaluate(x, i, j, m, fm)
f(x)
,
f^{(1)} (x)
, or
f^{(2)} (x)
where the Hessian
f^{(2)} (x)
is sparse.
The function
f : \R^n \rightarrow \R
depends on the
index vectors
i
and
j
.
The only non-zero entries in the Hessian of this function have the form
\[
\DD{f}{x[k]]}{x[j[k]}
\]
for some \( k \) between zero and \( \ell-1 \).
sparse_evaluate
is defined in the CppAD
namespace by including
the file cppad/speed/sparse_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
.
x
has prototype
const CppAD::vector<Float> &x
It contains he argument value for which the function,
or its derivative, is being evaluated.
We use
n
to denote the size of the vector
x
.
i
has prototype
const CppAD::vector<size_t> &i
It specifies one of the first
index of
x
for each non-zero Hessian term
(see purpose
above).
All the elements of
i
must be between zero and
n-1
.
We use
\ell
to denote the size of the vector
i
.
j
has prototype
const CppAD::vector<size_t> &j
and is a vector with size
\ell
.
It specifies one of the second
index of
x
for each non-zero Hessian term.
All the elements of
j
must be between zero and
n-1
.
size_t m
It is between zero and two and
specifies the order of the derivative of
f
that is being evaluated, i.e.,
f^{(m)} (x)
is evaluated.
CppAD::vector<Float> &fm
The input value of the elements of
fm
does not matter.
m
is zero, fm has size one and
fm[0]
is the value of
f(x)
.
m
is one, fm has size n and
for
j = 0 , \ldots , n-1
\[
\D{f}{x[j]} = fm [ j ]
\]
m
is two, fm has size
n *
n and
for
k = 0 , \ldots , n-1
,
m = 0 , \ldots , n-1
\[
\DD{f}{x[k]}{x[m]} = fm [ k * n + m ]
\]
sparse_evaluate.hpp
.
It returns true if it succeeds and false otherwise.