2 #ifndef OPENGM_GRAPHICALMODEL_FUNCTION_WRAPPER_HXX
3 #define OPENGM_GRAPHICALMODEL_FUNCTION_WRAPPER_HXX
33 class FUNCTION_TYPE_LIST ,
38 template<
class GRAPHICAL_MODEL>
class Factor;
40 namespace detail_graphical_model {
42 #define OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO( RETURN_TYPE , FUNCTION_NAME ) \
43 template<size_t NUMBER_OF_FUNCTIONS> \
46 FunctionWrapper<NUMBER_OF_FUNCTIONS>::FUNCTION_NAME \
49 const size_t functionIndex, \
50 const size_t functionType \
52 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex; \
53 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) { \
54 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
56 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) { \
58 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
60 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
62 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) { \
63 switch(functionType) { \
65 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
67 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
69 return gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
71 return gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
73 return gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
75 return gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
77 return gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
79 return gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
81 return gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
83 return gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
85 return gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
87 return gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
89 return gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
91 return gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
93 return gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
95 return gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \
97 return FunctionWrapperExecutor< \
99 NUMBER_OF_FUNCTIONS, \
100 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value \
101 >::FUNCTION_NAME(gm,functionIndex,functionType); \
105 template<size_t IX, size_t DX> \
107 RETURN_TYPE FunctionWrapperExecutor<IX, DX, false>::FUNCTION_NAME \
110 const size_t functionIndex, \
111 const size_t functionType \
113 if(functionType==IX) { \
114 return gm->template functions<IX>()[functionIndex].FUNCTION_NAME(); \
117 return FunctionWrapperExecutor<IX+1, DX, meta::Bool<IX+1==DX>::value >::FUNCTION_NAME (gm, functionIndex,functionType); \
120 template<size_t IX, size_t DX> \
122 RETURN_TYPE FunctionWrapperExecutor<IX, DX, true>::FUNCTION_NAME \
125 const size_t functionIndex, \
126 const size_t functionType \
128 throw RuntimeError("Incorrect function type id."); \
131 template<
size_t IX,
size_t DX,
bool end>
132 struct FunctionWrapperExecutor;
134 template<
size_t IX,
size_t DX>
135 struct FunctionWrapperExecutor<IX,DX,false>{
137 template <
class GM,
class FUNCTOR>
138 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
141 template <
class GM,
class ITERATOR>
142 static void getValues(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
143 template <
class GM,
class ITERATOR>
144 static void getValuesSwitchedOrder(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
145 template <
class GM,
class ITERATOR>
146 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
147 template <
class GM,
class FUNCTOR>
148 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
149 template <
class GM,
class FUNCTOR>
150 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
151 template <
class GM,
class FUNCTOR>
152 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
153 template <
class GM,
class FUNCTOR>
154 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
155 template <
class GM,
int PROPERTY>
156 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
157 template <
class GM,
int PROPERTY>
158 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
160 static size_t numberOfFunctions(
const GM *,
const size_t );
161 template <
class GM_SOURCE,
class GM_DEST>
162 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
164 static bool isPotts(GM
const *,
const size_t ,
const size_t);
166 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
168 static bool isSubmodular(GM
const *,
const size_t ,
const size_t);
170 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
172 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
174 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
176 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
178 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
180 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
182 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
184 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
186 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
189 template<
size_t IX,
size_t DX>
190 struct FunctionWrapperExecutor<IX,DX,true>{
192 template <
class GM,
class FUNCTOR>
193 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
195 template <
class GM,
class ITERATOR>
196 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
197 template <
class GM,
class ITERATOR>
198 static void getValues(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
199 template <
class GM,
class ITERATOR>
200 static void getValuesSwitchedOrder(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
201 template <
class GM,
class FUNCTOR>
202 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
203 template <
class GM,
class FUNCTOR>
204 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
205 template <
class GM,
class FUNCTOR>
206 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
207 template <
class GM,
class FUNCTOR>
208 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
209 template <
class GM,
int PROPERTY>
210 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
211 template <
class GM,
int PROPERTY>
212 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
214 static size_t numberOfFunctions(
const GM *,
const size_t functionTypeIndex);
215 template <
class GM_SOURCE,
class GM_DEST>
216 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
218 static bool isPotts(GM
const *,
const size_t ,
const size_t);
220 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
222 static bool isSubmodular(GM
const *,
const size_t,
const size_t );
224 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
226 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
228 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
230 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
232 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
234 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
236 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
238 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
240 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
243 template<
size_t NUMBER_OF_FUNCTIONS>
244 struct FunctionWrapper{
246 template <
class GM,
class FUNCTOR>
247 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
249 template <
class GM,
class OUT_ITERATOR>
250 static void getValues(
const GM *,OUT_ITERATOR,
const typename GM::IndexType ,
const size_t );
251 template <
class GM,
class OUT_ITERATOR>
252 static void getValuesSwitchedOrder(
const GM *,OUT_ITERATOR,
const typename GM::IndexType ,
const size_t );
253 template <
class GM,
class ITERATOR>
254 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
255 template <
class GM,
class FUNCTOR>
256 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
257 template <
class GM,
class FUNCTOR>
258 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
259 template <
class GM,
class FUNCTOR>
260 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
261 template <
class GM,
class FUNCTOR>
262 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
263 template <
class GM,
int PROPERTY>
264 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
265 template <
class GM,
int PROPERTY>
266 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
268 static size_t numberOfFunctions(
const GM *,
const size_t functionTypeIndex);
269 template <
class GM_SOURCE,
class GM_DEST>
270 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
272 static bool isPotts(GM
const *,
const size_t,
const size_t);
274 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
276 static bool isSubmodular(GM
const *,
const size_t ,
const size_t);
278 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
280 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
282 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
284 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
286 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
288 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
290 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
292 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
294 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
299 namespace detail_graphical_model {
300 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isSubmodular)
301 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isPotts)
302 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isGeneralizedPotts)
303 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isSquaredDifference)
304 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isTruncatedSquaredDifference)
305 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isAbsoluteDifference)
306 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isTruncatedAbsoluteDifference)
307 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isLinearConstraint)
308 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, min)
309 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, max)
310 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, sum)
311 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, product)
313 template<
size_t IX,
size_t DX>
314 template<
class GM,
class ITERATOR>
315 inline typename GM::ValueType
316 FunctionWrapperExecutor<IX,DX,false>::getValue
320 const typename GM::IndexType functionIndex,
321 const size_t functionType
323 if(IX==functionType) {
324 return gm->
template functions<IX>()[functionIndex](iterator);
327 return FunctionWrapperExecutor<
328 meta::Increment<IX>::value,
331 meta::Increment<IX>::value,
334 >::getValue(gm,iterator,functionIndex,functionType);
338 template<
size_t IX,
size_t DX>
339 template <
class GM,
class FUNCTOR>
341 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInAnyOrder
345 const typename GM::IndexType functionIndex,
346 const size_t functionType
348 if(IX==functionType) {
349 gm->
template functions<IX>()[functionIndex].forAllValuesInAnyOrder(functor);
352 FunctionWrapperExecutor<
353 meta::Increment<IX>::value,
356 meta::Increment<IX>::value,
359 >::forAllValuesInAnyOrder(gm,functor,functionIndex,functionType);
363 template<
size_t IX,
size_t DX>
364 template <
class GM,
class FUNCTOR>
366 FunctionWrapperExecutor<IX,DX,false>::forAtLeastAllUniqueValues
370 const typename GM::IndexType functionIndex,
371 const size_t functionType
373 if(IX==functionType) {
374 gm->
template functions<IX>()[functionIndex].forAtLeastAllUniqueValues(functor);
377 FunctionWrapperExecutor<
378 meta::Increment<IX>::value,
381 meta::Increment<IX>::value,
384 >::forAtLeastAllUniqueValues(gm,functor,functionIndex,functionType);
388 template<
size_t IX,
size_t DX>
389 template <
class GM,
class FUNCTOR>
391 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInOrder
395 const typename GM::IndexType functionIndex,
396 const size_t functionType
398 if(IX==functionType) {
399 gm->
template functions<IX>()[functionIndex].forAllValuesInOrder(functor);
402 FunctionWrapperExecutor<
403 meta::Increment<IX>::value,
406 meta::Increment<IX>::value,
409 >::forAllValuesInOrder(gm,functor,functionIndex,functionType);
413 template<
size_t IX,
size_t DX>
414 template <
class GM,
class FUNCTOR>
416 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInSwitchedOrder
420 const typename GM::IndexType functionIndex,
421 const size_t functionType
423 if(IX==functionType) {
424 gm->
template functions<IX>()[functionIndex].forAllValuesInSwitchedOrder(functor);
427 FunctionWrapperExecutor<
428 meta::Increment<IX>::value,
431 meta::Increment<IX>::value,
434 >::forAllValuesInSwitchedOrder(gm,functor,functionIndex,functionType);
439 template<
size_t IX,
size_t DX>
440 template <
class GM,
int PROPERTY>
442 FunctionWrapperExecutor<IX,DX,false>::binaryProperty
445 const typename GM::IndexType functionIndex,
446 const size_t functionType
448 if(IX==functionType) {
449 typedef typename GM::FunctionTypeList FTypeList;
450 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
451 return BinaryFunctionProperties<PROPERTY, FunctionType>::op(gm->
template functions<IX>()[functionIndex]);
454 return FunctionWrapperExecutor<
455 meta::Increment<IX>::value,
458 meta::Increment<IX>::value,
461 >:: template binaryProperty<GM,PROPERTY>(gm,functionIndex,functionType);
465 template<
size_t IX,
size_t DX>
466 template <
class GM,
int PROPERTY>
467 inline typename GM::ValueType
468 FunctionWrapperExecutor<IX,DX,false>::valueProperty
471 const typename GM::IndexType functionIndex,
472 const size_t functionType
474 if(IX==functionType) {
475 typedef typename GM::FunctionTypeList FTypeList;
476 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
477 return ValueFunctionProperties<PROPERTY, FunctionType>::op(gm->
template functions<IX>()[functionIndex]);
480 return FunctionWrapperExecutor<
481 meta::Increment<IX>::value,
484 meta::Increment<IX>::value,
487 >:: template valueProperty<GM,PROPERTY>(gm,functionIndex,functionType);
491 template<
size_t IX,
size_t DX>
492 template<
class GM,
class FUNCTOR>
494 FunctionWrapperExecutor<IX,DX,false>::callFunctor
497 const typename GM::IndexType functionIndex,
498 const size_t functionType,
501 if(IX==functionType) {
503 typedef typename GM::FunctionTypeList FTypeList;
504 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
505 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
507 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
512 return FunctionWrapperExecutor<
513 meta::Increment<IX>::value,
516 meta::Increment<IX>::value,
519 >::callFunctor(gm,functionIndex,functionType,functor);
524 template<
size_t IX,
size_t DX>
525 template<
class GM,
class ITERATOR>
527 FunctionWrapperExecutor<IX,DX,false>::getValues
531 const typename GM::IndexType functionIndex,
532 const size_t functionType
534 if(IX==functionType) {
536 typedef typename GM::FunctionTypeList FTypeList;
537 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
538 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
540 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
541 ShapeWalker< FunctionShapeIteratorType > walker(
function.functionShapeBegin(),
function.dimension());
542 for (
size_t i = 0; i <
function.size(); ++i) {
543 *iterator =
function(walker.coordinateTuple().begin());
550 return FunctionWrapperExecutor<
551 meta::Increment<IX>::value,
554 meta::Increment<IX>::value,
557 >::getValues(gm,iterator,functionIndex,functionType);
561 template<
size_t IX,
size_t DX>
562 template<
class GM,
class ITERATOR>
564 FunctionWrapperExecutor<IX,DX,false>::getValuesSwitchedOrder
568 const typename GM::IndexType functionIndex,
569 const size_t functionType
571 if(IX==functionType) {
573 typedef typename GM::FunctionTypeList FTypeList;
574 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
575 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
577 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
578 ShapeWalkerSwitchedOrder< FunctionShapeIteratorType > walker(
function.functionShapeBegin(),
function.dimension());
579 for (
size_t i = 0; i <
function.size(); ++i) {
580 *iterator =
function(walker.coordinateTuple().begin());
587 return FunctionWrapperExecutor<
588 meta::Increment<IX>::value,
591 meta::Increment<IX>::value,
594 >::getValuesSwitchedOrder(gm,iterator,functionIndex,functionType);
598 template<
size_t IX,
size_t DX>
599 template<
class GM,
class ITERATOR>
601 FunctionWrapperExecutor<IX,DX,true>::getValues
605 const typename GM::IndexType functionIndex,
606 const size_t functionType
608 throw RuntimeError(
"Incorrect function type id.");
610 template<
size_t IX,
size_t DX>
611 template<
class GM,
class ITERATOR>
613 FunctionWrapperExecutor<IX,DX,true>::getValuesSwitchedOrder
617 const typename GM::IndexType functionIndex,
618 const size_t functionType
620 throw RuntimeError(
"Incorrect function type id.");
623 template<
size_t IX,
size_t DX>
624 template<
class GM,
class FUNCTOR>
626 FunctionWrapperExecutor<IX,DX,true>::callFunctor
629 const typename GM::IndexType functionIndex,
630 const size_t functionType,
633 throw RuntimeError(
"Incorrect function type id.");
636 template<
size_t IX,
size_t DX>
637 template<
class GM,
class ITERATOR>
638 inline typename GM::ValueType
639 FunctionWrapperExecutor<IX,DX,true>::getValue
643 const typename GM::IndexType functionIndex,
644 const size_t functionType
646 throw RuntimeError(
"Incorrect function type id.");
647 return typename GM::ValueType();
650 template<
size_t IX,
size_t DX>
651 template <
class GM,
class FUNCTOR>
653 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInAnyOrder
657 const typename GM::IndexType functionIndex,
658 const size_t functionType
660 throw RuntimeError(
"Incorrect function type id.");
663 template<
size_t IX,
size_t DX>
664 template <
class GM,
class FUNCTOR>
666 FunctionWrapperExecutor<IX,DX,true>::forAtLeastAllUniqueValues
670 const typename GM::IndexType functionIndex,
671 const size_t functionType
673 throw RuntimeError(
"Incorrect function type id.");
676 template<
size_t IX,
size_t DX>
677 template <
class GM,
class FUNCTOR>
679 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInOrder
683 const typename GM::IndexType functionIndex,
684 const size_t functionType
686 throw RuntimeError(
"Incorrect function type id.");
689 template<
size_t IX,
size_t DX>
690 template <
class GM,
class FUNCTOR>
692 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInSwitchedOrder
696 const typename GM::IndexType functionIndex,
697 const size_t functionType
699 throw RuntimeError(
"Incorrect function type id.");
702 template<
size_t IX,
size_t DX>
703 template <
class GM,
int PROPERTY>
705 FunctionWrapperExecutor<IX,DX,true>::binaryProperty
708 const typename GM::IndexType functionIndex,
709 const size_t functionType
711 throw RuntimeError(
"Incorrect function type id.");
715 template<
size_t IX,
size_t DX>
716 template <
class GM,
int PROPERTY>
717 inline typename GM::ValueType
718 FunctionWrapperExecutor<IX,DX,true>::valueProperty
721 const typename GM::IndexType functionIndex,
722 const size_t functionType
724 throw RuntimeError(
"Incorrect function type id.");
728 template<
size_t IX,
size_t DX>
731 FunctionWrapperExecutor<IX,DX,false>::numberOfFunctions
734 const size_t functionType
736 if(IX==functionType) {
737 return gm->template functions<IX>().size();
740 return FunctionWrapperExecutor<
741 meta::Increment<IX>::value,
744 meta::Increment<IX>::value,
747 >::numberOfFunctions(gm,functionType);
751 template<
size_t IX,
size_t DX>
754 FunctionWrapperExecutor<IX,DX,true>::numberOfFunctions
757 const size_t functionType
759 throw RuntimeError(
"Incorrect function type id.");
762 template<
size_t IX,
size_t DX>
763 template<
class GM_SOURCE,
class GM_DEST>
765 FunctionWrapperExecutor<IX,DX,false>::assignFunctions
767 const GM_SOURCE & gmSource,
770 typedef typename meta::TypeAtTypeList<
771 typename GM_SOURCE::FunctionTypeList ,
773 >::type SourceTypeAtIX;
775 meta::GetIndexInTypeList<
776 typename GM_DEST::FunctionTypeList,
779 > PositionOfSourceTypeInDestType;
780 gmDest.template functions<PositionOfSourceTypeInDestType::value> () =
781 gmSource.template functions<IX> ();
784 FunctionWrapperExecutor<
785 meta::Increment<IX>::value,
788 meta::Increment<IX>::value,
791 >::assignFunctions(gmSource,gmDest);
794 template<
size_t IX,
size_t DX>
795 template<
class GM_SOURCE,
class GM_DEST>
797 FunctionWrapperExecutor<IX,DX,true>::assignFunctions
799 const GM_SOURCE & gmSource,
804 template<
size_t NUMBER_OF_FUNCTIONS>
805 template<
class GM_SOURCE,
class GM_DEST>
807 FunctionWrapper<NUMBER_OF_FUNCTIONS>::assignFunctions
809 const GM_SOURCE & gmSource,
812 typedef FunctionWrapperExecutor<0, NUMBER_OF_FUNCTIONS, meta::Bool<NUMBER_OF_FUNCTIONS==0>::value> ExecutorType;
813 return ExecutorType::assignFunctions(gmSource, gmDest);
816 template<
size_t NUMBER_OF_FUNCTIONS>
819 FunctionWrapper<NUMBER_OF_FUNCTIONS>::numberOfFunctions
822 const size_t functionType
824 typedef FunctionWrapperExecutor<0, NUMBER_OF_FUNCTIONS, meta::Bool<NUMBER_OF_FUNCTIONS==0>::value> ExecutorType;
825 return ExecutorType::numberOfFunctions(gm, functionType);
829 template<
size_t NUMBER_OF_FUNCTIONS>
830 template<
class GM,
class FUNCTOR>
832 FunctionWrapper<NUMBER_OF_FUNCTIONS>::callFunctor
835 const typename GM::IndexType functionIndex,
836 const size_t functionType,
839 FunctionWrapperExecutor<
842 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
843 >::callFunctor(gm,functionIndex,functionType,functor);
847 template<
size_t NUMBER_OF_FUNCTIONS>
848 template<
class GM,
class ITERATOR>
850 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValues
854 const typename GM::IndexType functionIndex,
855 const size_t functionType
857 FunctionWrapperExecutor<
860 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
861 >::getValues(gm,iterator,functionIndex,functionType);
864 template<
size_t NUMBER_OF_FUNCTIONS>
865 template<
class GM,
class ITERATOR>
867 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValuesSwitchedOrder
871 const typename GM::IndexType functionIndex,
872 const size_t functionType
874 FunctionWrapperExecutor<
877 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
878 >::getValuesSwitchedOrder(gm,iterator,functionIndex,functionType);
881 template<
size_t NUMBER_OF_FUNCTIONS>
882 template<
class GM,
class ITERATOR>
883 inline typename GM::ValueType
884 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValue
888 const typename GM::IndexType functionIndex,
889 const size_t functionType
891 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
893 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
894 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
897 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
899 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
901 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex](iterator);
904 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
905 switch(functionType) {
907 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
909 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex](iterator);
911 return gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex](iterator);
913 return gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex](iterator);
915 return gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex](iterator);
917 return gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex](iterator);
919 return gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex](iterator);
921 return gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex](iterator);
923 return gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex](iterator);
925 return gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex](iterator);
927 return gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex](iterator);
929 return gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex](iterator);
931 return gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex](iterator);
933 return gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex](iterator);
935 return gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex](iterator);
937 return gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex](iterator);
941 return FunctionWrapperExecutor<
944 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
945 >::getValue(gm,iterator,functionIndex,functionType);
951 template<
size_t NUMBER_OF_FUNCTIONS>
952 template<
class GM,
class FUNCTOR>
954 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInAnyOrder
958 const typename GM::IndexType functionIndex,
959 const size_t functionType
961 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
963 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
964 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
967 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
969 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
971 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
974 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
975 switch(functionType) {
977 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
980 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
983 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
986 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
989 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
992 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
995 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
998 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1001 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1004 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1007 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1010 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1013 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1016 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1019 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1022 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1027 FunctionWrapperExecutor<
1029 NUMBER_OF_FUNCTIONS,
1030 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1031 >::forAllValuesInAnyOrder(gm,functor,functionIndex,functionType);
1037 template<
size_t NUMBER_OF_FUNCTIONS>
1038 template<
class GM,
class FUNCTOR>
1040 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAtLeastAllUniqueValues
1044 const typename GM::IndexType functionIndex,
1045 const size_t functionType
1047 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1049 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1050 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1053 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1055 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1057 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1060 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1061 switch(functionType) {
1063 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1066 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1069 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1072 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1075 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1078 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1081 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1084 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1087 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1090 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1093 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1096 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1099 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1102 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1105 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1108 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1113 FunctionWrapperExecutor<
1115 NUMBER_OF_FUNCTIONS,
1116 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1117 >::forAtLeastAllUniqueValues(gm,functor,functionIndex,functionType);
1122 template<
size_t NUMBER_OF_FUNCTIONS>
1123 template<
class GM,
class FUNCTOR>
1125 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInOrder
1129 const typename GM::IndexType functionIndex,
1130 const size_t functionType
1132 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1134 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1135 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1138 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1140 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1142 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1145 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1146 switch(functionType) {
1148 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1151 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1154 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1157 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1160 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1163 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1166 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1169 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1172 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1175 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1178 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1181 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1184 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1187 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1190 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1193 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1198 FunctionWrapperExecutor<
1200 NUMBER_OF_FUNCTIONS,
1201 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1202 >::forAllValuesInOrder(gm,functor,functionIndex,functionType);
1208 template<
size_t NUMBER_OF_FUNCTIONS>
1209 template<
class GM,
class FUNCTOR>
1211 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInSwitchedOrder
1215 const typename GM::IndexType functionIndex,
1216 const size_t functionType
1218 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1220 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1221 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1224 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1226 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1228 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1231 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1232 switch(functionType) {
1234 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1237 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1240 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1243 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1246 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1249 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1252 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1255 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1258 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1261 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1264 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1267 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1270 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1273 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1276 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1279 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1284 FunctionWrapperExecutor<
1286 NUMBER_OF_FUNCTIONS,
1287 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1288 >::forAllValuesInSwitchedOrder(gm,functor,functionIndex,functionType);
1294 template<
size_t NUMBER_OF_FUNCTIONS>
1295 template <
class GM,
int PROPERTY>
1297 FunctionWrapper<NUMBER_OF_FUNCTIONS>::binaryProperty
1300 const typename GM::IndexType functionIndex,
1301 const size_t functionType
1303 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1304 typedef typename GM::FunctionTypeList FTypeList;
1308 #define OPENGM_FWRAPPER_PROPERTY_GEN_MACRO( NUMBER) typedef meta::Int< NUMBER > Number; \
1309 typedef meta::Int<meta::MinimumNumber<Number::value,MaxIndex::value >::value> SaveNumber; \
1310 typedef typename meta::TypeAtTypeList<FTypeList,SaveNumber::value>::type FunctionType; \
1311 return BinaryFunctionProperties<PROPERTY, FunctionType>::op(gm-> template functions<SaveNumber::value>()[functionIndex])
1313 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(0);}
1315 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1316 if(functionType==0){OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(1);}
1317 else{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(2);}
1320 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1321 switch(functionType) {
1322 case 0 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(0);}
1323 case 1 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(1);}
1324 case 2 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(2);}
1325 case 3 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(3);}
1326 case 4 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(4);}
1327 case 5 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(5);}
1328 case 6 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(6);}
1329 case 7 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(7);}
1330 case 8 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(8);}
1331 case 9 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(9);}
1332 case 10 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(10);}
1333 case 11 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(11);}
1334 case 12 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(12);}
1335 case 13 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(13);}
1336 case 14 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(14);}
1337 case 15 :{ OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(15);}
1341 return FunctionWrapperExecutor<
1343 NUMBER_OF_FUNCTIONS,
1344 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1345 >:: template binaryProperty <GM,PROPERTY> (gm,functionIndex,functionType);
1349 #undef OPENGM_FWRAPPER_PROPERTY_GEN_MACRO
1352 template<
size_t NUMBER_OF_FUNCTIONS>
1353 template <
class GM,
int PROPERTY>
1354 inline typename GM::ValueType
1355 FunctionWrapper<NUMBER_OF_FUNCTIONS>::valueProperty
1358 const typename GM::IndexType functionIndex,
1359 const size_t functionType
1361 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1362 typedef typename GM::FunctionTypeList FTypeList;
1366 #define OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO( NUMBER) typedef meta::Int< NUMBER > Number; \
1367 typedef meta::Int<meta::MinimumNumber<Number::value,MaxIndex::value >::value> SaveNumber; \
1368 typedef typename meta::TypeAtTypeList<FTypeList,SaveNumber::value>::type FunctionType; \
1369 return ValueFunctionProperties<PROPERTY, FunctionType>::op(gm-> template functions<SaveNumber::value>()[functionIndex])
1371 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(0);}
1373 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1374 if(functionType==0){OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(1);}
1375 else{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(2);}
1378 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1379 switch(functionType) {
1380 case 0 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(0);}
1381 case 1 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(1);}
1382 case 2 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(2);}
1383 case 3 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(3);}
1384 case 4 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(4);}
1385 case 5 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(5);}
1386 case 6 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(6);}
1387 case 7 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(7);}
1388 case 8 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(8);}
1389 case 9 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(9);}
1390 case 10 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(10);}
1391 case 11 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(11);}
1392 case 12 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(12);}
1393 case 13 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(13);}
1394 case 14 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(14);}
1395 case 15 :{ OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(15);}
1399 return FunctionWrapperExecutor<
1401 NUMBER_OF_FUNCTIONS,
1402 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1403 >:: template valueProperty <GM,PROPERTY> (gm,functionIndex,functionType);
1407 #undef OPENGM_FWRAPPER_PROPERTY_GEN_MACRO
1416 #endif // #ifndef OPENGM_GRAPHICALMODEL_FUNCTION_WRAPPER_HXX