![]() |
Prev | Next |
hes = f.SparseHessian(x, w)
hes = f.SparseHessian(x, w, p)
F : B^n \rightarrow B^m
do denote the
AD function
corresponding to
f
.
The syntax above sets
hes
to the Hessian
\[
hes = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x)
\]
This is a preliminary implementation of a method for using the fact
that the matrix is sparse to reduce the amount of computation necessary.
One should use speed tests to verify that results are computed faster
than when using the routine Hessian
.
f
has prototype
ADFun<Base> f
Note that the ADFun
object
f
is not const
(see Uses Forward
below).
x
has prototype
const BaseVector &x
(see BaseVector
below)
and its size
must be equal to
n
, the dimension of the
domain
space for
f
.
It specifies
that point at which to evaluate the Hessian.
w
has prototype
const BaseVector &w
and size
m
.
It specifies the value of
w_i
in the expression
for
hes
.
The more components of
w
that are identically zero,
the more spares the resulting Hessian may be (and hence the more efficient
the calculation of
hes
may be).
p
is optional and has prototype
const
BoolVector &
p
(see BoolVector
below)
and its size is
n * n
.
It specifies a
sparsity pattern
for the Hessian; i.e.,
for
j = 0 , \ldots , n-1
and
k = 0 , \ldots , n-1
.
\[
\sum_i w_i \DD{ F_i }{ x_j }{ x_k } \neq 0
; \Rightarrow \; p [ j * n + k ] = {\rm true}
\]
If this sparsity pattern does not change between calls to
SparseHessian
, it should be faster to calculate
p
once and
pass this argument to
SparseHessian
.
hes
has prototype
BaseVector hes
and its size is
n * n
.
For
j = 0 , \ldots , n - 1
and
\ell = 0 , \ldots , n - 1
\[
hes [ j * n + \ell ] = \DD{ w^{\rm T} F }{ x_j }{ x_\ell } ( x )
\]
BaseVector
must be a SimpleVector
class with
elements of type
Base
.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
BoolVector
must be a SimpleVector
class with
elements of type bool
.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
In order to save memory,
you may want to use a class that packs multiple elements into one
storage location; for example,
vectorBool
.
f
contains the corresponding
Taylor coefficients
.
After SparseHessian
,
the previous calls to Forward
are undefined.
sparse_hessian
.
It return true
, if it succeeds and false
otherwise.