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 >:
Collaboration graph
[legend]

List of all members.

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:

 opengm::ExplicitStorage<GmType> storage(gm);
 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 65 of file graphicalmodel_explicit_storage.hxx.


Constructor & Destructor Documentation

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

Definition at line 79 of file graphicalmodel_explicit_storage.hxx.

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

Definition at line 113 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 117 of file graphicalmodel_explicit_storage.hxx.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Jun 17 16:31:11 2013 for OpenGM by  doxygen 1.6.3