from_graph

View page source

ADFun Object Corresponding to a CppAD Graph

Syntax

      cpp_graph graph_obj
      ADFun < Base > fun
      fun . from_graph ( graph_obj )
      fun . from_graph ( graph_obj , dyn2var , var2dyn )

Prototype

template <class Base, class RecBase>
void CppAD::ADFun<Base,RecBase>::from_graph(
   const CppAD::cpp_graph& graph_obj     )
template <class Base, class RecBase>
void CppAD::ADFun<Base,RecBase>::from_graph(
      const CppAD::cpp_graph& graph_obj     ,
      const CppAD::vector<bool>& dyn2var    ,
      const CppAD::vector<bool>& var2dyn    )

Base

is the type corresponding to this ADFun object; i.e., its calculations are done using the type Base .

RecBase

in the prototype above, RecBase is the same type as Base .

graph_obj

is a cpp_ad_graph representation of this function.

dyn2var

is a vector with size equal to the number of independent dynamic parameters in the graph; i.e., the size of p . It specifies which independent dynamic parameters in the graph are independent variables in the function fun .

var2dyn

is a vector with size equal to the number of independent variables in the graph; i.e., the size of x . It specifies which independent variables in the graph are independent dynamic parameters in the function fun .

fun

It dyn2var and var2dyn are not present, the independent dynamic parameters and independent variables in fun are the same as for the graph. Otherwise, they are described below.

m_true, m_false

Let m_true ( m_false ) be the number of true (false) elements of dyn2var .

n_true, n_false

Let n_true ( n_false ) be the number of true (false) elements of var2dyn .

Independent Dynamic Parameters

The first m_false independent dynamic parameters in fun correspond to the false components of dyn2var and have the same order as in the graph. The next n_true independent dynamic parameters in fun correspond to the true components of var2dyn and have the same order as in the graph.

Independent Variables

The first m_true independent variables in fun correspond to the true components of dyn2var and have the same order as in the graph. The next n_false independent variables in fun correspond to the false components of var2dyn and have the same order as in the graph.

Examples

The file switch_var_dyn.cpp contains an example and test of this routine. For simpler examples, that do not change the dynamic parameters and variables; see graph_op_enum examples .