OpenGM  2.3.x
Discrete Graphical Model Library
Public Member Functions | List of all members
opengm::ExplicitStorage< GM > Class Template Reference

ExplicitStorage (continous storage) of a graphical model function data. More...

#include <graphicalmodel_explicit_storage.hxx>

+ Collaboration diagram for opengm::ExplicitStorage< GM >:

Public Member Functions

 ExplicitStorage (const GraphicalModelType &gm)
 
 ~ExplicitStorage ()
 
ValueType const * operator[] (const FactorType &factor) const
 

Detailed Description

template<class GM>
class opengm::ExplicitStorage< GM >

ExplicitStorage (continous storage) of a graphical model function data.

ExplicitStorage stores all instances of all functions into a single continous stride of memory. Given a factor one gets the begin pointer of the corresponding function. The storage of the function is in last coordinate major order.

Usage:

typedef GmType::FactorType::ShapeIteratorType ShapeIteratorType;
// loop over all factors
for(size_t factor=0;factor<gmA.numberOfFactors();++factor){
// "usual" way to iterate over the factors values with coordinates
// is with the shapewalker class
opengm::ShapeWalker< ShapeIteratorType > walker(gm[factor].shapeBegin(),gm[factor].numberOfVariables());
// get the begin pointer to the storage of the factors function
GmType::ValueType const * ptr=storageA[gmA[factor]];
// toy / test loop over all factors values
// and compare (expensive) direct access via the factors
// and cheap access via pointer
for (size_t i = 0; i < gmA[factor].size(); ++i) {
OPENGM_TEST_EQUAL(gmA[factor](walker.coordinateTuple().begin()),ptr[i]);
++walker;
}
}

Definition at line 64 of file graphicalmodel_explicit_storage.hxx.

Constructor & Destructor Documentation

template<class GM>
opengm::ExplicitStorage< GM >::ExplicitStorage ( const GraphicalModelType &  gm)
inline

Definition at line 78 of file graphicalmodel_explicit_storage.hxx.

template<class GM>
opengm::ExplicitStorage< GM >::~ExplicitStorage ( )
inline

Definition at line 112 of file graphicalmodel_explicit_storage.hxx.

Member Function Documentation

template<class GM>
ValueType const* opengm::ExplicitStorage< GM >::operator[] ( const FactorType &  factor) const
inline

Definition at line 116 of file graphicalmodel_explicit_storage.hxx.