OpenGM  2.3.x
Discrete Graphical Model Library
Public Types | Public Member Functions | Friends | List of all members
opengm::Factor< GRAPHICAL_MODEL > Class Template Reference

Abstraction (wrapper class) of factors, independent of the function used to implement the factor. More...

#include <graphicalmodel_factor.hxx>

+ Collaboration diagram for opengm::Factor< GRAPHICAL_MODEL >:

Public Types

enum  FunctionInformation { NrOfFunctionTypes = GraphicalModelType::NrOfFunctionTypes }
 
typedef GRAPHICAL_MODEL * GraphicalModelPointerType
 
typedef GRAPHICAL_MODEL GraphicalModelType
 
typedef GraphicalModelType::FunctionTypeList FunctionTypeList
 
typedef GraphicalModelType::ValueType ValueType
 
typedef GraphicalModelType::LabelType LabelType
 
typedef GraphicalModelType::IndexType IndexType
 
typedef VectorView< std::vector< IndexType >, IndexTypeVisContainerType
 
typedef opengm::AccessorIterator< ShapeAccessorType, true > ShapeIteratorType
 
typedef VisContainerType::const_iterator VariablesIteratorType
 

Public Member Functions

 Factor ()
 
 Factor (GraphicalModelPointerType)
 factors are usually not constructed directly but obtained from operator[] of GraphicalModel More...
 
 Factor (const Factor &)
 
 Factor (GraphicalModelPointerType, const IndexType, const UInt8Type, const IndexType, const IndexType)
 
Factoroperator= (const Factor &)
 
IndexType size () const
 
IndexType numberOfVariables () const
 
IndexType numberOfLabels (const IndexType) const
 return the number of labels of the j-th variable More...
 
IndexType shape (const IndexType) const
 return the extension a value table encoding this factor would have in the dimension of the j-th variable More...
 
IndexType variableIndex (const IndexType) const
 return the index of the j-th variable More...
 
ShapeIteratorType shapeBegin () const
 
ShapeIteratorType shapeEnd () const
 
template<size_t FUNCTION_TYPE_INDEX>
const meta::TypeAtTypeList< FunctionTypeList, FUNCTION_TYPE_INDEX >::type & function () const
 
VariablesIteratorType variableIndicesBegin () const
 
VariablesIteratorType variableIndicesEnd () const
 
template<class ITERATOR >
ValueType operator() (ITERATOR) const
 evaluate the factor for a sequence of labels More...
 
template<class FUNCTOR >
void callFunctor (FUNCTOR &f) const
 call a functor for the function of the factor the first and only argument passed to the functor is the function More...
 
template<class FUNCTOR >
void callViFunctor (FUNCTOR &f) const
 call a functor for the function of the factor the first to arguments passed to the functor are a begin and end iterator and the function More...
 
template<class ITERATOR >
void copyValues (ITERATOR iterator) const
 copies the values of a factors into an iterator More...
 
template<class ITERATOR >
void copyValuesSwitchedOrder (ITERATOR iterator) const
 
template<int FunctionType, class ITERATOR >
ValueType operator() (ITERATOR) const
 evaluate the factor for a sequence of labels More...
 
UInt8Type functionType () const
 
IndexType functionIndex () const
 
template<class ITERATOR >
void variableIndices (ITERATOR out) const
 
bool isPotts () const
 
bool isGeneralizedPotts () const
 
bool isSubmodular () const
 
bool isSquaredDifference () const
 
bool isTruncatedSquaredDifference () const
 
bool isAbsoluteDifference () const
 
bool isTruncatedAbsoluteDifference () const
 
bool isLinearConstraint () const
 
template<int PROPERTY>
bool binaryProperty () const
 compute a binary property of a factor More...
 
template<int PROPERTY>
ValueType valueProperty () const
 
template<class FUNCTOR >
void forAllValuesInAnyOrder (FUNCTOR &functor) const
 call a functor for all values in no defined order More...
 
template<class FUNCTOR >
void forAtLeastAllUniqueValues (FUNCTOR &functor) const
 call a functor for at least all unique values in no defined order More...
 
template<class FUNCTOR >
void forAllValuesInOrder (FUNCTOR &functor) const
 call a functor for all values in last coordinate major order More...
 
template<class FUNCTOR >
void forAllValuesInSwitchedOrder (FUNCTOR &functor) const
 
ValueType sum () const
 
ValueType product () const
 
ValueType min () const
 
ValueType max () const
 
IndexType dimension () const
 
template<class GRAPHICAL_MODEL >
 Factor (GraphicalModelPointerType gm, const typename Factor< GRAPHICAL_MODEL >::IndexType functionIndex, const UInt8Type functionTypeId, const typename Factor< GRAPHICAL_MODEL >::IndexType order, const typename Factor< GRAPHICAL_MODEL >::IndexType indexInVisVector)
 factors are usually not constructed directly but obtained from operator[] of GraphicalModel More...
 
template<int PROPERTY>
GRAPHICAL_MODEL::ValueType valueProperty () const
 compute a property of a factor More...
 
template<size_t FUNCTION_TYPE_INDEX>
meta::TypeAtTypeList< typename Factor< GRAPHICAL_MODEL >::FunctionTypeList, FUNCTION_TYPE_INDEX >::type & function ()
 
template<size_t FUNCTION_TYPE_INDEX>
const meta::TypeAtTypeList< typename Factor< GRAPHICAL_MODEL >::FunctionTypeList, FUNCTION_TYPE_INDEX >::type & function () const
 

Friends

template<typename GM_ >
void opengm::hdf5::save (const GM_ &, const std::string &, const std::string &)
 
template<typename GM_ >
void opengm::hdf5::load (GM_ &, const std::string &, const std::string &)
 

Detailed Description

template<class GRAPHICAL_MODEL>
class opengm::Factor< GRAPHICAL_MODEL >

Abstraction (wrapper class) of factors, independent of the function used to implement the factor.

Definition at line 103 of file graphicalmodel_factor.hxx.

Member Typedef Documentation

template<class GRAPHICAL_MODEL>
typedef GraphicalModelType::FunctionTypeList opengm::Factor< GRAPHICAL_MODEL >::FunctionTypeList

Definition at line 111 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef GRAPHICAL_MODEL* opengm::Factor< GRAPHICAL_MODEL >::GraphicalModelPointerType

Definition at line 105 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef GRAPHICAL_MODEL opengm::Factor< GRAPHICAL_MODEL >::GraphicalModelType

Definition at line 106 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef GraphicalModelType::IndexType opengm::Factor< GRAPHICAL_MODEL >::IndexType

Definition at line 114 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef GraphicalModelType::LabelType opengm::Factor< GRAPHICAL_MODEL >::LabelType

Definition at line 113 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef opengm::AccessorIterator<ShapeAccessorType, true> opengm::Factor< GRAPHICAL_MODEL >::ShapeIteratorType

Definition at line 120 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef GraphicalModelType::ValueType opengm::Factor< GRAPHICAL_MODEL >::ValueType

Definition at line 112 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef VisContainerType::const_iterator opengm::Factor< GRAPHICAL_MODEL >::VariablesIteratorType

Definition at line 121 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
typedef VectorView< std::vector<IndexType> , IndexType > opengm::Factor< GRAPHICAL_MODEL >::VisContainerType

Definition at line 119 of file graphicalmodel_factor.hxx.

Member Enumeration Documentation

template<class GRAPHICAL_MODEL>
enum opengm::Factor::FunctionInformation
Enumerator
NrOfFunctionTypes 

Definition at line 107 of file graphicalmodel_factor.hxx.

Constructor & Destructor Documentation

template<class GRAPHICAL_MODEL >
opengm::Factor< GRAPHICAL_MODEL >::Factor ( )
inline

Definition at line 396 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
opengm::Factor< GRAPHICAL_MODEL >::Factor ( GraphicalModelPointerType  gm)
inline

factors are usually not constructed directly but obtained from operator[] of GraphicalModel

Definition at line 432 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
opengm::Factor< GRAPHICAL_MODEL >::Factor ( const Factor< GRAPHICAL_MODEL > &  src)
inline

Definition at line 443 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
opengm::Factor< GRAPHICAL_MODEL >::Factor ( GraphicalModelPointerType  ,
const IndexType  ,
const UInt8Type  ,
const IndexType  ,
const IndexType   
)
template<class GRAPHICAL_MODEL>
template<class GRAPHICAL_MODEL >
opengm::Factor< GRAPHICAL_MODEL >::Factor ( GraphicalModelPointerType  gm,
const typename Factor< GRAPHICAL_MODEL >::IndexType  functionIndex,
const UInt8Type  functionTypeId,
const typename Factor< GRAPHICAL_MODEL >::IndexType  order,
const typename Factor< GRAPHICAL_MODEL >::IndexType  indexInVisVector 
)
inline

factors are usually not constructed directly but obtained from operator[] of GraphicalModel

Definition at line 405 of file graphicalmodel_factor.hxx.

Member Function Documentation

template<class GRAPHICAL_MODEL >
template<int PROPERTY>
bool opengm::Factor< GRAPHICAL_MODEL >::binaryProperty ( ) const
inline

compute a binary property of a factor

The property must be one of the properties defined in opengm::BinartyProperties::Values

Usage:

const size_t factorIndex=0;
bool isPotts=gm[factorIndex]. template binaryProperty<opengm::BinaryProperties::IsPotts>();
OPENGM_ASSERT(gm[factorIndex].isPotts() == isPotts);

Definition at line 630 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::callFunctor ( FUNCTOR &  f) const
inline

call a functor for the function of the factor the first and only argument passed to the functor is the function

Definition at line 551 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::callViFunctor ( FUNCTOR &  f) const
inline

call a functor for the function of the factor the first to arguments passed to the functor are a begin and end iterator and the function

Definition at line 566 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class ITERATOR >
void opengm::Factor< GRAPHICAL_MODEL >::copyValues ( ITERATOR  begin) const
inline

copies the values of a factors into an iterator

Parameters
beginoutput iterator to store the factors values in last coordinate major order

Definition at line 583 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class ITERATOR >
void opengm::Factor< GRAPHICAL_MODEL >::copyValuesSwitchedOrder ( ITERATOR  iterator) const
inline

Definition at line 595 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
IndexType opengm::Factor< GRAPHICAL_MODEL >::dimension ( ) const
inline

Definition at line 194 of file graphicalmodel_factor.hxx.

+ Here is the call graph for this function:

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::forAllValuesInAnyOrder ( FUNCTOR &  functor) const
inline

call a functor for all values in no defined order

Usage:

opengm::AccumulationFunctor<opengm::Adder,ValueType> functor;
const size_t factorIndex=0;
gm[factorIndex].forAllValuesInAnyOrder(functor);
OPENGM_ASSERT(gm[factorIndex].sum()==functor.value());

Definition at line 672 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::forAllValuesInOrder ( FUNCTOR &  functor) const
inline

call a functor for all values in last coordinate major order

Usage:

opengm::AccumulationFunctor<opengm::Multipler,ValueType> functor;
const size_t factorIndex=0;
gm[factorIndex].forAllValuesInOrder(functor);
OPENGM_ASSERT(gm[factorIndex].product()==functor.value());

Definition at line 715 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::forAllValuesInSwitchedOrder ( FUNCTOR &  functor) const
inline

Definition at line 727 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<class FUNCTOR >
void opengm::Factor< GRAPHICAL_MODEL >::forAtLeastAllUniqueValues ( FUNCTOR &  functor) const
inline

call a functor for at least all unique values in no defined order

Usage:

opengm::AccumulationFunctor<opengm::Maximizer,ValueType> functor;
const size_t factorIndex=0;
gm[factorIndex].forAtLeastAllUniqueValues(functor);
OPENGM_ASSERT(gm[factorIndex].max()==functor.value());

Definition at line 694 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
template<size_t FUNCTION_TYPE_INDEX>
const meta::TypeAtTypeList<FunctionTypeList, FUNCTION_TYPE_INDEX>::type& opengm::Factor< GRAPHICAL_MODEL >::function ( ) const
template<class GRAPHICAL_MODEL>
template<size_t FUNCTION_TYPE_INDEX>
meta::TypeAtTypeList< typename Factor<GRAPHICAL_MODEL>::FunctionTypeList, FUNCTION_TYPE_INDEX>::type& opengm::Factor< GRAPHICAL_MODEL >::function ( )
inline

Definition at line 874 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
template<size_t FUNCTION_TYPE_INDEX>
const meta::TypeAtTypeList< typename Factor<GRAPHICAL_MODEL>::FunctionTypeList, FUNCTION_TYPE_INDEX>::type& opengm::Factor< GRAPHICAL_MODEL >::function ( ) const
inline

Definition at line 884 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::functionIndex ( ) const
inline

Definition at line 935 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
opengm::UInt8Type opengm::Factor< GRAPHICAL_MODEL >::functionType ( ) const
inline

Definition at line 929 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isAbsoluteDifference ( ) const
inline

Definition at line 792 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isGeneralizedPotts ( ) const
inline

Definition at line 746 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isLinearConstraint ( ) const
inline

Definition at line 820 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isPotts ( ) const
inline

Definition at line 737 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isSquaredDifference ( ) const
inline

Definition at line 764 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isSubmodular ( ) const
inline

Definition at line 755 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isTruncatedAbsoluteDifference ( ) const
inline

Definition at line 806 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
bool opengm::Factor< GRAPHICAL_MODEL >::isTruncatedSquaredDifference ( ) const
inline

Definition at line 778 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::max ( ) const
inline

Definition at line 853 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::min ( ) const
inline

Definition at line 845 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::numberOfLabels ( const IndexType  j) const
inline

return the number of labels of the j-th variable

Definition at line 496 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::numberOfVariables ( ) const
inline

Definition at line 504 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

template<class GRAPHICAL_MODEL >
template<class ITERATOR >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::operator() ( ITERATOR  begin) const
inline

evaluate the factor for a sequence of labels

Parameters
beginiterator to the beginning of a sequence of labels

Definition at line 535 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
template<int FunctionType, class ITERATOR >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::operator() ( ITERATOR  begin) const
inline

evaluate the factor for a sequence of labels

Parameters
beginiterator to the beginning of a sequence of labels

Definition at line 610 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL > & opengm::Factor< GRAPHICAL_MODEL >::operator= ( const Factor< GRAPHICAL_MODEL > &  src)
inline

Definition at line 455 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::product ( ) const
inline

Definition at line 837 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::shape ( const IndexType  j) const
inline

return the extension a value table encoding this factor would have in the dimension of the j-th variable

Definition at line 522 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ShapeIteratorType opengm::Factor< GRAPHICAL_MODEL >::shapeBegin ( ) const

Definition at line 470 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ShapeIteratorType opengm::Factor< GRAPHICAL_MODEL >::shapeEnd ( ) const

Definition at line 477 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::size ( ) const
inline

Definition at line 905 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::ValueType opengm::Factor< GRAPHICAL_MODEL >::sum ( ) const
inline

Definition at line 829 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL>
template<int PROPERTY>
ValueType opengm::Factor< GRAPHICAL_MODEL >::valueProperty ( ) const
template<class GRAPHICAL_MODEL>
template<int PROPERTY>
GRAPHICAL_MODEL::ValueType opengm::Factor< GRAPHICAL_MODEL >::valueProperty ( ) const
inline

compute a property of a factor

The property must be one of the properties defined in opengm::ValueProperties::Values

Usage:

const size_t factorIndex=0;
GmType::ValueType sum=gm[factorIndex]. template valueProperty<opengm::ValueProperties::Sum>();
OPENGM_ASSERT(gm[factorIndex].sum() == sum);

Definition at line 652 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::IndexType opengm::Factor< GRAPHICAL_MODEL >::variableIndex ( const IndexType  j) const
inline

return the index of the j-th variable

Definition at line 512 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

template<class GRAPHICAL_MODEL >
template<class ITERATOR >
void opengm::Factor< GRAPHICAL_MODEL >::variableIndices ( ITERATOR  out) const
inline

Definition at line 862 of file graphicalmodel_factor.hxx.

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::VisContainerType::const_iterator opengm::Factor< GRAPHICAL_MODEL >::variableIndicesBegin ( ) const
inline

Definition at line 893 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

template<class GRAPHICAL_MODEL >
Factor< GRAPHICAL_MODEL >::VisContainerType::const_iterator opengm::Factor< GRAPHICAL_MODEL >::variableIndicesEnd ( ) const
inline

Definition at line 899 of file graphicalmodel_factor.hxx.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<class GRAPHICAL_MODEL>
template<typename GM_ >
void opengm::hdf5::load ( GM_ &  ,
const std::string &  ,
const std::string &   
)
friend
template<class GRAPHICAL_MODEL>
template<typename GM_ >
void opengm::hdf5::save ( const GM_ &  ,
const std::string &  ,
const std::string &   
)
friend