![]() |
Prev | Next |
h =
f.RevSparseHes(
q,
s)
F : B^n \rightarrow B^m
to denote the
AD function
corresponding to f.
For a fixed
n \times q
matrix
R
and a fixed
1 \times m
matrix
S
,
the second partial of
S * F[ x + R * u ]
with respect to
u
at
u = 0
and with respect to x
\[
H(x) = R^T * (S * F)^{(2)} ( x )
\]
where
(S * F)^{(2)} (x)
is the Hessian of the scalar
valued function
S * F (x)
.
Given a
sparsity pattern
for
R
and
S
,
RevSparseHes
returns a sparsity pattern for the
H(x)
.
const ADFun<
Base>
f
x \in B^n
.
If f.use_VecAD
is true,
the sparsity patter is only valid for the value of x
in the previous zero order forward mode
call
f.Forward(0,
x)
If there is no previous zero order forward mode call using f,
the value of the independent
variables
during the recording of the AD sequence of operations is used
for x.
size_t
q
It specifies the number of columns in the Jacobian
J(x)
.
It must be the same value as in the previous ForSparseJac
call
f.ForSparseJac(
q,
r)
Note that the memory required for the calculation is proportional
to
q
times the total number of variables
in the AD operation sequence corresponding to f
(f.size_var
).
f.ForSparseJac(
q,
r)
is a sparsity pattern for the matrix
R
above; i.e.,
for
i = 0 , \ldots , n-1
and
j = 0 , \ldots , q-1
.
\[
R_{i,j} \neq 0 ; \Rightarrow \; r [ i * q + j ] = {\rm true}
\]
const
Vector &
s
(see Vector
below)
and its size is
m
.
It specifies a
sparsity pattern
for the matrix S as follows:
for
j = 0 , \ldots , m-1
.
\[
S_{0,j} \neq 0 ; \Rightarrow \; s [ j ] = {\rm true}
\]
Vector &
h
(see Vector
below)
and its size is
q * n
,
It specifies a
sparsity pattern
for the matrix
H(x)
as follows:
for
x \in B^n
,
for
i = 0 , \ldots , q-1
,
and
j = 0 , \ldots , n-1
\[
H(x)_{i,j} \neq 0 ; \Rightarrow \; h [ i * n + j ] = {\rm true}
\]
q = n
and
R
is the
n \times n
identity matrix,
If follows that
\[
r [ i * q + j ] = \left\{ \begin{array}{ll}
{\rm true} & {\rm if} \; i = j \\
{\rm false} & {\rm otherwise}
\end{array} \right.
\]
is an efficient sparsity pattern for
R
;
i.e., the choice for r has as few true values as possible.
Further suppose that the
S
is the k-th
elementary vector
If follows that
\[
s [ j ] = \left\{ \begin{array}{ll}
{\rm true} & {\rm if} \; j = k \\
{\rm false} & {\rm otherwise}
\end{array} \right.
\]
is an efficient sparsity pattern for
S
.
In the case defined above,
the result h corresponds to a
sparsity pattern for the Hessian
F_k^{(2)} (x)
.