CppADCodeGen
HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
|
Public Types | |
using | PathNode = OperationPathNode< Base > |
using | SourceCodePath = std::vector< PathNode > |
using | ScopePath = std::vector< ScopePathElement< Base > > |
using | Node = OperationNode< Base > |
using | Arg = Argument< Base > |
using | CGB = CG< Base > |
using | ScopeIDType = unsigned short |
Public Member Functions | |
void | setReuseVariableIDs (bool reuse) |
bool | isReuseVariableIDs () const |
template<class VectorCG > | |
void | makeVariables (VectorCG &variables) |
void | makeVariables (std::vector< AD< CGB > > &variables) |
void | makeVariable (AD< CGB > &variable) |
void | makeVariable (CGB &variable) |
size_t | getIndependentVariableSize () const |
size_t | getIndependentVariableIndex (const Node &var) const |
const CodeHandlerVector< Base, size_t > & | getVariablesIDs () const |
size_t | getMaximumVariableID () const |
bool | isVerbose () const |
void | setVerbose (bool verbose) |
JobTimer * | getJobTimer () const |
void | setJobTimer (JobTimer *jobTimer) |
bool | isZeroDependents () const |
void | setZeroDependents (bool zeroDependents) |
size_t | getOperationTreeVisitId () const |
void | startNewOperationTreeVisit () |
bool | isVisited (const Node &node) const |
void | markVisited (const Node &node) |
std::string | getAtomicFunctionName (size_t id) const |
const std::map< size_t, CGAbstractAtomicFun< Base > *> & | getAtomicFunctions () const |
const std::vector< int > & | getExternalFuncMaxForwardOrder () const |
const std::vector< int > & | getExternalFuncMaxReverseOrder () const |
const std::string * | getLoopName (size_t id) const |
const std::vector< ScopePath > & | getScopes () const |
std::vector< SourceCodePath > | findPaths (Node &root, Node &target, size_t max) |
BidirGraph< Base > | findPathGraph (Node &root, Node &target) |
BidirGraph< Base > | findPathGraph (Node &root, Node &target, size_t &bifurcations, size_t maxBifurcations=(std::numeric_limits< size_t >::max)()) |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, CppAD::vector< CGB > &dependent, VariableNameGenerator< Base > &nameGen, const std::string &jobName="source") |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, std::vector< CGB > &dependent, VariableNameGenerator< Base > &nameGen, const std::string &jobName="source") |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, ArrayView< CGB > &dependent, VariableNameGenerator< Base > &nameGen, const std::string &jobName="source") |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, CppAD::vector< CGB > &dependent, VariableNameGenerator< Base > &nameGen, std::vector< std::string > &atomicFunctions, const std::string &jobName="source") |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, std::vector< CGB > &dependent, VariableNameGenerator< Base > &nameGen, std::vector< std::string > &atomicFunctions, const std::string &jobName="source") |
virtual void | generateCode (std::ostream &out, Language< Base > &lang, ArrayView< CGB > &dependent, VariableNameGenerator< Base > &nameGen, std::vector< std::string > &atomicFunctions, const std::string &jobName="source") |
size_t | getTemporaryVariableCount () const |
size_t | getTemporaryArraySize () const |
size_t | getTemporarySparseArraySize () const |
virtual void | reset () |
void | resetNodes () |
Node * | cloneNode (const Node &n) |
Node * | makeNode (CGOpCode op) |
Node * | makeNode (CGOpCode op, const Arg &arg) |
Node * | makeNode (CGOpCode op, std::vector< Arg > &&args) |
Node * | makeNode (CGOpCode op, std::vector< size_t > &&info, std::vector< Arg > &&args) |
Node * | makeNode (CGOpCode op, const std::vector< size_t > &info, const std::vector< Arg > &args) |
LoopStartOperationNode< Base > * | makeLoopStartNode (Node &indexDcl, size_t iterationCount) |
LoopStartOperationNode< Base > * | makeLoopStartNode (Node &indexDcl, IndexOperationNode< Base > &iterCount) |
LoopEndOperationNode< Base > * | makeLoopEndNode (LoopStartOperationNode< Base > &loopStart, const std::vector< Arg > &endArgs) |
PrintOperationNode< Base > * | makePrintNode (const std::string &before, const Arg &arg, const std::string &after) |
IndexOperationNode< Base > * | makeIndexNode (Node &indexDcl) |
IndexOperationNode< Base > * | makeIndexNode (LoopStartOperationNode< Base > &loopStart) |
IndexOperationNode< Base > * | makeIndexNode (IndexAssignOperationNode< Base > &indexAssign) |
IndexAssignOperationNode< Base > * | makeIndexAssignNode (Node &index, IndexPattern &indexPattern, IndexOperationNode< Base > &index1) |
IndexAssignOperationNode< Base > * | makeIndexAssignNode (Node &index, IndexPattern &indexPattern, IndexOperationNode< Base > *index1, IndexOperationNode< Base > *index2) |
Node * | makeIndexDclrNode (const std::string &name) |
size_t | getManagedNodesCount () const |
const std::vector< Node * > & | getManagedNodes () const |
void | deleteManagedNodes (size_t start, size_t end) |
CGB | createCG (const Arg &arg) |
const std::map< size_t, LoopModel< Base > * > & | getLoops () const |
LoopModel< Base > * | getLoop (size_t loopId) const |
size_t | addLoopDependentIndexPattern (IndexPattern &jacPattern) |
void | manageLoopDependentIndexPattern (const IndexPattern *pattern) |
size_t | addLoopIndependentIndexPattern (IndexPattern &pattern, size_t hint) |
CGB | solveFor (Node &expression, Node &var) |
bool | isSolvable (Node &expression, Node &var) |
void | substituteIndependent (const CGB &indep, const CGB &dep, bool removeFromIndeps=true) |
void | substituteIndependent (Node &indep, Node &dep, bool removeFromIndeps=true) |
void | undoSubstituteIndependent (Node &indep) |
void | removeIndependent (Node &indep) |
bool | manageOperationNodeMemory (Node *code) |
Static Public Member Functions | |
static void | findRandomIndexPatterns (IndexPattern *ip, std::set< RandomIndexPattern *> &found) |
Protected Member Functions | |
void | findPaths (SourceCodePath &path2node, Node &code, std::vector< SourceCodePath > &found, size_t max) |
CGB | solveFor (const SourceCodePath &path) |
bool | isSolvable (const SourceCodePath &path) const |
virtual Node * | manageOperationNode (Node *code) |
void | addVector (CodeHandlerVectorSync< Base > *v) |
void | removeVector (CodeHandlerVectorSync< Base > *v) |
virtual void | markCodeBlockUsed (Node &code) |
bool | handleTemporaryVarInDiffScopes (Node &code, size_t oldScope, size_t newScope) |
void | replaceWithConditionalTempVar (Node &tmp, IndexOperationNode< Base > &iterationIndexOp, const std::vector< size_t > &iterationRegions, ScopeIDType oldScope, ScopeIDType commonScopeColor) |
void | updateTemporaryVarInDiffScopes (Node &code) |
void | restoreTemporaryVar (Node &tmp) |
void | restoreTemporaryVar (Node *tmp, Node *opClone) |
void | updateVarScopeUsage (Node *node, ScopeIDType usageScope, ScopeIDType oldUsageScope) |
void | addScopeToVarOrder (size_t scope, size_t &e) |
size_t | findFirstDifferentScope (size_t color1, size_t color2) |
void | optimizeIfs () |
void | replaceScope (Node *node, ScopeIDType oldScope, ScopeIDType newScope) |
void | breakCyclicDependency (Node *node, size_t scope, Node *endIf) |
bool | containedInScope (const Node &node, ScopeIDType scope) |
virtual void | registerAtomicFunction (CGAbstractAtomicFun< Base > &atomic) |
virtual void | checkVariableCreation (Node &code) |
void | addToEvaluationQueue (Node &arg) |
void | reduceTemporaryVariables (ArrayView< CGB > &dependent) |
void | reorderOperations (ArrayView< CGB > &dependent) |
void | reorderOperation (Node &node) |
size_t | findLastTemporaryLocation (Node &node) |
void | repositionEvaluationQueue (size_t fromPos, size_t toPos) |
void | determineLastTempVarUsage (Node &node) |
void | findVariableDependencies () |
void | findVariableDependencies (size_t i, Node &node) |
void | dependentAdded2EvaluationQueue (Node &node) |
void | updateEvaluationQueueOrder (Node &node, size_t newEvalOrder) |
bool | isIndependent (const Node &arg) const |
bool | isTemporary (const Node &arg) const |
size_t | getEvaluationOrder (const Node &node) const |
void | setEvaluationOrder (Node &node, size_t order) |
size_t | getLastUsageEvaluationOrder (const Node &node) const |
void | setLastUsageEvaluationOrder (const Node &node, size_t last) |
size_t | getTotalUsageCount (const Node &node) const |
void | setTotalUsageCount (const Node &node, size_t cout) |
void | increaseTotalUsageCount (const Node &node) |
void | resetManagedNodes () |
CGB | collectVariable (Node &expression, const SourceCodePath &path1, const SourceCodePath &path2, size_t bifPos) |
CGB | collectVariableAddSub (const SourceCodePath &pathLeft, const SourceCodePath &pathRight) |
bool | isCollectableVariableAddSub (const SourceCodePath &pathLeft, const SourceCodePath &pathRight, bool throwEx) |
Static Protected Member Functions | |
static bool | containsArgument (const Node &node, const Node &arg) |
static bool | isTemporaryArray (const Node &arg) |
static bool | isTemporarySparseArray (const Node &arg) |
static Node * | getOperationFromAlias (Node &alias) |
static std::vector< SourceCodePath > | findPathsFromNode (const std::vector< SourceCodePath > nodePaths, Node &node) |
Protected Attributes | |
size_t | _idVisit |
size_t | _idCount |
size_t | _idArrayCount |
size_t | _idSparseArrayCount |
size_t | _idAtomicCount |
std::vector< Node * > | _independentVariables |
ArrayView< CGB > * | _dependents |
std::vector< Node * > | _codeBlocks |
std::set< CodeHandlerVectorSync< Base > * > | _managedVectors |
CodeHandlerVector< Base, size_t > | _lastVisit |
CodeHandlerVector< Base, ScopeIDType > | _scope |
CodeHandlerVector< Base, size_t > | _evaluationOrder |
CodeHandlerVector< Base, size_t > | _lastUsageOrder |
CodeHandlerVector< Base, size_t > | _totalUseCount |
CodeHandlerVector< Base, size_t > | _operationCount |
CodeHandlerVector< Base, size_t > | _varId |
std::vector< Node * > | _variableOrder |
std::vector< std::set< Node * > > | _variableDependencies |
std::vector< std::vector< Node * > > | _scopedVariableOrder |
LoopData | _loops |
std::map< size_t, CGAbstractAtomicFun< Base > * > | _atomicFunctions |
std::map< std::string, size_t > | _atomicFunctionName2Index |
std::vector< std::string > * | _atomicFunctionsOrder |
std::vector< int > | _atomicFunctionsMaxForward |
std::vector< int > | _atomicFunctionsMaxReverse |
bool | _used |
bool | _reuseIDs |
ScopeIDType | _scopeColorCount |
ScopeIDType | _currentScopeColor |
std::vector< ScopePath > | _scopes |
std::list< std::pair< Node *, Node *> > | _alteredNodes |
Language< Base > * | _lang |
size_t | _minTemporaryVarID |
bool | _zeroDependents |
bool | _verbose |
JobTimer * | _jobTimer |
Node * | _auxIndexI |
IndexOperationNode< Base > * | _auxIterationIndexOp |
|
inlineprotectedinherited |
Removes cyclic dependencies when 'ifs' are merged together. Relative variable order must have already been defined.
node | the node being visited |
scope | the scope where the cyclic dependency could appear (or scopes inside it) |
endIf | the dependency to remove |
Definition at line 1370 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
protectedvirtualinherited |
Save atomic function related information
make sure new temporary variables are NOT created for the independent variables and that a dependency did not use it first
Operation that mark a change in variable scope are always added
Definition at line 1444 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Creates a shallow clone of an operation node
Definition at line 524 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::replaceWithConditionalTempVar().
|
inlineprotectedinherited |
Reduces the number of occurrences of a variable in an equation. For instance: f(x,y) = x + y + x could become f(x,y) = 2 * x + y
expression | The original expression (f(x, y)) |
path1 | A path from the equation residual to where the variable is used. |
path2 | A different path from the equation residual to where the variable is used. |
CGException | if it is not possible to combine the multiple occurrences of the variable |
Check common path
Replace the new expression
Definition at line 25 of file collect_variable.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Argument validation
Check operations after the divergence
find the coefficient which will multiply the variable
Clone operations in expression without var
add term for variable
Definition at line 100 of file collect_variable.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Allows to delete OperationNodes that are managed internally.
start | The index of the first OperationNode to be deleted |
end | The index after the last OperationNode to be deleted |
Definition at line 651 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Defines the evaluation order for the code fragments that do not create variables (right hand side variables)
code | The operation just added to the evaluation order |
Definition at line 1970 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Determines when each temporary variable is last used in the evaluation order
node | The current node for which the number of usages is to be to determined |
count variable usage
temporary variables from outside the loop which are used within the loop cannot be overwritten inside that loop
Definition at line 1873 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::reduceTemporaryVariables().
|
inlineprotectedinherited |
Determines the depth of the first different scope from scope paths of two scopes
color1 | scope color 1 |
color2 | scope color 2 |
Definition at line 1249 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::updateTemporaryVarInDiffScopes().
|
inlineprotectedinherited |
Determine the highest location in the evaluation queue of temporary variables used by an operation node in the same scope.
Definition at line 1809 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::reorderOperation().
|
inlineinherited |
Finds occurrences of a source code fragment in an operation graph.
root | the operation graph where to search |
target | the source code fragment to find in root |
max | the maximum number of occurrences of code to find in root |
Definition at line 117 of file operation_path.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::findPaths(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Determines relations between variables with an ID
Definition at line 2012 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::findVariableDependencies(), CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
virtualinherited |
Creates the source code from the operations registered so far.
out | The output stream where the source code is to be printed. |
lang | The targeted language. |
dependent | The dependent variables for which the source code should be generated. By defining this vector the number of operations in the source code can be reduced and thus providing a more optimized code. |
nameGen | Provides the rules for variable name creation. |
Definition at line 214 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseHessianSourceDirectly(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSources(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateZeroSource(), CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops().
|
virtualinherited |
Creates the source code from the operations registered so far.
out | The output stream where the source code is to be printed. |
lang | The targeted language. |
dependent | The dependent variables for which the source code should be generated. By defining this vector the number of operations in the source code can be reduced and thus providing a more optimized code. |
nameGen | Provides the rules for variable name creation. |
atomicFunctions | The order of the atomic functions. |
Definition at line 244 of file code_handler_impl.hpp.
|
virtualinherited |
the first variable IDs are for the independent variables
determine the number of times each variable is used
determine the variable creation order
Generate flat variable order (without scopes)
Reuse temporary variables
Creates the source code for a specific language
clean-up
Definition at line 266 of file code_handler_impl.hpp.
|
inlineinherited |
Provides the name used by an atomic function with a given ID.
id | the atomic function ID. |
Definition at line 178 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Provides a map with all the currently registered atomic functions.
Definition at line 188 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inherited |
Provides the maximum forward mode order used by all atomic functions in the last call to ::generateCode (-1 means forward mode not used).
Definition at line 193 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops().
|
inherited |
Provides the maximum reverse mode order used by all atomic functions in the last call to ::generateCode (-1 means forward mode not used).
Definition at line 198 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops().
|
inherited |
CGException | if a variable is not found in the independent vector |
Definition at line 141 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inherited |
The number of independent variables defined with makeVariable().
Definition at line 96 of file code_handler_impl.hpp.
Referenced by CppAD::cg::EvaluatorBase< ScalarIn, double, adouble, Evaluator< ScalarIn, double, adouble > >::evaluate(), CppAD::cg::DummyDerivatives< Base >::generateReorderedModel(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Provides the name used by a loop atomic function with a given ID.
id | the atomic function ID. |
Definition at line 203 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Provides the OperationNodes created by the model.
Definition at line 646 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Provides the current number of OperationNodes created by the model. This number is not the total number of operations in the final model since it also contains Operations nodes marking independent variables and there could be unused operations by the model (dead-code).
Definition at line 641 of file code_handler_impl.hpp.
Referenced by CppAD::cg::EvaluatorBase< ScalarIn, double, adouble, Evaluator< ScalarIn, double, adouble > >::clear(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Provides the total number of times the result of an operation node is being used as an argument for another operation.
Definition at line 2142 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Provides variable IDs that were assigned to operation nodes. Zero means that no variable is assigned. The first IDs are reserved for the independent variables. It can be an empty vector if IDs have not yet been assigned.
Definition at line 101 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
allow Array elements to use a CGTmp instead of a CGArrayCreationOp
does this variable require a condition based on indexes?
determine the iterations which use this temporary variable
Definition at line 927 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Check operations after the divergence
Definition at line 240 of file collect_variable.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Whether or not node IDs are reused once they are not need by a node anymore.
Definition at line 71 of file code_handler_impl.hpp.
|
inlineinherited |
Determines whether or not the dependent variables will be set to zero before executing the operation graph
Definition at line 131 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Marks the provided variable as being an independent variable.
variables | the variable that will become an independent variables. |
Definition at line 83 of file code_handler_impl.hpp.
Referenced by CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSources(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSourcesNoAtomics(), CppAD::cg::CodeHandler< ScalarOut >::makeVariable(), CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseForwardOneWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseTwoWithLoops().
|
inlineinherited |
Marks the provided variable as being an independent variable.
variables | the variable that will become an independent variables. |
Definition at line 90 of file code_handler_impl.hpp.
|
inlineinherited |
Marks the provided variables as being independent variables.
variables | the vector of variables that will become independent variables. |
Definition at line 207 of file code_handler.hpp.
Referenced by CppAD::cg::BipartiteGraph< Base >::generateNewModel(), CppAD::cg::DummyDerivatives< Base >::generateSemiExplicitDAE(), CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseForwardOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseHessianSourceDirectly(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseOneSourcesWithAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSources(), CppAD::cg::ModelCSourceGen< Base >::generateSparseReverseTwoSourcesNoAtomics(), CppAD::cg::ModelCSourceGen< Base >::generateZeroSource(), CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseForwardOneWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseTwoWithLoops(), CppAD::cg::DummyDerivatives< Base >::reduceEquations(), and CppAD::cg::DummyDerivatives< Base >::reorderModelEqNVars().
|
inlineinherited |
Marks the provided variables as being independent variables.
variables | the vector of variables that will become independent variables. |
Definition at line 76 of file code_handler_impl.hpp.
|
inlineinherited |
Adds an operation node to the list of nodes to be deleted when this handler is destroyed.
code | The operation node to be managed. |
Definition at line 706 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
protectedvirtualinherited |
Alias operations are always followed so that there is a correct usage count at the operation that it points to
Iterate over all arguments with operation nodes
this node was previously altered to ensure that the evaluation of the expression is only performed for the required iterations
node previously used in a different scope must make sure it is defined before being used in both scopes
does this variable require a condition based on indexes?
Must also update the scope of the arguments used by this operation
reset scope
Definition at line 738 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Attempt to reduce the number of ifs when there are consecutive ifs with the same condition
same condition -> combine the contents into a single if
Definition at line 1270 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
determine the last line where each temporary variable is used
Redefine temporary variable IDs
Definition at line 1636 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Finalizes the substitution of an independent variable by eliminating it from the list of independents. After this operation the variable substitution cannot be undone.
indep | The independent variable |
CGException | if the dependent variable is not an not an alias or it does not belong to this handler |
Definition at line 76 of file graph_mod.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
determine the location of the last temporary variable
move dependent if beneficial
Must be in same scope
Definition at line 1742 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::reorderOperations().
|
inlineprotectedinherited |
Change operation order so that the total number of temporary variables is reduced.
dependent | The vector of dependent variable values |
Definition at line 1716 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::reduceTemporaryVariables().
|
inlineprotectedinherited |
clone
Create condition
Change original variable
add the new scope
Must also update the scope of the arguments used by this operation
Definition at line 983 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
virtualinherited |
Resets this handler for a usage with completely different nodes.
Definition at line 493 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineinherited |
Resets the previously used dependents and their children so that they can be reused again by this handler.
Definition at line 510 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops().
|
inlineprotectedinherited |
Must also update the scope of the arguments used by this operation
Definition at line 1151 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::updateTemporaryVarInDiffScopes().
|
inlineprotectedinherited |
Must also update the scope of the arguments used by this operation
Definition at line 1174 of file code_handler_impl.hpp.
|
inlineinherited |
Defines whether or not to reuse the node IDs once they are not need by a node anymore.
Definition at line 66 of file code_handler_impl.hpp.
|
inlineinherited |
Defines whether or not the dependent variables should be set to zero before executing the operation graph
true | if the dependents should be zeroed |
Definition at line 136 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseForwardOneWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseHessianWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseJacobianWithLoops(), CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseTwoWithLoops().
|
inlineinherited |
Solves an expression (e.g. f(x, y) == 0) for a given variable (e.g. x).
expression | The original expression (f(x, y)) |
var | The variable to solve for |
CGException | if it is not possible to solve the expression |
Definition at line 25 of file solver.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
Solves an expression (e.g. f(x, y) == 0) for a given variable (e.g. x) The variable can appear only once in the expression. This is also known as isolation.
path | The path from the equation residual to the variable |
CGException | if it is not possible to solve the expression |
Definition at line 83 of file solver.hpp.
|
inlineinherited |
Eliminates an independent variable by substitution using the provided dependent variable which is assumed to be a residual of an equation. If successful the model will contain one less independent variable.
indep | The independent variable to eliminate. |
dep | The dependent variable representing a residual |
removeFromIndeps | Whether or not to immediately remove the independent variable from the list of independents in the model. The substitution operation can only be reversed if the variable is not removed. |
CGException | if the dependent variable does not belong to this handler |
Definition at line 22 of file graph_mod.hpp.
Referenced by CppAD::cg::DummyDerivatives< Base >::assignVar2Equation(), CppAD::cg::DummyDerivatives< Base >::generateSemiExplicitDAE(), CppAD::cg::CodeHandler< ScalarOut >::makeVariables(), and CppAD::cg::CodeHandler< ScalarOut >::substituteIndependent().
|
inlineinherited |
Reverts a substitution of an independent variable that has not been removed from the list of independents yet. Warning: it does not recover any custom name assigned to the variable.
indep | The independent variable |
CGException | if the dependent variable does not belong to this handler |
Definition at line 65 of file graph_mod.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
inlineprotectedinherited |
does this variable require a condition based on indexes?
Determine if it should be moved into a different scope so that it is defined before being used in both scopes
does this variable require a condition based on indexes?
determine the iterations which use this temporary variable
Must also update the scope of the arguments used by this operation
Definition at line 1068 of file code_handler_impl.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::makeVariables().
|
protectedinherited |
already used atomic function names (may contain names which were used by previous calls to this/other CondeHandlers)
Definition at line 124 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode().
|
protectedinherited |
maps the IDs of the atomic functions
Definition at line 119 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getAtomicFunctionName(), and CppAD::cg::CodeHandler< ScalarOut >::getAtomicFunctions().
|
protectedinherited |
the maximum forward mode order each atomic function is called (-1 means forward mode not used)
Definition at line 134 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::getExternalFuncMaxForwardOrder().
|
protectedinherited |
the maximum reverse mode order each atomic function is called (-1 means reverse mode not used)
Definition at line 139 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::getExternalFuncMaxReverseOrder().
|
protectedinherited |
the order of the atomic functions (may contain names which were used by previous calls to this/other CondeHandlers)
Definition at line 129 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode().
|
protectedinherited |
Auxiliary index declaration (might not be used)
Definition at line 170 of file code_handler.hpp.
|
protectedinherited |
Auxiliary index (might not be used)
Definition at line 174 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode().
|
protectedinherited |
nodes managed by this code handler which include all all OperationNodes created by CG<Base> objects
Definition at line 60 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::deleteManagedNodes(), CppAD::cg::CodeHandler< ScalarOut >::getManagedNodes(), CppAD::cg::CodeHandler< ScalarOut >::getManagedNodesCount(), CppAD::cg::CodeHandler< ScalarOut >::manageOperationNodeMemory(), and CppAD::cg::CodeHandler< ScalarOut >::reset().
|
protectedinherited |
evaluation order of each managed node (zero means that an evaluation position was never assigned)
Definition at line 77 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), and CppAD::cg::CodeHandler< ScalarOut >::resetNodes().
|
protectedinherited |
used to track evaluation times and print out messages
Definition at line 166 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), and CppAD::cg::CodeHandler< ScalarOut >::getVariablesIDs().
|
protectedinherited |
the last index in the evaluation order for which an operation node is taken as an argument of another operation node. (zero means that the node was never used)
Definition at line 83 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), and CppAD::cg::CodeHandler< ScalarOut >::resetNodes().
|
protectedinherited |
the ID of the last visit to each managed node
Definition at line 68 of file code_handler.hpp.
|
protectedinherited |
All CodeHandlerVector associated with this code handler
Definition at line 64 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::deleteManagedNodes(), CppAD::cg::CodeHandler< ScalarOut >::manageOperationNodeMemory(), and CppAD::cg::CodeHandler< ScalarOut >::~CodeHandler().
|
protectedinherited |
The number of operations used in the expression that directly assign the value to a (temporary/dependent) variable. Operations used to compute other temporary variables are not considered.
Definition at line 93 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), and CppAD::cg::CodeHandler< ScalarOut >::resetNodes().
|
protectedinherited |
scope of each managed operation node
Definition at line 72 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), CppAD::cg::CodeHandler< ScalarOut >::resetNodes(), and CppAD::cg::CodeHandler< ScalarOut >::updateTemporaryVarInDiffScopes().
|
protectedinherited |
the order for the variable creation in the source code (each level represents a different variable scope)
Definition at line 111 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), and CppAD::cg::CodeHandler< ScalarOut >::optimizeIfs().
|
protectedinherited |
the total number of times the result of an operation node is used
Definition at line 87 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), and CppAD::cg::CodeHandler< ScalarOut >::resetNodes().
|
protectedinherited |
maps dependencies between variables in _variableOrder
Definition at line 106 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::findVariableDependencies(), and CppAD::cg::CodeHandler< ScalarOut >::generateCode().
|
protectedinherited |
the order for the variable creation in the source code
Definition at line 102 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::findVariableDependencies(), CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), CppAD::cg::CodeHandler< ScalarOut >::reduceTemporaryVariables(), and CppAD::cg::CodeHandler< ScalarOut >::reorderOperation().
|
protectedinherited |
Provides the variable ID that was altered/assigned to operation nodes. Zero means that no variable is assigned.
Definition at line 98 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::findVariableDependencies(), CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::getTotalUsageCount(), CppAD::cg::CodeHandler< ScalarOut >::getVariablesIDs(), CppAD::cg::CodeHandler< ScalarOut >::reduceTemporaryVariables(), and CppAD::cg::CodeHandler< ScalarOut >::resetNodes().
|
protectedinherited |
whether or not the dependent variables should be zeroed before executing the operation graph
Definition at line 160 of file code_handler.hpp.
Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::CodeHandler< ScalarOut >::isZeroDependents(), and CppAD::cg::CodeHandler< ScalarOut >::setZeroDependents().