Prev Next

Sparse Hessian: Easy Driver

Syntax
h = f.SparseHessian(xw)

Purpose
We use  F : B^n \rightarrow B^m do denote the AD function corresponding to f. The syntax above sets h to the Hessian  \[
     h = \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
The object f has prototype
     ADFun<
Basef
Note that the ADFun object f is not const (see Uses Forward below).

x
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.

w
The argument w has prototype
     const 
Vector &w
and size  m . It specifies the value of  w_i in the expression for h. 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 h may be).

h
The result h has prototype
     
Vector h
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 )
\] 


Vector
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.

Uses Forward
After each call to Forward , the object f contains the corresponding Taylor coefficients . After SparseHessian, the previous calls to Forward are undefined.

Example
The routines Hessian.cpp and HesLagrangian.cpp are examples and tests of Hessian. They return true, if they succeed and false otherwise.
Input File: cppad/local/sparse_hessian.hpp