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

Public Types

using Base = EvaluatorOperations< ScalarIn, ScalarOut, ActiveOut, Evaluator< ScalarIn, ScalarOut, ActiveOut > >
 
using NodeIn = OperationNode< ScalarIn >
 
using ArgIn = Argument< ScalarIn >
 

Public Member Functions

 Evaluator (CodeHandler< ScalarIn > &handler)
 
bool isUnderEvaluation ()
 
std::vector< ActiveOut > evaluate (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 SourceCodePath = typename CodeHandler< ScalarIn >::SourceCodePath
 

Protected Member Functions

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

Protected Attributes

CodeHandler< ScalarIn > & handler_
 
const ActiveOut * indep_
 
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 ActiveOut = CppAD::AD<ScalarOut>>
class CppAD::cg::Evaluator< ScalarIn, ScalarOut, ActiveOut >

An evaluator allows to reprocess operations defined in an operation graph for a different set of independent variables and (possibly) data types.

Definition at line 694 of file evaluator.hpp.

Member Function Documentation

◆ clear()

template<class ScalarIn , class ScalarOut , class ActiveOut , class FinalEvaluatorType >
void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::clear ( )
inlineprotectedinherited

◆ evalOperation()

CppAD::AD< ScalarOut > CppAD::cg::EvaluatorOperations< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > , Evaluator< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > > >::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.

◆ evaluate() [1/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() [2/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::CodeHandler< Base >::collectVariable(), CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::evaluate(), CppAD::cg::BipartiteGraph< Base >::generateNewModel(), and CppAD::cg::DummyDerivatives< Base >::generateReorderedModel().

◆ 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.

◆ 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.


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