![]() |
Prev | Next |
jac = f.SparseJacobian(x)
jac = f.SparseJacobian(x, p)
F : B^n \rightarrow B^m
do denote the
AD function
corresponding to
f
.
The syntax above sets
jac
to the Jacobian
\[
jac = F^{(1)} (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 Jacobian
.
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 Jacobian.
p
is optional and has prototype
const
BoolVector &
p
(see BoolVector
below)
and its size is
m * n
.
It specifies a
sparsity pattern
for the Jacobian; i.e.,
for
i = 0 , \ldots , m-1
and
j = 0 , \ldots , n-1
.
\[
\D{ F_i }{ x_j } \neq 0 ; \Rightarrow \; p [ i * n + j ] = {\rm true}
\]
If this sparsity pattern does not change between calls to
SparseJacobian
, it should be faster to calculate
p
once and
pass this argument to
SparseJacobian
.
jac
has prototype
BaseVector jac
and its size is
m * n
.
For
i = 0 , \ldots , m - 1
,
and
j = 0 , \ldots , n - 1
\[
jac [ i * n + j ] = \D{ F_i }{ x_j }
\]
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 SparseJacobian
,
the previous calls to Forward
are undefined.
sparse_jacobian
.
It return true
, if it succeeds and false
otherwise.