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}} }@)@

*hes* = *f*.Hessian(*x*, *w*)

*hes* = *f*.Hessian(*x*, *l*)

We use @(@ F : B^n \rightarrow B^m @)@ to denote the AD function corresponding to

*f*

.
The syntax above sets
*hes*

to the Hessian
The syntax above sets
*h*

to the Hessian
@[@
hes = \dpow{2}{x} \sum_{i=1}^m w_i F_i (x)
@]@
The routine sparse_hessian
may be faster in the case
where the Hessian is sparse.
The object

*f*

has prototype

ADFun<*Base*> *f*

Note that the ADFun
object
*f*

is not `const`

(see Hessian Uses Forward
below).
The argument

*x*

has prototype

const *Vector* &*x*

(see Vector
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.
If the argument

*l*

is present, it has prototype

size_t *l*

and is less than
*m*

, the dimension of the
range
space for
*f*

.
It specifies the component of
*F*

for which we are evaluating the Hessian.
To be specific, in the case where the argument
*l*

is present,
@[@
w_i = \left\{ \begin{array}{ll}
1 & i = l \\
0 & {\rm otherwise}
\end{array} \right.
@]@
If the argument

*w*

is present, it has prototype

const *Vector* &*w*

and size @(@
m
@)@.
It specifies the value of @(@
w_i
@)@ in the expression
for
*h*

.
The result

*hes*

has prototype

*Vector* *hes*

(see Vector
below)
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 )
@]@
The type

*Vector*

must be a SimpleVector
class with
elements of type
*Base*

.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
After each call to Forward , the object

*f*

contains the corresponding
Taylor coefficients
.
After a call to `Hessian`

,
the zero order Taylor coefficients correspond to
*f*.Forward(0, *x*)

and the other coefficients are unspecified.
The routines hessian.cpp and hes_lagrangian.cpp are examples and tests of

`Hessian`

.
They return `true`

, if they succeed and `false`

otherwise.
Input File: cppad/core/hessian.hpp