CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::VariableNameGenerator< Base > Class Template Referenceabstract
Inheritance diagram for CppAD::cg::VariableNameGenerator< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::VariableNameGenerator< Base >:
Collaboration graph

Public Member Functions

virtual const std::vector< FuncArgument > & getDependent () const
 
virtual const std::vector< FuncArgument > & getIndependent () const
 
virtual const std::vector< FuncArgument > & getTemporary () const
 
virtual size_t getMinTemporaryVariableID () const =0
 
virtual size_t getMaxTemporaryVariableID () const =0
 
virtual size_t getMaxTemporaryArrayVariableID () const =0
 
virtual size_t getMaxTemporarySparseArrayVariableID () const =0
 
virtual std::string generateDependent (size_t index)=0
 
virtual std::string generateIndependent (const OperationNode< Base > &variable, size_t id)=0
 
virtual std::string generateTemporary (const OperationNode< Base > &variable, size_t id)=0
 
virtual std::string generateTemporaryArray (const OperationNode< Base > &variable, size_t id)=0
 
virtual std::string generateTemporarySparseArray (const OperationNode< Base > &variable, size_t id)=0
 
virtual std::string generateIndexedDependent (const OperationNode< Base > &var, size_t id, const IndexPattern &ip)=0
 
virtual std::string generateIndexedIndependent (const OperationNode< Base > &var, size_t id, const IndexPattern &ip)=0
 
virtual void setTemporaryVariableID (size_t minTempID, size_t maxTempID, size_t maxTempArrayID, size_t maxTempSparseArrayID)=0
 
virtual const std::string & getIndependentArrayName (const OperationNode< Base > &indep, size_t id)=0
 
virtual size_t getIndependentArrayIndex (const OperationNode< Base > &indep, size_t id)=0
 
virtual bool isConsecutiveInIndepArray (const OperationNode< Base > &indepFirst, size_t idFirst, const OperationNode< Base > &indepSecond, size_t idSecond)=0
 
virtual bool isInSameIndependentArray (const OperationNode< Base > &indep1, size_t id1, const OperationNode< Base > &indep2, size_t id2)=0
 
virtual const std::string & getTemporaryVarArrayName (const OperationNode< Base > &var, size_t id)=0
 
virtual size_t getTemporaryVarArrayIndex (const OperationNode< Base > &var, size_t id)=0
 
virtual bool isConsecutiveInTemporaryVarArray (const OperationNode< Base > &varFirst, size_t idFirst, const OperationNode< Base > &varSecond, size_t idSecond)=0
 
virtual bool isInSameTemporaryVarArray (const OperationNode< Base > &var1, size_t id1, const OperationNode< Base > &var2, size_t id2)=0
 
virtual void customFunctionVariableDeclarations (std::ostream &out)
 
virtual void prepareCustomFunctionVariables (std::ostream &out)
 
virtual void finalizeCustomFunctionVariables (std::ostream &out)
 

Protected Attributes

std::vector< FuncArgument_dependent
 
std::vector< FuncArgument_independent
 
std::vector< FuncArgument_temporary
 

Detailed Description

template<class Base>
class CppAD::cg::VariableNameGenerator< Base >

Creates variables names for the source code.

Author
Joao Leal

Definition at line 129 of file declare_cg.hpp.

Member Function Documentation

◆ generateDependent()

◆ generateIndependent()

◆ generateIndexedDependent()

template<class Base>
virtual std::string CppAD::cg::VariableNameGenerator< Base >::generateIndexedDependent ( const OperationNode< Base > &  var,
size_t  id,
const IndexPattern ip 
)
pure virtual

Creates a name for a reference to an indexed dependent variable expression.

Parameters
varthe node representing an indexed dependent variable
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
ipthe index pattern
Returns
the generated name

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::generateIndexedDependent(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::generateIndexedDependent().

◆ generateIndexedIndependent()

template<class Base>
virtual std::string CppAD::cg::VariableNameGenerator< Base >::generateIndexedIndependent ( const OperationNode< Base > &  var,
size_t  id,
const IndexPattern ip 
)
pure virtual

Creates a name for a reference to an indexed independent variable expression.

Parameters
varthe node representing an indexed independent variable
idan ID assigned by the CodeHandler to the operation node (unique for indexed independent variables)
ipthe index pattern
Returns
the generated name

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::generateIndexedIndependent(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::generateIndexedIndependent().

◆ generateTemporary()

template<class Base>
virtual std::string CppAD::cg::VariableNameGenerator< Base >::generateTemporary ( const OperationNode< Base > &  variable,
size_t  id 
)
pure virtual

◆ generateTemporaryArray()

template<class Base>
virtual std::string CppAD::cg::VariableNameGenerator< Base >::generateTemporaryArray ( const OperationNode< Base > &  variable,
size_t  id 
)
pure virtual

◆ generateTemporarySparseArray()

template<class Base>
virtual std::string CppAD::cg::VariableNameGenerator< Base >::generateTemporarySparseArray ( const OperationNode< Base > &  variable,
size_t  id 
)
pure virtual

◆ getDependent()

template<class Base>
virtual const std::vector<FuncArgument>& CppAD::cg::VariableNameGenerator< Base >::getDependent ( ) const
inlinevirtual

◆ getIndependent()

template<class Base>
virtual const std::vector<FuncArgument>& CppAD::cg::VariableNameGenerator< Base >::getIndependent ( ) const
inlinevirtual

Provides the independent variable arguments used by a function.

Returns
the independent variable arguments

Definition at line 65 of file variable_name_generator.hpp.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::isInSameTemporaryVarArray(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::setTemporaryVariableID().

◆ getIndependentArrayIndex()

template<class Base>
virtual size_t CppAD::cg::VariableNameGenerator< Base >::getIndependentArrayIndex ( const OperationNode< Base > &  indep,
size_t  id 
)
pure virtual

Provides the index in the associated independent array of an independent variable. It should only be called if independents are saved in an array.

Parameters
indepthe independent variable node (CGInvOp)
idan ID assigned by the CodeHandler to the operation node (unique for independent variable arrays)
Returns
the index

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::getIndependentArrayIndex(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getIndependentArrayIndex().

◆ getIndependentArrayName()

template<class Base>
virtual const std::string& CppAD::cg::VariableNameGenerator< Base >::getIndependentArrayName ( const OperationNode< Base > &  indep,
size_t  id 
)
pure virtual

Provides the array name where independent variables are provided to the function. It should only be called if independents are saved in an array.

Parameters
indepthe independent variable node (CGInvOp)
idan ID assigned by the CodeHandler to the operation node (unique for independent variable arrays)
Returns
the array name

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::getIndependentArrayName(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getIndependentArrayName().

◆ getMaxTemporaryArrayVariableID()

◆ getMaxTemporarySparseArrayVariableID()

◆ getMaxTemporaryVariableID()

◆ getMinTemporaryVariableID()

◆ getTemporary()

template<class Base>
virtual const std::vector<FuncArgument>& CppAD::cg::VariableNameGenerator< Base >::getTemporary ( ) const
inlinevirtual

◆ getTemporaryVarArrayIndex()

template<class Base>
virtual size_t CppAD::cg::VariableNameGenerator< Base >::getTemporaryVarArrayIndex ( const OperationNode< Base > &  var,
size_t  id 
)
pure virtual

Provides the index in the associated temporary array of a temporary variable. It should only be called if temporary variables are saved in an array.

Parameters
varthe temporary variable node
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
Returns
the index

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::getTemporaryVarArrayIndex(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getTemporaryVarArrayIndex().

◆ getTemporaryVarArrayName()

template<class Base>
virtual const std::string& CppAD::cg::VariableNameGenerator< Base >::getTemporaryVarArrayName ( const OperationNode< Base > &  var,
size_t  id 
)
pure virtual

Provides the array name for the temporary variables. It should only be called if temporary variables are saved in an array.

Parameters
varthe temporary variable node
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
Returns
the array name

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::getTemporaryVarArrayName(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getTemporaryVarArrayName().

◆ isConsecutiveInIndepArray()

template<class Base>
virtual bool CppAD::cg::VariableNameGenerator< Base >::isConsecutiveInIndepArray ( const OperationNode< Base > &  indepFirst,
size_t  idFirst,
const OperationNode< Base > &  indepSecond,
size_t  idSecond 
)
pure virtual

Whether or not two independent variables are considered to be part of the same independent variable array at consecutive locations.

Parameters
indepFirstthe independent node (CGInvOp) with the lower index
idFirstan ID assigned by the CodeHandler to the first node (unique for independent variables)
indepSecondthe independent node (CGInvOp) with the higher index
idSecondan ID assigned by the CodeHandler to the second node (unique for independent variables)
Returns
true if the independents are consecutive

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >, CppAD::cg::LangLatexCustomVariableNameGenerator< Base >, CppAD::cg::LangMathMLCustomVariableNameGenerator< Base >, and CppAD::cg::LangCCustomVariableNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::isConsecutiveInIndepArray(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::isConsecutiveInIndepArray().

◆ isConsecutiveInTemporaryVarArray()

template<class Base>
virtual bool CppAD::cg::VariableNameGenerator< Base >::isConsecutiveInTemporaryVarArray ( const OperationNode< Base > &  varFirst,
size_t  idFirst,
const OperationNode< Base > &  varSecond,
size_t  idSecond 
)
pure virtual

Whether or not two temporary variables are considered to be part of the same temporary variable array at consecutive locations.

Parameters
varFirstthe temporary variable node with the lower index
idFirstan ID assigned by the CodeHandler to the first node (potentially not unique)
varSecondthe temporary variable node with the higher index
varSecondan ID assigned by the CodeHandler to the second node (potentially not unique)
Returns
true if they are consecutive

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::isConsecutiveInTemporaryVarArray(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::isConsecutiveInTemporaryVarArray().

◆ isInSameIndependentArray()

template<class Base>
virtual bool CppAD::cg::VariableNameGenerator< Base >::isInSameIndependentArray ( const OperationNode< Base > &  indep1,
size_t  id1,
const OperationNode< Base > &  indep2,
size_t  id2 
)
pure virtual

Determines whether or not two independents are part of the same independent variable array.

Parameters
indep1the first independent node (CGInvOp or CGLoopIndexedIndepOp)
id1an ID assigned by the CodeHandler to indep1 (unique for independent variables)
indep2the second independent node (CGInvOp or CGLoopIndexedIndepOp)
id2an ID assigned by the CodeHandler to indep2 (unique for independent variables)
Returns
true if the independents are part of the same array

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >, CppAD::cg::LangLatexCustomVariableNameGenerator< Base >, CppAD::cg::LangMathMLCustomVariableNameGenerator< Base >, and CppAD::cg::LangCCustomVariableNameGenerator< Base >.

◆ isInSameTemporaryVarArray()

template<class Base>
virtual bool CppAD::cg::VariableNameGenerator< Base >::isInSameTemporaryVarArray ( const OperationNode< Base > &  var1,
size_t  id1,
const OperationNode< Base > &  var2,
size_t  id2 
)
pure virtual

Determines whether or not two temporary variables are part of the same temporary variable array.

Parameters
var1the temporary variable node
id1an ID assigned by the CodeHandler to var1 (potentially not unique)
var2the temporary variable node
id2an ID assigned by the CodeHandler to var2 (potentially not unique)
Returns
true if the temporary variables are part of the same array

Implemented in CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultVariableNameGenerator< Base >, and CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >.

Referenced by CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::isInSameTemporaryVarArray(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::isInSameTemporaryVarArray().

◆ setTemporaryVariableID()

template<class Base>
virtual void CppAD::cg::VariableNameGenerator< Base >::setTemporaryVariableID ( size_t  minTempID,
size_t  maxTempID,
size_t  maxTempArrayID,
size_t  maxTempSparseArrayID 
)
pure virtual

Defines the ID ranges used by each variable type.

Parameters
minTempIDthe lowest ID of temporary variables
maxTempIDthe highest used ID of temporary variables
maxTempArrayIDthe highest used ID of temporary dense array variables
maxTempSparseArrayIDthe highest used ID of temporary sparse array variables

Implemented in CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >, CppAD::cg::LangMathMLDefaultVariableNameGenerator< Base >, CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >, CppAD::cg::LangLatexDefaultVariableNameGenerator< Base >, and CppAD::cg::LangCDefaultVariableNameGenerator< Base >.

Referenced by CppAD::cg::CodeHandler< ScalarOut >::generateCode(), CppAD::cg::LangCDefaultHessianVarNameGenerator< Base >::setTemporaryVariableID(), and CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::setTemporaryVariableID().


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