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

Public Member Functions

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

Protected Attributes

VariableNameGenerator< Base > * _nameGen
 
const size_t _minLevel1ID
 
const std::string _level1Name
 
const size_t _minLevel2ID
 
const std::string _level2Name
 
std::stringstream _ss
 
std::vector< FuncArgument_dependent
 
std::vector< FuncArgument_independent
 
std::vector< FuncArgument_temporary
 

Detailed Description

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

Creates variables names for the source code generated for second-order reverse mode calculations. The independent variables are considered to have been registered first, followed by a first level of additional variables and then a second.

Author
Joao Leal

Definition at line 31 of file lang_c_default_reverse2_var_name_gen.hpp.

Member Function Documentation

◆ generateDependent()

template<class Base >
std::string CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::generateDependent ( size_t  index)
inlineoverridevirtual

Creates a name for a dependent variable.

Parameters
indexthe dependent variable index
Returns
the generated name

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 104 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateIndependent()

template<class Base >
std::string CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::generateIndependent ( const OperationNode< Base > &  variable,
size_t  id 
)
inlineoverridevirtual

Creates a name for a dependent variable.

Parameters
variablethe node representing the independent variable
idan ID assigned by the CodeHandler to the operation node (unique for independent variables)
Returns
the generated name

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 108 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateIndexedDependent()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 139 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateIndexedIndependent()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 145 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateTemporary()

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

Creates a name for a temporary variable.

Parameters
variablethe node representing the temporary variable
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
Returns
the generated name

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 124 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateTemporaryArray()

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

Creates a name for a temporary dense array variable.

Parameters
variablethe node representing the dense array variable creation
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
Returns
the generated name

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 129 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ generateTemporarySparseArray()

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

Creates a name for a temporary sparse array variable.

Parameters
variablethe node representing the sparse array variable creation
idan ID assigned by the CodeHandler to the operation node (potentially not unique)
Returns
the generated name

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 134 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getDependent()

template<class Base >
const std::vector<FuncArgument>& CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getDependent ( ) const
inlineoverridevirtual

Provides the dependent variable arguments used by a function.

Returns
the dependent variable arguments

Reimplemented from CppAD::cg::VariableNameGenerator< Base >.

Definition at line 80 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getIndependent()

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

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 >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getIndependentArrayIndex ( const OperationNode< Base > &  indep,
size_t  id 
)
inlineoverridevirtual

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 187 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getIndependentArrayName()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 177 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getMaxTemporaryArrayVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getMaxTemporaryArrayVariableID ( ) const
inlineoverridevirtual

Provides the maximum variable ID of temporary dense array variables.

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 96 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getMaxTemporarySparseArrayVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getMaxTemporarySparseArrayVariableID ( ) const
inlineoverridevirtual

Provides the maximum variable ID of temporary sparse array variables.

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 100 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getMaxTemporaryVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getMaxTemporaryVariableID ( ) const
inlineoverridevirtual

Provides the maximum used variable ID of temporary variables.

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 92 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getMinTemporaryVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getMinTemporaryVariableID ( ) const
inlineoverridevirtual

Provides the minimum variable ID of temporary variables.

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 88 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getTemporary()

template<class Base >
const std::vector<FuncArgument>& CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getTemporary ( ) const
inlineoverridevirtual

Provides the temporary variable arguments used by a function.

Returns
the temporary variable arguments

Reimplemented from CppAD::cg::VariableNameGenerator< Base >.

Definition at line 84 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getTemporaryVarArrayIndex()

template<class Base >
size_t CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::getTemporaryVarArrayIndex ( const OperationNode< Base > &  var,
size_t  id 
)
inlineoverridevirtual

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 239 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ getTemporaryVarArrayName()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 234 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ isConsecutiveInIndepArray()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 197 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ isConsecutiveInTemporaryVarArray()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 244 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ isInSameIndependentArray()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 213 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ isInSameTemporaryVarArray()

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

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 251 of file lang_c_default_reverse2_var_name_gen.hpp.

◆ setTemporaryVariableID()

template<class Base >
void CppAD::cg::LangCDefaultReverse2VarNameGenerator< Base >::setTemporaryVariableID ( size_t  minTempID,
size_t  maxTempID,
size_t  maxTempArrayID,
size_t  maxTempSparseArrayID 
)
inlineoverridevirtual

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

Implements CppAD::cg::VariableNameGenerator< Base >.

Definition at line 258 of file lang_c_default_reverse2_var_name_gen.hpp.


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