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

Public Member Functions

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

void prepareNewEvaluation ()
 
void clear ()
 
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 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, class FinalEvaluatorType>
class CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >

A base class for evaluators. Evaluators allow to reprocess operations defined in an operation graph for a different set of independent variables and (possibly) data types.

Operation implementations (sin(), cos(), ...) should be implemented in a subclass of type FinalEvaluatorType. This allows static polymorphism through curiously recurring template pattern (CRTP). Therefore the default behaviour can be overridden without the use of virtual methods.

This class should not be instantiated directly.

Todo:
implement nonrecursive algorithm (so that there will never be any stack limit issues)

Definition at line 27 of file evaluator.hpp.

Constructor & Destructor Documentation

◆ EvaluatorBase()

template<class ScalarIn, class ScalarOut, class ActiveOut, class FinalEvaluatorType>
CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >::EvaluatorBase ( CodeHandler< ScalarIn > &  handler)
inline
Parameters
handlerThe original source code handler

Definition at line 63 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 ( )
inlineprotected

◆ 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 
)
inline

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

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

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 ( )
inline
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 file: