2 #ifndef OPENGM_MODELVIEWFUNCTION_HXX
3 #define OPENGM_MODELVIEWFUNCTION_HXX
15 template<
class GM,
class MARRAY>
18 typename GM::ValueType,
19 typename GM::IndexType,
20 typename GM::LabelType>
30 ModelViewFunction(
const GraphicalModelType& gm,
const IndexType factorIndex,
const ValueType scale, OffsetType
const* offset);
31 ModelViewFunction(
const GraphicalModelType& gm,
const IndexType factorIndex,
const ValueType scale);
34 template<
class Iterator> ValueType
operator()(Iterator begin)
const;
36 LabelType
shape(
const size_t i)
const;
50 GraphicalModelType
const* gm_;
51 IndexType factorIndex_;
53 OffsetType
const* offset_;
62 template<
class GM,
class MARRAY>
66 const typename ModelViewFunction<GM, MARRAY>::IndexType factorIndex,
67 const typename ModelViewFunction<GM, MARRAY>::ValueType scale,
71 factorIndex_(factorIndex),
78 OPENGM_ASSERT((*offset_).dimension() == gm_->operator[](factorIndex_).numberOfVariables());
79 for(
size_t i=0; i<(*offset_).dimension();++i)
80 OPENGM_ASSERT((*offset_).shape(i) == gm_->operator[](factorIndex_).numberOfLabels(i));
87 template<
class GM,
class MARRAY>
91 const typename ModelViewFunction<GM, MARRAY>::IndexType factorIndex,
95 factorIndex_(factorIndex),
103 template<
class GM,
class MARRAY>
116 template<
class GM,
class MARRAY>
117 template<
class Iterator>
126 return scale_*gm_->operator[](factorIndex_)(begin) + (*offset_)(begin);
128 return scale_*gm_->operator[](factorIndex_)(begin);
130 return (*offset_)(begin);
137 template<
class GM,
class MARRAY>
143 OPENGM_ASSERT(gm_->operator[](factorIndex_).shape(i)==(*offset_).shape(i));
144 return (*offset_).shape(i);
146 return gm_->operator[](factorIndex_).shape(i);
148 return (*offset_).shape(i);
155 template<
class GM,
class MARRAY>
160 return (*offset_).size();
162 return gm_->operator[](factorIndex_).size();
164 return (*offset_).size();
170 template<
class GM,
class MARRAY>
175 OPENGM_ASSERT(gm_->operator[](factorIndex_).numberOfVariables()==(*offset_).dimension());
176 return (*offset_).dimension();
178 return gm_->operator[](factorIndex_).numberOfVariables();
180 return (*offset_).dimension();
190 #endif // #ifndef OPENGM_MODELVIEWFUNCTION_HXX
Fallback implementation of member functions of OpenGM functions.
#define OPENGM_ASSERT(expression)
ValueType operator()(Iterator begin) const
Function that refers to a factor of another GraphicalModel.
LabelType shape(const size_t i) const
ModelViewFunction(const GraphicalModelType &gm, const IndexType factorIndex, const ValueType scale, OffsetType const *offset)