Hessian Sparsity Pattern: Reverse Mode
Keywords: hessian sparsity pattern: reverse mode syntax purpose f x q transpose r s h false true vectorset entire pattern example

| Prev | Next |  |  |  |  |  |  |

Hessian Sparsity Pattern: Reverse Mode
Syntax
`h = f.RevSparseHes(q, s)
` `h = f.RevSparseHes(q, s, transpose)`
Purpose
We use F : R n → R m to denote the AD function corresponding to `f` . For a fixed matrix R ∈ R n × q and a fixed vector S ∈ R 1 × m , we define H ( x ) = ∂ x [∂ u S * F [ x + R * u ] ] u = 0 = R T * ( S * F ) ( 2 ) ( x ) H ( x ) T = ( S * F ) ( 2 ) ( x ) * R Given a sparsity pattern for the matrix R and the vector S , `RevSparseHes` returns a sparsity pattern for the H ( x ) .
f
The object `f` has prototype `
const ADFun<Base> f
`
x
the sparsity pattern is valid for all values of the independent variables in x ∈ R n (even if it has CondExp or VecAD operations).
q
The argument `q` has prototype `
size_t q
` It specifies the number of columns in R ∈ R n × q and the number of rows in H ( x ) ∈ R q × n . It must be the same value as in the previous ForSparseJac call `
f.ForSparseJac(q, r, r_transpose)
` Note that if `r_transpose` is true, `r` in the call above corresponding to R T ∈ R q × n
transpose
The argument `transpose` has prototype `
bool transpose
` The default value `false` is used when `transpose` is not present.
r
The matrix R is specified by the previous call `
f.ForSparseJac(q, r, transpose)
` see r . The type of the elements of VectorSet must be the same as the type of the elements of `r` .
s
The argument `s` has prototype `
const VectorSet& s
` (see VectorSet below) If it has elements of type `bool`, its size is m . If it has elements of type `std::set<size_t>`, its size is one and all the elements of `s[0]` are between zero and m - 1 . It specifies a sparsity pattern for the vector `S` .
h
The result `h` has prototype `
VectorSet& h
` (see VectorSet below).
transpose false
If `h` has elements of type `bool`, its size is q * n . If it has elements of type `std::set<size_t>`, its size is q and all the set elements are between zero and `n-1` inclusive. It specifies a sparsity pattern for the matrix H ( x ) .
transpose true
If `h` has elements of type `bool`, its size is n * q . If it has elements of type `std::set<size_t>`, its size is n and all the set elements are between zero and `q-1` inclusive. It specifies a sparsity pattern for the matrix H ( x ) T .
VectorSet
The type `VectorSet` must be a SimpleVector class with elements of type `bool` or `std::set<size_t>`; see sparsity pattern for a discussion of the difference. The type of the elements of VectorSet must be the same as the type of the elements of `r` .
Entire Sparsity Pattern
Suppose that q = n and R ∈ R n × n is the n × n identity matrix. Further suppose that the S is the `k`-th elementary vector ; i.e. S j = { 1 if j = k 0 otherwise In this case, the corresponding value `h` is a sparsity pattern for the Hessian matrix F k ( 2 ) ( x ) ∈ R n × n .
Example
The file rev_sparse_hes.cpp contains an example and test of this operation. It returns true if it succeeds and false otherwise. The file sparsity_sub.cpp contains an example and test of using `RevSparseHes` to compute the sparsity pattern for a subset of the Hessian.

Input File: cppad/local/rev_sparse_hes.hpp