Prev | Next |
f.subgraph_sparsity(
select_domain, select_range, transpose, pattern_out
)
f
.
f
operation sequence
are not efficient. To be specific, each atomic function is treated as if
all of its outputs depend on all of its inputs.
This may be improved upon in the future; see the
subgraph sparsity
wish list item.
BoolVector
is a SimpleVector
class with
elements of type
bool
.
SizeVector
is a SimpleVector
class with
elements of type
size_t
.
f
has prototype
ADFun<Base> f
select_domain
has prototype
const BoolVector& select_domain
It has size @(@
n
@)@ and specifies which independent variables
to include in the calculation.
If not all the independent variables are included in the calculation,
a forward pass on the operation sequence is used to determine which
nodes may be in the subgraphs.
select_range
has prototype
const BoolVector& select_range
It has size @(@
m
@)@ and specifies which components of the range
to include in the calculation.
A subgraph is built for each dependent variable
and the selected set of independent variables.
bool transpose
If
transpose
it is false (true),
upon return
pattern_out
is a sparsity pattern for
@(@
J(x)
@)@ (@(@
J(x)^\R{T}
@)@) defined below.
sparse_rc<SizeVector>& pattern_out
This input value of
pattern_out
does not matter.
Upon return
pattern_out
is a
dependency pattern
for @(@
F(x)
@)@.
The pattern has @(@
m
@)@ rows, @(@
n
@)@ columns.
If
select_domain[j]
is true,
select_range[i]
is true, and
@(@
F_i (x)
@)@ depends on @(@
x_j
@)@,
then the pair @(@
(i, j)
@)@ is in
pattern_out
.
Not that this is also a sparsity pattern for the Jacobian
@[@
J(x) = R F^{(1)} (x) D
@]@
where @(@
D
@)@ (@(@
R
@)@) is the diagonal matrix corresponding
to
select_domain
(
select_range
).