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

Public Member Functions

 LangCCustomVariableNameGenerator (std::vector< std::string > depNames, std::vector< std::string > indepNames, const std::string &depName="y", const std::string &indepName="x", const std::string &tmpName="v", const std::string &tmpArrayName="array")
 
std::string generateDependent (size_t index) override
 
std::string generateIndependent (const OperationNode< Base > &independent, size_t id) override
 
bool isConsecutiveInIndepArray (const OperationNode< Base > &indepFirst, size_t idFirst, const OperationNode< Base > &indepSecond, size_t idSecond) override
 
bool isInSameIndependentArray (const OperationNode< Base > &indep1, size_t id1, const OperationNode< Base > &indep2, size_t id2) override
 
size_t getMinTemporaryVariableID () const override
 
size_t getMaxTemporaryVariableID () const override
 
size_t getMaxTemporaryArrayVariableID () const override
 
size_t getMaxTemporarySparseArrayVariableID () const 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
 
void setTemporaryVariableID (size_t minTempID, size_t maxTempID, size_t maxTempArrayID, size_t maxTempSparseArrayID) override
 
const std::string & getIndependentArrayName (const OperationNode< Base > &indep, size_t id) override
 
size_t getIndependentArrayIndex (const OperationNode< Base > &indep, size_t id) 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
 
virtual const std::vector< FuncArgument > & getDependent () const
 
virtual const std::vector< FuncArgument > & getIndependent () const
 
virtual const std::vector< FuncArgument > & getTemporary () const
 
virtual void customFunctionVariableDeclarations (std::ostream &out)
 
virtual void prepareCustomFunctionVariables (std::ostream &out)
 
virtual void finalizeCustomFunctionVariables (std::ostream &out)
 

Static Protected Member Functions

static std::vector< const OperationNode< Base > * > getIndexes (const OperationNode< Base > &var, size_t offset)
 

Protected Attributes

const std::vector< std::string > depNames_
 
const std::vector< std::string > indepNames_
 
std::stringstream _ss
 
std::string _depName
 
std::string _indepName
 
std::string _tmpName
 
std::string _tmpArrayName
 
std::string _tmpSparseArrayName
 
size_t _minTemporaryID
 
size_t _maxTemporaryID
 
size_t _maxTemporaryArrayID
 
size_t _maxTemporarySparseArrayID
 
std::vector< FuncArgument_dependent
 
std::vector< FuncArgument_independent
 
std::vector< FuncArgument_temporary
 

Detailed Description

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

Creates variables names for the source code using a list of provided custom names.

Author
Joao Leal

Definition at line 135 of file declare_cg.hpp.

Member Function Documentation

◆ generateDependent()

template<class Base>
std::string CppAD::cg::LangCCustomVariableNameGenerator< 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 49 of file lang_c_custom_var_name_gen.hpp.

◆ generateIndependent()

template<class Base>
std::string CppAD::cg::LangCCustomVariableNameGenerator< 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 57 of file lang_c_custom_var_name_gen.hpp.

◆ generateIndexedDependent()

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

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 149 of file lang_c_default_var_name_gen.hpp.

◆ generateIndexedIndependent()

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

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 163 of file lang_c_default_var_name_gen.hpp.

◆ generateTemporary()

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

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 111 of file lang_c_default_var_name_gen.hpp.

◆ generateTemporaryArray()

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

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 125 of file lang_c_default_var_name_gen.hpp.

◆ generateTemporarySparseArray()

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

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 137 of file lang_c_default_var_name_gen.hpp.

◆ getDependent()

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

◆ 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::LangCDefaultVariableNameGenerator< Base >::getIndependentArrayIndex ( const OperationNode< Base > &  indep,
size_t  id 
)
inlineoverridevirtualinherited

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 197 of file lang_c_default_var_name_gen.hpp.

◆ getIndependentArrayName()

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

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 192 of file lang_c_default_var_name_gen.hpp.

◆ getMaxTemporaryArrayVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultVariableNameGenerator< Base >::getMaxTemporaryArrayVariableID ( ) const
inlineoverridevirtualinherited

Provides the maximum variable ID of temporary dense array variables.

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

Definition at line 84 of file lang_c_default_var_name_gen.hpp.

◆ getMaxTemporarySparseArrayVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultVariableNameGenerator< Base >::getMaxTemporarySparseArrayVariableID ( ) const
inlineoverridevirtualinherited

Provides the maximum variable ID of temporary sparse array variables.

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

Definition at line 88 of file lang_c_default_var_name_gen.hpp.

◆ getMaxTemporaryVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultVariableNameGenerator< Base >::getMaxTemporaryVariableID ( ) const
inlineoverridevirtualinherited

Provides the maximum used variable ID of temporary variables.

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

Definition at line 80 of file lang_c_default_var_name_gen.hpp.

◆ getMinTemporaryVariableID()

template<class Base >
size_t CppAD::cg::LangCDefaultVariableNameGenerator< Base >::getMinTemporaryVariableID ( ) const
inlineoverridevirtualinherited

Provides the minimum variable ID of temporary variables.

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

Definition at line 76 of file lang_c_default_var_name_gen.hpp.

◆ getTemporary()

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

◆ getTemporaryVarArrayIndex()

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

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 221 of file lang_c_default_var_name_gen.hpp.

◆ getTemporaryVarArrayName()

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

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 216 of file lang_c_default_var_name_gen.hpp.

◆ isConsecutiveInIndepArray()

template<class Base>
bool CppAD::cg::LangCCustomVariableNameGenerator< 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 67 of file lang_c_custom_var_name_gen.hpp.

◆ isConsecutiveInTemporaryVarArray()

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

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 226 of file lang_c_default_var_name_gen.hpp.

◆ isInSameIndependentArray()

template<class Base>
bool CppAD::cg::LangCCustomVariableNameGenerator< 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 82 of file lang_c_custom_var_name_gen.hpp.

◆ isInSameTemporaryVarArray()

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

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 233 of file lang_c_default_var_name_gen.hpp.

◆ setTemporaryVariableID()

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

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 177 of file lang_c_default_var_name_gen.hpp.


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