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

Public Types

using ActiveOut = CppAD::AD< ScalarOut >
 
using NodeIn = OperationNode< ScalarIn >
 
using ArgIn = Argument< ScalarIn >
 
using Super = EvaluatorOperations< ScalarIn, ScalarOut, CppAD::AD< ScalarOut >, FinalEvaluatorType >
 
using Base = EvaluatorBase< ScalarIn, ScalarOut, CppAD::AD< ScalarOut >, FinalEvaluatorType >
 

Public Member Functions

 EvaluatorAD (CodeHandler< ScalarIn > &handler)
 
void setPrintOutPrintOperations (bool print)
 
bool isPrintOutPrintOperations () const
 
virtual bool addAtomicFunction (size_t id, atomic_base< ScalarOut > &atomic)
 
virtual void addAtomicFunctions (const std::map< size_t, atomic_base< ScalarOut > * > &atomics)
 
size_t getNumberOfEvaluatedAtomics () const
 
bool isUnderEvaluation ()
 
std::vector< CppAD::AD< ScalarOut > > evaluate (ArrayView< const CppAD::AD< ScalarOut > > indepNew, ArrayView< const CG< ScalarIn > > depOld)
 
void evaluate (ArrayView< const CppAD::AD< ScalarOut > > indepNew, ArrayView< CppAD::AD< ScalarOut > > depNew, ArrayView< const CG< ScalarIn > > depOld)
 
void evaluate (const CppAD::AD< ScalarOut > *indepNew, size_t indepSize, CppAD::AD< ScalarOut > *depNew, const CG< ScalarIn > *depOld, size_t depSize)
 

Protected Types

using SourceCodePath = typename CodeHandler< ScalarIn >::SourceCodePath
 

Protected Member Functions

void prepareNewEvaluation ()
 
void evalAtomicOperation (NodeIn &node)
 
ActiveOut evalPrint (const NodeIn &node)
 
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 > 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)
 
void clear ()
 
void analyzeOutIndeps (const CppAD::AD< ScalarOut > *indep, size_t n)
 
CppAD::AD< ScalarOut > evalCG (const CG< ScalarIn > &dep)
 
CppAD::AD< ScalarOut > evalArg (const std::vector< Argument< ScalarIn > > &args, size_t pos)
 
CppAD::AD< ScalarOut > evalArg (const Argument< ScalarIn > &arg, size_t pos)
 
const CppAD::AD< ScalarOut > & evalOperations (OperationNode< ScalarIn > &node)
 
CppAD::AD< ScalarOut > * saveEvaluation (const OperationNode< ScalarIn > &node, CppAD::AD< ScalarOut > &&result)
 
std::vector< CppAD::AD< ScalarOut > > & evalArrayCreationOperation (const OperationNode< ScalarIn > &node)
 
std::vector< CppAD::AD< ScalarOut > > & evalSparseArrayCreationOperation (const OperationNode< ScalarIn > &node)
 

Protected Attributes

std::set< NodeIn * > evalsAtomic_
 
std::map< size_t, CppAD::atomic_base< ScalarOut > *> atomicFunctions_
 
bool printOutPriOperations_
 
CodeHandler< ScalarIn > & handler_
 
const CppAD::AD< ScalarOut > * indep_
 
CodeHandlerVector< ScalarIn, std::unique_ptr< CppAD::AD< ScalarOut > > > evals_
 
std::map< size_t, std::vector< CppAD::AD< ScalarOut > > * > evalsArrays_
 
std::map< size_t, std::vector< CppAD::AD< ScalarOut > > * > evalsSparseArrays_
 
bool underEval_
 
size_t depth_
 
SourceCodePath path_
 

Detailed Description

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

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

Definition at line 27 of file evaluator_ad.hpp.

Member Function Documentation

◆ addAtomicFunction()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
virtual bool CppAD::cg::EvaluatorAD< ScalarIn, ScalarOut, FinalEvaluatorType >::addAtomicFunction ( size_t  id,
atomic_base< ScalarOut > &  atomic 
)
inlinevirtual

Provides an atomic function.

Parameters
idThe atomic function ID
atomicThe atomic function
Returns
True if an atomic function with the same ID was already defined, false otherwise.

Definition at line 83 of file evaluator_ad.hpp.

◆ clear()

void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > , FinalEvaluatorType >::clear ( )
inlineprotectedinherited

clean-up

Definition at line 197 of file evaluator.hpp.

◆ evalAtomicOperation()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorAD< ScalarIn, ScalarOut, FinalEvaluatorType >::evalAtomicOperation ( NodeIn node)
inlineprotected
Exceptions
CGExceptionon an internal evaluation error
Note
overrides the default evalAtomicOperation() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 131 of file evaluator_ad.hpp.

◆ evalOperation()

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

◆ evalPrint()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
ActiveOut CppAD::cg::EvaluatorAD< 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 181 of file evaluator_ad.hpp.

◆ evaluate() [1/3]

std::vector<CppAD::AD< ScalarOut > > CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > , FinalEvaluatorType >::evaluate ( ArrayView< const CppAD::AD< ScalarOut > >  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.

◆ evaluate() [2/3]

void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > , FinalEvaluatorType >::evaluate ( ArrayView< const CppAD::AD< ScalarOut > >  indepNew,
ArrayView< CppAD::AD< ScalarOut > >  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]

void CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > , FinalEvaluatorType >::evaluate ( const CppAD::AD< ScalarOut > *  indepNew,
size_t  indepSize,
CppAD::AD< ScalarOut > *  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.

◆ getNumberOfEvaluatedAtomics()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
size_t CppAD::cg::EvaluatorAD< ScalarIn, ScalarOut, FinalEvaluatorType >::getNumberOfEvaluatedAtomics ( ) const
inline

Provides the number of atomic function evaluations. The same function can be considered more than once.

Returns
the number of atomic functions evaluations.

Definition at line 104 of file evaluator_ad.hpp.

◆ isPrintOutPrintOperations()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
bool CppAD::cg::EvaluatorAD< 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 71 of file evaluator_ad.hpp.

◆ isUnderEvaluation()

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

Definition at line 78 of file evaluator.hpp.

◆ prepareNewEvaluation()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorAD< ScalarIn, ScalarOut, FinalEvaluatorType >::prepareNewEvaluation ( )
inlineprotected
Note
overrides the default prepareNewEvaluation() even though this method is not virtual (hides a method in EvaluatorBase)

Do not place this in clear() so that it is possible to determine the number of atomic function evaluations after the evaluation has ended.

Definition at line 114 of file evaluator_ad.hpp.

◆ setPrintOutPrintOperations()

template<class ScalarIn, class ScalarOut, class FinalEvaluatorType>
void CppAD::cg::EvaluatorAD< 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 63 of file evaluator_ad.hpp.

Member Data Documentation

◆ printOutPriOperations_

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

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

Definition at line 49 of file evaluator_ad.hpp.

Referenced by CppAD::cg::EvaluatorAD< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CppAD::AD< ScalarOut > > >::isPrintOutPrintOperations().


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