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

Public Types

using ScalarOut = CG< BaseOut >
 
using ActiveOut = CppAD::AD< ScalarOut >
 
using Super = EvaluatorAD< ScalarIn, ScalarOut, Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >
 
using NodeIn = OperationNode< ScalarIn >
 
using ArgIn = Argument< ScalarIn >
 
using Base = EvaluatorBase< ScalarIn, ScalarOut, ActiveOut, FinalEvaluatorType >
 

Public Member Functions

 Evaluator (CodeHandler< ScalarIn > &handler)
 
void setPrintFor (bool printFor)
 
bool isPrintFor () const
 
void setPrintForPos (const ActiveOut &pos)
 
const ActiveOutgetPrintForPos () const
 
void setCopyAdCgName (bool adcgName)
 
bool isCopyAdCgName () const
 
void setPrintOutPrintOperations (bool print)
 
bool isPrintOutPrintOperations () const
 
virtual bool addAtomicFunction (size_t id, atomic_base< CG< BaseOut > > &atomic)
 
virtual void addAtomicFunctions (const std::map< size_t, atomic_base< CG< BaseOut > > * > &atomics)
 
size_t getNumberOfEvaluatedAtomics () 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 SourceCodePath = typename CodeHandler< ScalarIn >::SourceCodePath
 

Protected Member Functions

void processActiveOut (const OperationNode< ScalarIn > &node, ActiveOut &a)
 
void prepareNewEvaluation ()
 
void evalAtomicOperation (NodeIn &node)
 
void evalAtomicOperation (const NodeIn &node)
 
ActiveOut evalPrint (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 evalArrayElement (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)
 
ActiveOut evalArg (const std::vector< Argument< ScalarIn > > &args, size_t pos)
 
ActiveOut 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 clear ()
 
void analyzeOutIndeps (const ActiveOut *indep, size_t n)
 
ActiveOut evalCG (const CG< ScalarIn > &dep)
 
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)
 

Protected Attributes

bool printFor_
 
ActiveOut printForPos_
 
bool adcgName_
 
std::set< NodeIn * > evalsAtomic_
 
std::map< size_t, CppAD::atomic_base< ScalarOut > * > atomicFunctions_
 
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 BaseOut>
class CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >

Specialization of class Evaluator for an output active type of AD<CG<Base>>

Definition at line 25 of file evaluator_adcg.hpp.

Member Function Documentation

◆ addAtomicFunction()

virtual bool CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::addAtomicFunction ( size_t  id,
atomic_base< CG< BaseOut > > &  atomic 
)
inlinevirtualinherited

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

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

◆ evalAtomicOperation()

void CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::evalAtomicOperation ( NodeIn node)
inlineprotectedinherited
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()

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.

◆ evalPrint()

ActiveOut CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::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 181 of file evaluator_ad.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.

◆ getNumberOfEvaluatedAtomics()

size_t CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::getNumberOfEvaluatedAtomics ( ) const
inlineinherited

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.

◆ getPrintForPos()

template<class ScalarIn , class BaseOut >
const ActiveOut& CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::getPrintForPos ( ) const
inline

Whenever printFor_ is set to true it will add a CppAD::PrintFor(pos, "", var, name) to every variable with a name so that names can be recovered using a OperationNodeNameStreambuf. This method provides the pos value used in CppAD::PrintFor.

Definition at line 105 of file evaluator_adcg.hpp.

◆ isCopyAdCgName()

template<class ScalarIn , class BaseOut >
bool CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::isCopyAdCgName ( ) const
inline

Whenever set to true it will copy the name in original operation nodes into new operation nodes created in AD<CG>. The default value is true.

Definition at line 122 of file evaluator_adcg.hpp.

◆ isPrintFor()

template<class ScalarIn , class BaseOut >
bool CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::isPrintFor ( ) const
inline

true if a CppAD::PrintFor(pos, "", var, name) will be added to every variable with a name so that names can be recovered using a OperationNodeNameStreambuf. The default value is false.

Definition at line 83 of file evaluator_adcg.hpp.

◆ isPrintOutPrintOperations()

bool CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::isPrintOutPrintOperations ( ) const
inlineinherited

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

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.

◆ prepareNewEvaluation()

void CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::prepareNewEvaluation ( )
inlineprotectedinherited
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.

◆ processActiveOut()

template<class ScalarIn , class BaseOut >
void CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::processActiveOut ( const OperationNode< ScalarIn > &  node,
ActiveOut a 
)
inlineprotected
Note
overrides the default processActiveOut() even though this method is not virtual (hides a method in EvaluatorOperations)

Definition at line 132 of file evaluator_adcg.hpp.

◆ setCopyAdCgName()

template<class ScalarIn , class BaseOut >
void CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::setCopyAdCgName ( bool  adcgName)
inline

Whenever set to true it will copy the name in original operation nodes into new operation nodes created in AD<CG>.

Definition at line 113 of file evaluator_adcg.hpp.

◆ setPrintFor()

template<class ScalarIn , class BaseOut >
void CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::setPrintFor ( bool  printFor)
inline

Whenever set to true it will add a CppAD::PrintFor(pos, "", var, name) to every variable with a name so that names can be recovered using a OperationNodeNameStreambuf.

Definition at line 73 of file evaluator_adcg.hpp.

◆ setPrintForPos()

template<class ScalarIn , class BaseOut >
void CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::setPrintForPos ( const ActiveOut pos)
inline

Whenever printFor_ is set to true it will add a CppAD::PrintFor(pos, "", var, name) to every variable with a name so that names can be recovered using a OperationNodeNameStreambuf. This method sets the pos value used in CppAD::PrintFor.

Definition at line 94 of file evaluator_adcg.hpp.

◆ setPrintOutPrintOperations()

void CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::setPrintOutPrintOperations ( bool  print)
inlineinherited

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

◆ adcgName_

template<class ScalarIn , class BaseOut >
bool CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::adcgName_
protected

Whenever set to true it will copy the name in original operation nodes into new operation nodes created in AD<CG>.

Definition at line 55 of file evaluator_adcg.hpp.

◆ printFor_

template<class ScalarIn , class BaseOut >
bool CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::printFor_
protected

Whenever set to true it will add a CppAD::PrintFor(0, "", var, name) to every variable with a name so that names can be recovered using a OperationNodeNameStreambuf.

Definition at line 46 of file evaluator_adcg.hpp.

◆ printForPos_

template<class ScalarIn , class BaseOut >
ActiveOut CppAD::cg::Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > >::printForPos_
protected

Pos value used in CppAD::PrintFor(pos, ...)

Definition at line 50 of file evaluator_adcg.hpp.

◆ printOutPriOperations_

bool CppAD::cg::EvaluatorAD< ScalarIn, CG< BaseOut > , Evaluator< ScalarIn, CG< BaseOut >, CppAD::AD< CG< BaseOut > > > >::printOutPriOperations_
protectedinherited

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.


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