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

Public Types

using CGB = CppAD::cg::CG< Base >
 
using Arg = Argument< Base >
 
using pairss = std::pair< size_t, size_t >
 

Public Member Functions

 LoopModel (ADFun< CGB > *fun, bool containsAtoms, size_t iterationCount, const std::vector< std::vector< size_t > > &dependentOrigIndexes, const std::vector< std::vector< size_t > > &indexedIndepOrigIndexes, const std::vector< size_t > &nonIndexedIndepOrigIndexes, const std::vector< size_t > &temporaryIndependents)
 
 LoopModel (const LoopModel< Base > &)=delete
 
LoopModeloperator= (const LoopModel< Base > &)=delete
 
size_t getLoopId () const
 
bool isContainsAtomics () const
 
const size_t getIterationCount () const
 
ADFun< CGB > & getTape () const
 
size_t getTapeDependentCount () const
 
size_t getTapeIndependentCount () const
 
const std::vector< std::vector< LoopPosition > > & getDependentIndexes () const
 
const std::vector< IterEquationGroup< Base > > & getEquationsGroups () const
 
const std::vector< std::set< const IterEquationGroup< Base > * > > & getIterationEquationsGroup () const
 
const std::vector< std::vector< LoopPosition > > & getIndexedIndepIndexes () const
 
const std::vector< LoopPosition > & getNonIndexedIndepIndexes () const
 
const std::vector< LoopPosition > & getTemporaryIndependents () const
 
const LoopIndexedPositiongetTapeDependentIndex (size_t origI) const
 
const std::map< size_t, LoopIndexedPosition > & getOriginalDependentIndexes () const
 
const LoopPositiongetNonIndexedIndepIndexes (size_t origJ) const
 
const LoopPositiongetTempIndepIndexes (size_t k) const
 
const std::set< size_t > & getIndexedTapeIndexes (size_t iteration, size_t origJ) const
 
std::map< size_t, std::set< size_t > > getIndexedTapeIndexes (size_t origJ) const
 
void detectIndexPatterns ()
 
const std::vector< IndexPattern * > & getDependentIndexPatterns () const
 
const std::vector< IndexPattern * > & getIndependentIndexPatterns () const
 
bool isTemporary (size_t tapeJ) const
 
bool isIndexedIndependent (size_t tapeJ) const
 
void evalJacobianSparsity ()
 
const std::vector< std::set< size_t > > & getJacobianSparsity () const
 
void evalHessianSparsity ()
 
const std::vector< std::set< size_t > > & getHessianSparsity () const
 

Static Public Member Functions

static void printOriginalVariableIndexes (std::ostringstream &ss, const std::vector< LoopPosition > &indexes)
 

Static Public Attributes

static const std::string ITERATION_INDEX_NAME
 

Detailed Description

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

A model representing a loop body for source code generation

Author
Joao Leal

Definition at line 108 of file declare_cg.hpp.

Constructor & Destructor Documentation

◆ LoopModel()

template<class Base>
CppAD::cg::LoopModel< Base >::LoopModel ( ADFun< CGB > *  fun,
bool  containsAtoms,
size_t  iterationCount,
const std::vector< std::vector< size_t > > &  dependentOrigIndexes,
const std::vector< std::vector< size_t > > &  indexedIndepOrigIndexes,
const std::vector< size_t > &  nonIndexedIndepOrigIndexes,
const std::vector< size_t > &  temporaryIndependents 
)
inline

Creates a new atomic function that is responsible for defining the dependencies to calls of a user atomic function.

Parameters
funThe tape for a single loop iteration (loop model)
containsAtomsWhether or not fun calls atomic functions
iterationCountNumber of loop iterations
dependentOrigIndexes
indexedIndepOrigIndexes
nonIndexedIndepOrigIndexes
temporaryIndependents

dependents

Must determine the equations which are present at the same iterations (some equations may not be present at some iterations)

independents

Definition at line 125 of file loop_model.hpp.

Member Function Documentation

◆ getDependentIndexes()

template<class Base>
const std::vector<std::vector<LoopPosition> >& CppAD::cg::LoopModel< Base >::getDependentIndexes ( ) const
inline

Provides the dependent variables indexes ([tape equation][iteration])

Definition at line 291 of file loop_model.hpp.

Referenced by CppAD::cg::ModelCSourceGen< Base >::prepareSparseReverseOneWithLoops().

◆ getEquationsGroups()

template<class Base>
const std::vector<IterEquationGroup<Base> >& CppAD::cg::LoopModel< Base >::getEquationsGroups ( ) const
inline

Provides groups of equations present at the same iterations

Definition at line 298 of file loop_model.hpp.

Referenced by CppAD::cg::LoopFreeModel< Base >::calculateJacobianHessianUsedByLoops(), and CppAD::cg::loops::HessianWithLoopsInfo< Base >::evalLoopModelJacobianHessian().

◆ getIndexedIndepIndexes()

template<class Base>
const std::vector<std::vector<LoopPosition> >& CppAD::cg::LoopModel< Base >::getIndexedIndepIndexes ( ) const
inline

Provides the indexed independent variables ([tape variable][iteration])

Definition at line 309 of file loop_model.hpp.

Referenced by CppAD::cg::ModelCSourceGen< Base >::analyseSparseJacobianWithLoops(), and CppAD::cg::IterEquationGroup< Base >::evalHessianSparsity().

◆ getIndexedTapeIndexes() [1/2]

template<class Base>
const std::set<size_t>& CppAD::cg::LoopModel< Base >::getIndexedTapeIndexes ( size_t  iteration,
size_t  origJ 
) const
inline

Finds the local tape variable indexes which use a given model variable at a given iteration

Parameters
origJthe index of the variable in the original model
iterationthe iteration
Returns
the indexes of tape variables where the variable is used

Definition at line 374 of file loop_model.hpp.

Referenced by CppAD::cg::ModelCSourceGen< Base >::analyseSparseJacobianWithLoops().

◆ getIndexedTapeIndexes() [2/2]

template<class Base>
std::map<size_t, std::set<size_t> > CppAD::cg::LoopModel< Base >::getIndexedTapeIndexes ( size_t  origJ) const
inline

Finds the local tape variable indexes which use a given model variable

Parameters
origJthe index of the variable in the original model
Returns
all the indexed tape variables for each iteration where the variable is used

Definition at line 393 of file loop_model.hpp.

◆ getIterationCount()

◆ getLoopId()

template<class Base>
size_t CppAD::cg::LoopModel< Base >::getLoopId ( ) const
inline

◆ getNonIndexedIndepIndexes() [1/2]

template<class Base>
const std::vector<LoopPosition>& CppAD::cg::LoopModel< Base >::getNonIndexedIndepIndexes ( ) const
inline

◆ getNonIndexedIndepIndexes() [2/2]

template<class Base>
const LoopPosition* CppAD::cg::LoopModel< Base >::getNonIndexedIndepIndexes ( size_t  origJ) const
inline

Maps the original variable indexes to non-indexed variables

Definition at line 345 of file loop_model.hpp.

◆ getTape()

◆ getTapeDependentCount()

template<class Base>
size_t CppAD::cg::LoopModel< Base >::getTapeDependentCount ( ) const
inline

Provides the number of dependent variables in the loop tape/model (number of equation patterns).

Returns
the number of dependents in the loop model (number of equation patterns)

Definition at line 274 of file loop_model.hpp.

◆ getTapeDependentIndex()

template<class Base>
const LoopIndexedPosition& CppAD::cg::LoopModel< Base >::getTapeDependentIndex ( size_t  origI) const
inline

Provides the locations where a dependent variable is used

Parameters
origIthe dependent variable index in the original model
Returns
the locations where a dependent variable is used

Definition at line 334 of file loop_model.hpp.

◆ getTapeIndependentCount()

template<class Base>
size_t CppAD::cg::LoopModel< Base >::getTapeIndependentCount ( ) const
inline

Provides the number of independent variables in the loop tape/model (number of indexed + non-indexed + temporary variables).

Returns
the number of independents in the loop model

Definition at line 284 of file loop_model.hpp.

◆ getTempIndepIndexes()

template<class Base>
const LoopPosition* CppAD::cg::LoopModel< Base >::getTempIndepIndexes ( size_t  k) const
inline

Maps the temporary variable indexes to temporary variables

Definition at line 357 of file loop_model.hpp.

Referenced by CppAD::cg::LoopFreeModel< Base >::calculateJacobianHessianUsedByLoops(), and CppAD::cg::ModelCSourceGen< Base >::prepareSparseJacobianRowWithLoops().

◆ getTemporaryIndependents()

template<class Base>
const std::vector<LoopPosition>& CppAD::cg::LoopModel< Base >::getTemporaryIndependents ( ) const
inline

Provides the independent variables related with temporary variables of the original model.

Definition at line 324 of file loop_model.hpp.

Referenced by CppAD::cg::ModelCSourceGen< Base >::analyseSparseJacobianWithLoops(), and CppAD::cg::IterEquationGroup< Base >::evalHessianSparsity().

◆ isContainsAtomics()

template<class Base>
bool CppAD::cg::LoopModel< Base >::isContainsAtomics ( ) const
inline

Whether or not the tape for the loop calls atomic functions.

Returns
Whether or not it calls atomic functions.

Definition at line 245 of file loop_model.hpp.


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