CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType > Class Template Reference
Inheritance diagram for CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >:
Inheritance graph
Collaboration diagram for CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >:
Collaboration graph

Public Types

using ActiveIn = CG< ScalarIn >
 
using ActiveOut = CG< ScalarOut >
 
using NodeIn = OperationNode< ScalarIn >
 
using NodeOut = OperationNode< ScalarOut >
 
using ArgIn = Argument< ScalarIn >
 
using ArgOut = Argument< ScalarOut >
 
using Base = EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >
 

Public Member Functions

 EvaluatorCG (CodeHandler< ScalarIn > &handler)
 
void setPrintOutPrintOperations (bool print)
 
bool isPrintOutPrintOperations () const
 
bool isUnderEvaluation ()
 
std::vector< ActiveOutevaluate (ArrayView< const ActiveOut > indepNew, ArrayView< const CG< ScalarIn > > depOld)
 
void evaluate (ArrayView< const ActiveOut > indepNew, ArrayView< ActiveOut > depNew, ArrayView< const CG< ScalarIn > > depOld)
 
void evaluate (const ActiveOut *indepNew, size_t indepSize, ActiveOut *depNew, const CG< ScalarIn > *depOld, size_t depSize)
 

Protected Types

using Super = EvaluatorOperations< ScalarIn, ScalarOut, CG< ScalarOut >, FinalEvaluatorType >
 
using SourceCodePath = typename CodeHandler< ScalarIn >::SourceCodePath
 

Protected Member Functions

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< ScalarOut > &values, bool &valuesDefined, bool &allParameters)
 
ActiveOut makeDenseArray (const NodeIn &node)
 
ActiveOut makeSparseArray (const NodeIn &node)
 
ActiveOut evalOperation (OperationNode< ScalarIn > &node)
 
ActiveOut evalAssign (const NodeIn &node)
 
ActiveOut evalAbs (const NodeIn &node)
 
ActiveOut evalAcos (const NodeIn &node)
 
ActiveOut evalAdd (const NodeIn &node)
 
ActiveOut evalAlias (const NodeIn &node)
 
ActiveOut evalAsin (const NodeIn &node)
 
ActiveOut evalAtan (const NodeIn &node)
 
ActiveOut evalCompareLt (const NodeIn &node)
 
ActiveOut evalCompareLe (const NodeIn &node)
 
ActiveOut evalCompareEq (const NodeIn &node)
 
ActiveOut evalCompareGe (const NodeIn &node)
 
ActiveOut evalCompareGt (const NodeIn &node)
 
ActiveOut evalCompareNe (const NodeIn &node)
 
ActiveOut evalCosh (const NodeIn &node)
 
ActiveOut evalCos (const NodeIn &node)
 
ActiveOut evalDiv (const NodeIn &node)
 
ActiveOut evalExp (const NodeIn &node)
 
ActiveOut evalIndependent (const NodeIn &node)
 
ActiveOut evalLog (const NodeIn &node)
 
ActiveOut evalMul (const NodeIn &node)
 
ActiveOut evalPow (const NodeIn &node)
 
ActiveOut evalSign (const NodeIn &node)
 
ActiveOut evalSinh (const NodeIn &node)
 
ActiveOut evalSin (const NodeIn &node)
 
ActiveOut evalSqrt (const NodeIn &node)
 
ActiveOut evalSub (const NodeIn &node)
 
ActiveOut evalTanh (const NodeIn &node)
 
ActiveOut evalTan (const NodeIn &node)
 
ActiveOut evalMinus (const NodeIn &node)
 
ActiveOut evalUnsupportedOperation (const NodeIn &node)
 
void processActiveOut (const NodeIn &node, ActiveOut &a)
 
void prepareNewEvaluation ()
 
void analyzeOutIndeps (const ActiveOut *indep, size_t n)
 
ActiveOut evalCG (const CG< ScalarIn > &dep)
 
ActiveOut evalArg (const std::vector< Argument< ScalarIn > > &args, size_t pos)
 
ActiveOut evalArg (const Argument< ScalarIn > &arg, size_t pos)
 
const ActiveOutevalOperations (OperationNode< ScalarIn > &node)
 
ActiveOutsaveEvaluation (const OperationNode< ScalarIn > &node, ActiveOut &&result)
 
std::vector< ActiveOut > & evalArrayCreationOperation (const OperationNode< ScalarIn > &node)
 
std::vector< ActiveOut > & evalSparseArrayCreationOperation (const OperationNode< ScalarIn > &node)
 

Static Protected Member Functions

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

Protected Attributes

CodeHandler< ScalarOut > * outHandler_
 
std::map< const NodeIn *, std::vector< ScalarOut * > > atomicEvalResults_
 
bool printOutPriOperations_
 
CodeHandler< ScalarIn > & handler_
 
const ActiveOutindep_
 
CodeHandlerVector< ScalarIn, std::unique_ptr< ActiveOut > > evals_
 
std::map< size_t, std::vector< ActiveOut > *> evalsArrays_
 
std::map< size_t, std::vector< ActiveOut > *> evalsSparseArrays_
 
bool underEval_
 
size_t depth_
 
SourceCodePath path_
 

Detailed Description

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
class CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >

Specialization of class Evaluator for an output active type of CG<Base>. This class should not be instantiated directly.

Definition at line 27 of file evaluator_cg.hpp.

Member Function Documentation

◆ analyzeOutIndeps()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::analyzeOutIndeps ( const ActiveOut indep,
size_t  n 
)
inlineprotected
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()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::clear ( )
inlineprotected
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()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
ActiveOut CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::evalArrayElement ( const NodeIn node)
inlineprotected
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()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::evalAtomicOperation ( const NodeIn node)
inlineprotected
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 ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
ActiveOut CppAD::cg::EvaluatorOperations< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::evalOperation ( OperationNode< ScalarIn > &  node)
inlineprotectedinherited

Clones a node with the new type. Override this method to add a custom node generation behaviour which does not follow the original operation graph.

Parameters
nodethe original node
Returns
the clone of the original node

Definition at line 374 of file evaluator.hpp.

Referenced by CppAD::cg::EvaluatorCloneSolve< Scalar >::evalOperation().

◆ evalPrint()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
ActiveOut CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::evalPrint ( const NodeIn node)
inlineprotected
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]

template<class ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
std::vector<ActiveOut> CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::evaluate ( ArrayView< const ActiveOut >  indepNew,
ArrayView< const CG< ScalarIn > >  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::EvaluatorBase< ScalarIn, double, adouble, Evaluator< ScalarIn, double, adouble > >::evaluate().

◆ evaluate() [2/3]

template<class ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::evaluate ( ArrayView< const ActiveOut >  indepNew,
ArrayView< ActiveOut >  depNew,
ArrayView< const CG< ScalarIn > >  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]

template<class ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::evaluate ( const ActiveOut *  indepNew,
size_t  indepSize,
ActiveOut *  depNew,
const CG< ScalarIn > *  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()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
bool CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::isPrintOutPrintOperations ( ) const
inline

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()

template<class ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
bool CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::isUnderEvaluation ( )
inlineinherited
Returns
true if this Evaluator is currently being used.

Definition at line 78 of file evaluator.hpp.

◆ processActiveOut()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::processActiveOut ( const NodeIn node,
ActiveOut a 
)
inlineprotected
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()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::setPrintOutPrintOperations ( bool  print)
inline

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_

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
std::map<const NodeIn*, std::vector<ScalarOut*> > CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::atomicEvalResults_
protected

Cache for the evaluation of atomic operations

Definition at line 51 of file evaluator_cg.hpp.

◆ outHandler_

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
CodeHandler<ScalarOut>* CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::outHandler_
protected

The source code handler used to create the evaluation results

Definition at line 47 of file evaluator_cg.hpp.

◆ printOutPriOperations_

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
bool CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, FinalEvaluatorType >::printOutPriOperations_
protected

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.

Referenced by CppAD::cg::EvaluatorCG< Scalar, Scalar, EvaluatorCloneSolve< Scalar > >::isPrintOutPrintOperations().


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