1 # ifndef CPPAD_LOCAL_SUBGRAPH_SPARSITY_HPP
2 # define CPPAD_LOCAL_SUBGRAPH_SPARSITY_HPP
20 namespace CppAD {
namespace local {
namespace subgraph {
82 template <
typename Base,
typename BoolVector>
87 const BoolVector& select_domain ,
88 const BoolVector& select_range ,
97 size_t(select_domain.size()) == sub_info.
n_ind()
100 size_t(select_range.size()) == sub_info.
n_dep()
104 size_t n_dep = dep_taddr.
size();
126 sub_info.
init_rev(play, select_domain);
142 for(
size_t i_dep = 0; i_dep < n_dep; ++i_dep)
if( select_range[i_dep] )
147 play, dep_taddr,
addr_t(i_dep), subgraph
150 for(
size_t k = 0; k < subgraph.size(); k++)
151 {
size_t i_op = subgraph[k];
165 size_t i_ind = i_var - 1;
void resize(size_t n)
resize the vector (existing elements preserved when n <= capacity_).
void push_back(const Type &e)
Add an element to theh back of this vector.
subgraph information attached to a operation sequence
CPPAD_TAPE_ADDR_TYPE addr_t
const pod_vector< addr_t > & map_user_op(void) const
map user atomic function calls to first operator in the call
include entire function call in a subgraph
Class used to store and play back an operation sequence recording.
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
File used to define pod_vector class.
void set_map_user_op(const player< Base > *play)
set the value of map_user_op for this operation sequence
void get_rev(const player< Base > *play, const vector< size_t > &dep_taddr, addr_t i_dep, pod_vector< addr_t > &subgraph)
Get the subgraph corresponding to a dependent variables (and a selected set of independent variables)...
void init_rev(const player< Base > *play, const BoolVector &select_domain)
Initialize in_subgraph corresponding to a single dependent variable (and a selected set of independen...
size_t size(void) const
number of elements currently in this vector.
OpCode
Type used to distinguish different AD< Base > atomic operations.
size_t n_dep(void) const
number of dependent variables
size_t size(void) const
current number of elements in this vector.
Determine arguments that are variables.
pod_vector< addr_t > & in_subgraph(void)
flag which operators that are in the subgraph
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
size_t num_op_rec(void) const
Fetch number of operators in the recording.
#define CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res)
Check that operator op has the specified number of of arguments and results.
size_t n_ind(void) const
number of independent variables
void subgraph_sparsity(const player< Base > *play, subgraph_info &sub_info, const vector< size_t > &dep_taddr, const BoolVector &select_domain, const BoolVector &select_range, pod_vector< size_t > &row_out, pod_vector< size_t > &col_out)
Compute dependency sparsity pattern for an ADFun<Base> function.
size_t var2op(size_t var_index) const
fetch the operator corresponding to a primary variable
OpCode GetOp(size_t i) const
fetch an operator from the recording.
class for maintaining subgraph information attached to on ADFun object.
bool check_map_user_op(const player< Base > *play) const
check that the value of map_user_op is OK for this operation sequence