CppADCodeGen  2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > Class Template Reference
Inheritance diagram for CppAD::cg::Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > >:
Inheritance graph
Collaboration diagram for CppAD::cg::Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > >:
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, CG< ScalarOut >, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >
 

Public Member Functions

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

Protected Types

using Super = EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >
 
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)
 
CG< ScalarOut > evalOperation (OperationNode< ScalarIn > &node)
 
CG< ScalarOut > evalAssign (const NodeIn &node)
 
CG< ScalarOut > evalAbs (const NodeIn &node)
 
CG< ScalarOut > evalAcos (const NodeIn &node)
 
CG< ScalarOut > evalAdd (const NodeIn &node)
 
CG< ScalarOut > evalAlias (const NodeIn &node)
 
CG< ScalarOut > evalAsin (const NodeIn &node)
 
CG< ScalarOut > evalAtan (const NodeIn &node)
 
CG< ScalarOut > evalCompareLt (const NodeIn &node)
 
CG< ScalarOut > evalCompareLe (const NodeIn &node)
 
CG< ScalarOut > evalCompareEq (const NodeIn &node)
 
CG< ScalarOut > evalCompareGe (const NodeIn &node)
 
CG< ScalarOut > evalCompareGt (const NodeIn &node)
 
CG< ScalarOut > evalCompareNe (const NodeIn &node)
 
CG< ScalarOut > evalCosh (const NodeIn &node)
 
CG< ScalarOut > evalCos (const NodeIn &node)
 
CG< ScalarOut > evalDiv (const NodeIn &node)
 
CG< ScalarOut > evalExp (const NodeIn &node)
 
CG< ScalarOut > evalIndependent (const NodeIn &node)
 
CG< ScalarOut > evalLog (const NodeIn &node)
 
CG< ScalarOut > evalMul (const NodeIn &node)
 
CG< ScalarOut > evalPow (const NodeIn &node)
 
CG< ScalarOut > evalSign (const NodeIn &node)
 
CG< ScalarOut > evalSinh (const NodeIn &node)
 
CG< ScalarOut > evalSin (const NodeIn &node)
 
CG< ScalarOut > evalSqrt (const NodeIn &node)
 
CG< ScalarOut > evalSub (const NodeIn &node)
 
CG< ScalarOut > evalTanh (const NodeIn &node)
 
CG< ScalarOut > evalTan (const NodeIn &node)
 
CG< ScalarOut > evalMinus (const NodeIn &node)
 
CG< ScalarOut > evalUnsupportedOperation (const NodeIn &node)
 
void prepareNewEvaluation ()
 
CG< ScalarOut > evalCG (const CG< ScalarIn > &dep)
 
CG< ScalarOut > evalArg (const std::vector< Argument< ScalarIn > > &args, size_t pos)
 
CG< ScalarOut > evalArg (const Argument< ScalarIn > &arg, size_t pos)
 
const CG< ScalarOut > & evalOperations (OperationNode< ScalarIn > &node)
 
CG< ScalarOut > * saveEvaluation (const OperationNode< ScalarIn > &node, CG< ScalarOut > &&result)
 
std::vector< CG< ScalarOut > > & evalArrayCreationOperation (const OperationNode< ScalarIn > &node)
 
std::vector< CG< ScalarOut > > & 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 CG< ScalarOut > * indep_
 
CodeHandlerVector< ScalarIn, std::unique_ptr< CG< ScalarOut > > > evals_
 
std::map< size_t, std::vector< CG< ScalarOut > > * > evalsArrays_
 
std::map< size_t, std::vector< CG< ScalarOut > > * > evalsSparseArrays_
 
bool underEval_
 
size_t depth_
 
SourceCodePath path_
 

Detailed Description

template<class ScalarIn, class ScalarOut>
class CppAD::cg::Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > >

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

Definition at line 372 of file evaluator_cg.hpp.

Member Function Documentation

◆ analyzeOutIndeps()

void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::analyzeOutIndeps ( const ActiveOut indep,
size_t  n 
)
inlineprotectedinherited
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()

void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::clear ( )
inlineprotectedinherited
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()

ActiveOut CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::evalArrayElement ( const NodeIn node)
inlineprotectedinherited
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()

void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::evalAtomicOperation ( const NodeIn node)
inlineprotectedinherited
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()

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

◆ evalPrint()

ActiveOut CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::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 127 of file evaluator_cg.hpp.

◆ evaluate() [1/3]

std::vector<CG< ScalarOut > > CppAD::cg::EvaluatorBase< ScalarIn, ScalarOut, CG< ScalarOut > , Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::evaluate ( ArrayView< const CG< 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, CG< ScalarOut > , Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::evaluate ( ArrayView< const CG< ScalarOut > >  indepNew,
ArrayView< CG< 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, CG< ScalarOut > , Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::evaluate ( const CG< ScalarOut > *  indepNew,
size_t  indepSize,
CG< 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.

◆ isPrintOutPrintOperations()

bool CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::isPrintOutPrintOperations ( ) const
inlineinherited

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

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

Definition at line 78 of file evaluator.hpp.

◆ processActiveOut()

void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::processActiveOut ( const NodeIn node,
ActiveOut a 
)
inlineprotectedinherited
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()

void CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::setPrintOutPrintOperations ( bool  print)
inlineinherited

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_

std::map<const NodeIn*, std::vector<ScalarOut*> > CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::atomicEvalResults_
protectedinherited

Cache for the evaluation of atomic operations

Definition at line 51 of file evaluator_cg.hpp.

◆ outHandler_

CodeHandler<ScalarOut>* CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::outHandler_
protectedinherited

The source code handler used to create the evaluation results

Definition at line 47 of file evaluator_cg.hpp.

◆ printOutPriOperations_

bool CppAD::cg::EvaluatorCG< ScalarIn, ScalarOut, Evaluator< ScalarIn, ScalarOut, CG< ScalarOut > > >::printOutPriOperations_
protectedinherited

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.


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