CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::EvaluatorCloneSolve< Scalar > Class Template Reference
Inheritance diagram for CppAD::cg::EvaluatorCloneSolve< Scalar >:
Inheritance graph
Collaboration diagram for CppAD::cg::EvaluatorCloneSolve< Scalar >:
Collaboration graph

Public Types

using ActiveOut = CG< Scalar >
 
using SourceCodePath = typename CodeHandler< Scalar >::SourceCodePath
 
using ActiveIn = CG< Scalar >
 
using NodeIn = OperationNode< Scalar >
 
using NodeOut = OperationNode< Scalar >
 
using ArgIn = Argument< Scalar >
 
using ArgOut = Argument< Scalar >
 
using Base = EvaluatorBase< Scalar, Scalar, CG< Scalar >, EvaluatorCloneSolve< Scalar > >
 

Public Member Functions

 EvaluatorCloneSolve (CodeHandler< Scalar > &handler, const std::vector< const SourceCodePath *> &paths, const std::vector< const std::vector< CG< Scalar > *> *> &replaceOnPath)
 
 EvaluatorCloneSolve (CodeHandler< Scalar > &handler, const BidirGraph< Scalar > &pathGraph, const std::map< const PathNodeEdges< Scalar > *, CG< Scalar > > &replaceOnGraph)
 
 EvaluatorCloneSolve (CodeHandler< Scalar > &handler, const std::set< const OperationNode< Scalar > *> &clone, const std::map< const OperationPathNode< Scalar >, CG< Scalar >> &replaceArgument)
 
void setPrintOutPrintOperations (bool print)
 
bool isPrintOutPrintOperations () const
 
bool isUnderEvaluation ()
 
std::vector< CG< Scalar > > evaluate (ArrayView< const CG< Scalar > > indepNew, ArrayView< const CG< Scalar > > depOld)
 
void evaluate (ArrayView< const CG< Scalar > > indepNew, ArrayView< CG< Scalar > > depNew, ArrayView< const CG< Scalar > > depOld)
 
void evaluate (const CG< Scalar > *indepNew, size_t indepSize, CG< Scalar > *depNew, const CG< Scalar > *depOld, size_t depSize)
 

Protected Types

using Super = EvaluatorCG< Scalar, Scalar, FinalEvaluatorType >
 

Protected Member Functions

ActiveOut evalOperation (OperationNode< Scalar > &node)
 
void analyzeOutIndeps (const ActiveOut *indep, size_t n)
 
void clear ()
 
void processActiveOut (const NodeIn &node, ActiveOut &a)
 
ActiveOut evalPrint (const NodeIn &node)
 
void evalAtomicOperation (const NodeIn &node)
 
ActiveOut evalArrayElement (const NodeIn &node)
 
ActiveOut makeArray (const NodeIn &node)
 
ActiveOut makeArray (const NodeIn &node, std::vector< Scalar > &values, bool &valuesDefined, bool &allParameters)
 
ActiveOut makeDenseArray (const NodeIn &node)
 
ActiveOut makeSparseArray (const NodeIn &node)
 
CG< Scalar > evalAssign (const NodeIn &node)
 
CG< Scalar > evalAbs (const NodeIn &node)
 
CG< Scalar > evalAcos (const NodeIn &node)
 
CG< Scalar > evalAdd (const NodeIn &node)
 
CG< Scalar > evalAlias (const NodeIn &node)
 
CG< Scalar > evalAsin (const NodeIn &node)
 
CG< Scalar > evalAtan (const NodeIn &node)
 
CG< Scalar > evalCompareLt (const NodeIn &node)
 
CG< Scalar > evalCompareLe (const NodeIn &node)
 
CG< Scalar > evalCompareEq (const NodeIn &node)
 
CG< Scalar > evalCompareGe (const NodeIn &node)
 
CG< Scalar > evalCompareGt (const NodeIn &node)
 
CG< Scalar > evalCompareNe (const NodeIn &node)
 
CG< Scalar > evalCosh (const NodeIn &node)
 
CG< Scalar > evalCos (const NodeIn &node)
 
CG< Scalar > evalDiv (const NodeIn &node)
 
CG< Scalar > evalExp (const NodeIn &node)
 
CG< Scalar > evalIndependent (const NodeIn &node)
 
CG< Scalar > evalLog (const NodeIn &node)
 
CG< Scalar > evalMul (const NodeIn &node)
 
CG< Scalar > evalPow (const NodeIn &node)
 
CG< Scalar > evalSign (const NodeIn &node)
 
CG< Scalar > evalSinh (const NodeIn &node)
 
CG< Scalar > evalSin (const NodeIn &node)
 
CG< Scalar > evalSqrt (const NodeIn &node)
 
CG< Scalar > evalSub (const NodeIn &node)
 
CG< Scalar > evalTanh (const NodeIn &node)
 
CG< Scalar > evalTan (const NodeIn &node)
 
CG< Scalar > evalMinus (const NodeIn &node)
 
CG< Scalar > evalUnsupportedOperation (const NodeIn &node)
 
void prepareNewEvaluation ()
 
CG< Scalar > evalCG (const CG< Scalar > &dep)
 
CG< Scalar > evalArg (const std::vector< Argument< Scalar > > &args, size_t pos)
 
CG< Scalar > evalArg (const Argument< Scalar > &arg, size_t pos)
 
const CG< Scalar > & evalOperations (OperationNode< Scalar > &node)
 
CG< Scalar > * saveEvaluation (const OperationNode< Scalar > &node, CG< Scalar > &&result)
 
std::vector< CG< Scalar > > & evalArrayCreationOperation (const OperationNode< Scalar > &node)
 
std::vector< CG< Scalar > > & evalSparseArrayCreationOperation (const OperationNode< Scalar > &node)
 

Static Protected Member Functions

static void processArray (const std::vector< ActiveOut > &array, std::vector< Scalar > &values, bool &valuesDefined, bool &allParameters)
 
static bool isParameters (const CppAD::vector< ActiveOut > &tx)
 
static bool isValuesDefined (const std::vector< ArgOut > &tx)
 

Protected Attributes

CodeHandler< Scalar > * outHandler_
 
std::map< const NodeIn *, std::vector< Scalar *> > atomicEvalResults_
 
bool printOutPriOperations_
 
CodeHandler< Scalar > & handler_
 
const CG< Scalar > * indep_
 
CodeHandlerVector< Scalar, std::unique_ptr< CG< Scalar > > > evals_
 
std::map< size_t, std::vector< CG< Scalar > > * > evalsArrays_
 
std::map< size_t, std::vector< CG< Scalar > > * > evalsSparseArrays_
 
bool underEval_
 
size_t depth_
 
SourceCodePath path_
 

Detailed Description

template<class Scalar>
class CppAD::cg::EvaluatorCloneSolve< Scalar >

Specialization of EvaluatorCG which can replace some operations. It only clones some of the nodes. It is used by the symbolic solver.

Definition at line 27 of file evaluator_solve.hpp.

Constructor & Destructor Documentation

◆ EvaluatorCloneSolve() [1/3]

template<class Scalar>
CppAD::cg::EvaluatorCloneSolve< Scalar >::EvaluatorCloneSolve ( CodeHandler< Scalar > &  handler,
const std::vector< const SourceCodePath *> &  paths,
const std::vector< const std::vector< CG< Scalar > *> *> &  replaceOnPath 
)
inline

Creates a new evaluator.

Parameters
handler
pathsoperation nodes in a path which should be cloned (there shouldn't be multiple usages of these nodes)
replaceOnPathreplacements for the operations along the paths (a null means that the original should be cloned)

Definition at line 78 of file evaluator_solve.hpp.

◆ EvaluatorCloneSolve() [2/3]

template<class Scalar>
CppAD::cg::EvaluatorCloneSolve< Scalar >::EvaluatorCloneSolve ( CodeHandler< Scalar > &  handler,
const BidirGraph< Scalar > &  pathGraph,
const std::map< const PathNodeEdges< Scalar > *, CG< Scalar > > &  replaceOnGraph 
)
inline

Creates a new evaluator.

Parameters
handler
pathGraphthe operation paths which should be cloned
replaceOnGraphreplacements for the operations along the graph

Definition at line 103 of file evaluator_solve.hpp.

◆ EvaluatorCloneSolve() [3/3]

template<class Scalar>
CppAD::cg::EvaluatorCloneSolve< Scalar >::EvaluatorCloneSolve ( CodeHandler< Scalar > &  handler,
const std::set< const OperationNode< Scalar > *> &  clone,
const std::map< const OperationPathNode< Scalar >, CG< Scalar >> &  replaceArgument 
)
inline

Creates a new evaluator.

Parameters
handler
cloneoperations which should be cloned
replaceArgumentreplacements for the operations along the paths

Definition at line 122 of file evaluator_solve.hpp.

Member Function Documentation

◆ analyzeOutIndeps()

void CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::analyzeOutIndeps ( const ActiveOut indep,
size_t  n 
)
inlineprotectedinherited
Note
overrides the default analyzeOutIndeps() even though this method is not virtual (hides a method in EvaluatorBase)

Definition at line 88 of file evaluator_cg.hpp.

◆ clear()

void CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::clear ( )
inlineprotectedinherited
Note
overrides the default clear() even though this method is not virtual (hides a method in EvaluatorBase)

Definition at line 98 of file evaluator_cg.hpp.

◆ evalArrayElement()

ActiveOut CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::evalArrayElement ( const NodeIn node)
inlineprotectedinherited
Note
overrides the default evalArrayElement() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 229 of file evaluator_cg.hpp.

◆ evalAtomicOperation()

void CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::evalAtomicOperation ( const NodeIn node)
inlineprotectedinherited
Note
overrides the default evalAtomicOperation() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 152 of file evaluator_cg.hpp.

◆ evalOperation()

template<class Scalar>
ActiveOut CppAD::cg::EvaluatorCloneSolve< Scalar >::evalOperation ( OperationNode< Scalar > &  node)
inlineprotected
Note
overrides the default evalOperation() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 140 of file evaluator_solve.hpp.

◆ evalPrint()

ActiveOut CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::evalPrint ( const NodeIn node)
inlineprotectedinherited
Note
overrides the default evalPrint() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 127 of file evaluator_cg.hpp.

◆ evaluate() [1/3]

std::vector<CG< Scalar > > CppAD::cg::EvaluatorBase< Scalar , Scalar , CG< Scalar > , EvaluatorCloneSolve< Scalar > >::evaluate ( ArrayView< const CG< Scalar > >  indepNew,
ArrayView< const CG< Scalar > >  depOld 
)
inlineinherited

Performs all the operations required to calculate the dependent variables with a (potentially) new data type

Parameters
indepNewThe new independent variables.
depOldDependent variable vector representing the operations that are going to be executed to determine the new variables (all variables must belong to the same code handler)
Returns
The dependent variable values
Exceptions
CGExceptionon error (such as an unhandled operation type)

Definition at line 93 of file evaluator.hpp.

Referenced by CppAD::cg::CodeHandler< ScalarOut >::collectVariable().

◆ evaluate() [2/3]

void CppAD::cg::EvaluatorBase< Scalar , Scalar , CG< Scalar > , EvaluatorCloneSolve< Scalar > >::evaluate ( ArrayView< const CG< Scalar > >  indepNew,
ArrayView< CG< Scalar > >  depNew,
ArrayView< const CG< Scalar > >  depOld 
)
inlineinherited

Performs all the operations required to calculate the dependent variables with a (potentially) new data type

Parameters
indepNewThe new independent variables.
depNewThe new dependent variable vector to be computed.
depOldDependent variable vector representing the operations that are going to be executed to determine the new variables (all variables must belong to the same code handler)
Exceptions
CGExceptionon error (such as an different sizes of depNew and depOld or an unhandled operation type)

Definition at line 114 of file evaluator.hpp.

◆ evaluate() [3/3]

void CppAD::cg::EvaluatorBase< Scalar , Scalar , CG< Scalar > , EvaluatorCloneSolve< Scalar > >::evaluate ( const CG< Scalar > *  indepNew,
size_t  indepSize,
CG< Scalar > *  depNew,
const CG< Scalar > *  depOld,
size_t  depSize 
)
inlineinherited

Performs all the operations required to calculate the dependent variables with a (potentially) new data type

Parameters
indepNewThe new independent variables.
indepSizeThe size of the array of independent variables.
depNewThe new dependent variable vector that will be created.
depOldDependent variable vector representing the operations that are going to be executed to determine the new variables (all variables must belong to the same code handler)
depSizeThe size of the array of dependent variables.
Exceptions
CGExceptionon error (such as an unhandled operation type)

Definition at line 137 of file evaluator.hpp.

◆ isPrintOutPrintOperations()

bool CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::isPrintOutPrintOperations ( ) const
inlineinherited

Whether or not the nodes with an operation type 'Pri' are printed out during the evaluation.

Definition at line 78 of file evaluator_cg.hpp.

◆ isUnderEvaluation()

bool CppAD::cg::EvaluatorBase< Scalar , Scalar , CG< Scalar > , EvaluatorCloneSolve< Scalar > >::isUnderEvaluation ( )
inlineinherited
Returns
true if this Evaluator is currently being used.

Definition at line 78 of file evaluator.hpp.

◆ processActiveOut()

void CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::processActiveOut ( const NodeIn node,
ActiveOut a 
)
inlineprotectedinherited
Note
overrides the default processActiveOut() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 114 of file evaluator_cg.hpp.

◆ setPrintOutPrintOperations()

void CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::setPrintOutPrintOperations ( bool  print)
inlineinherited

Defines whether or not to print out the nodes with an operation type 'Pri' during the evaluation.

Definition at line 70 of file evaluator_cg.hpp.

Member Data Documentation

◆ atomicEvalResults_

std::map<const NodeIn*, std::vector<Scalar *> > CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::atomicEvalResults_
protectedinherited

Cache for the evaluation of atomic operations

Definition at line 51 of file evaluator_cg.hpp.

◆ outHandler_

CodeHandler<Scalar >* CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::outHandler_
protectedinherited

The source code handler used to create the evaluation results

Definition at line 47 of file evaluator_cg.hpp.

◆ printOutPriOperations_

bool CppAD::cg::EvaluatorCG< Scalar , Scalar , EvaluatorCloneSolve< Scalar > >::printOutPriOperations_
protectedinherited

Whether or not the nodes with an operation type 'Pri' are printed out during the evaluation.

Definition at line 56 of file evaluator_cg.hpp.


The documentation for this class was generated from the following file: