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 {
43 template<
bool IN_LIST>
44 struct MaybeCopyFunctionVector;
47 struct MaybeCopyFunctionVector<true>{
49 template<
class FVEC,
class GM_T,
class SRC_FID_TO_TARGET>
51 const FVEC & functionsS,
53 SRC_FID_TO_TARGET & srcFidToTarget,
57 typedef typename GM_T::FunctionTypeList TargetList;
58 typedef opengm::meta::GetIndexInTypeList<TargetList,typename FVEC::value_type> IndexGetter;
60 srcFidToTarget[indexInSource] = IndexGetter::value;
61 gmT.
template functions<IndexGetter::value>() = functionsS;
66 struct MaybeCopyFunctionVector<false>{
68 template<
class FVEC,
class GM_T,
class SRC_FID_TO_TARGET>
70 const FVEC & functionsS,
72 SRC_FID_TO_TARGET & srcFidToTarget,
75 srcFidToTarget[indexInSource] = -1;
76 OPENGM_CHECK_OP(functionsS.size(),==,0,
"incompatible functions must have zero size");
81 template<
size_t I,
size_t DX>
84 template<
class GM_S,
class GM_T,
class SRC_FID_TO_TARGET>
88 SRC_FID_TO_TARGET & srcFidToTarget
91 typedef typename GM_S::FunctionTypeList SourceList;
92 typedef typename GM_T::FunctionTypeList TargetList;
93 typedef typename opengm::meta::TypeAtTypeList<SourceList, I>::type FType;
95 const std::vector<FType> & functions = gmS.
template functions<I>();
97 typedef MaybeCopyFunctionVector<opengm::meta::HasTypeInTypeList<TargetList, FType>::value > CopyFVec;
98 CopyFVec::op(functions, gmT, srcFidToTarget, I);
100 CopyFunctions<I+1, DX>::op(gmS,gmT,srcFidToTarget);
104 struct CopyFunctions<DX,DX>{
106 template<
class GM_S,
class GM_T,
class SRC_FID_TO_TARGET>
110 SRC_FID_TO_TARGET & srcFidToTarget
121 #define OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO( RETURN_TYPE , FUNCTION_NAME ) \ 122 template<size_t NUMBER_OF_FUNCTIONS> \ 125 FunctionWrapper<NUMBER_OF_FUNCTIONS>::FUNCTION_NAME \ 128 const size_t functionIndex, \ 129 const size_t functionType \ 131 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex; \ 132 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) { \ 133 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 135 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) { \ 136 if(functionType==0) \ 137 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 139 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 141 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) { \ 142 switch(functionType) { \ 144 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 146 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 148 return gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 150 return gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 152 return gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 154 return gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 156 return gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 158 return gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 160 return gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 162 return gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 164 return gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 166 return gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 168 return gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 170 return gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 172 return gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 174 return gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].FUNCTION_NAME(); \ 176 return FunctionWrapperExecutor< \ 178 NUMBER_OF_FUNCTIONS, \ 179 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value \ 180 >::FUNCTION_NAME(gm,functionIndex,functionType); \ 184 template<size_t IX, size_t DX> \ 186 RETURN_TYPE FunctionWrapperExecutor<IX, DX, false>::FUNCTION_NAME \ 189 const size_t functionIndex, \ 190 const size_t functionType \ 192 if(functionType==IX) { \ 193 return gm->template functions<IX>()[functionIndex].FUNCTION_NAME(); \ 196 return FunctionWrapperExecutor<IX+1, DX, meta::Bool<IX+1==DX>::value >::FUNCTION_NAME (gm, functionIndex,functionType); \ 199 template<size_t IX, size_t DX> \ 201 RETURN_TYPE FunctionWrapperExecutor<IX, DX, true>::FUNCTION_NAME \ 204 const size_t functionIndex, \ 205 const size_t functionType \ 207 throw RuntimeError("Incorrect function type id."); \ 210 template<
size_t IX,
size_t DX,
bool end>
211 struct FunctionWrapperExecutor;
213 template<
size_t IX,
size_t DX>
214 struct FunctionWrapperExecutor<IX,DX,false>{
216 template <
class GM,
class FUNCTOR>
217 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
220 template <
class GM,
class ITERATOR>
221 static void getValues(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
222 template <
class GM,
class ITERATOR>
223 static void getValuesSwitchedOrder(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
224 template <
class GM,
class ITERATOR>
225 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
226 template <
class GM,
class FUNCTOR>
227 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
228 template <
class GM,
class FUNCTOR>
229 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
230 template <
class GM,
class FUNCTOR>
231 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
232 template <
class GM,
class FUNCTOR>
233 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
234 template <
class GM,
int PROPERTY>
235 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
236 template <
class GM,
int PROPERTY>
237 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
239 static size_t numberOfFunctions(
const GM *,
const size_t );
240 template <
class GM_SOURCE,
class GM_DEST>
241 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
243 static bool isPotts(GM
const *,
const size_t ,
const size_t);
245 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
247 static bool isSubmodular(GM
const *,
const size_t ,
const size_t);
249 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
251 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
253 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
255 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
257 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
259 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
261 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
263 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
265 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
268 template<
size_t IX,
size_t DX>
269 struct FunctionWrapperExecutor<IX,DX,true>{
271 template <
class GM,
class FUNCTOR>
272 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
274 template <
class GM,
class ITERATOR>
275 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
276 template <
class GM,
class ITERATOR>
277 static void getValues(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
278 template <
class GM,
class ITERATOR>
279 static void getValuesSwitchedOrder(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
280 template <
class GM,
class FUNCTOR>
281 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
282 template <
class GM,
class FUNCTOR>
283 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
284 template <
class GM,
class FUNCTOR>
285 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
286 template <
class GM,
class FUNCTOR>
287 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
288 template <
class GM,
int PROPERTY>
289 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
290 template <
class GM,
int PROPERTY>
291 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
293 static size_t numberOfFunctions(
const GM *,
const size_t functionTypeIndex);
294 template <
class GM_SOURCE,
class GM_DEST>
295 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
297 static bool isPotts(GM
const *,
const size_t ,
const size_t);
299 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
301 static bool isSubmodular(GM
const *,
const size_t,
const size_t );
303 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
305 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
307 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
309 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
311 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
313 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
315 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
317 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
319 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
322 template<
size_t NUMBER_OF_FUNCTIONS>
323 struct FunctionWrapper{
325 template <
class GM,
class FUNCTOR>
326 static void callFunctor(
const GM *,
const typename GM::IndexType ,
const size_t ,FUNCTOR & functor);
328 template <
class GM,
class OUT_ITERATOR>
329 static void getValues(
const GM *,OUT_ITERATOR,
const typename GM::IndexType ,
const size_t );
330 template <
class GM,
class OUT_ITERATOR>
331 static void getValuesSwitchedOrder(
const GM *,OUT_ITERATOR,
const typename GM::IndexType ,
const size_t );
332 template <
class GM,
class ITERATOR>
333 static typename GM::ValueType getValue(
const GM *,ITERATOR,
const typename GM::IndexType ,
const size_t );
334 template <
class GM,
class FUNCTOR>
335 static void forAllValuesInAnyOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
336 template <
class GM,
class FUNCTOR>
337 static void forAtLeastAllUniqueValues(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
338 template <
class GM,
class FUNCTOR>
339 static void forAllValuesInOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
340 template <
class GM,
class FUNCTOR>
341 static void forAllValuesInSwitchedOrder(
const GM *,FUNCTOR &,
const typename GM::IndexType ,
const size_t );
342 template <
class GM,
int PROPERTY>
343 static bool binaryProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
344 template <
class GM,
int PROPERTY>
345 static typename GM::ValueType valueProperty(
const GM *,
const typename GM::IndexType ,
const size_t );
347 static size_t numberOfFunctions(
const GM *,
const size_t functionTypeIndex);
348 template <
class GM_SOURCE,
class GM_DEST>
349 static void assignFunctions(
const GM_SOURCE & ,GM_DEST &);
351 static bool isPotts(GM
const *,
const size_t,
const size_t);
353 static bool isGeneralizedPotts(GM
const *,
const size_t ,
const size_t);
355 static bool isSubmodular(GM
const *,
const size_t ,
const size_t);
357 static typename GM::ValueType min(GM
const *,
const size_t ,
const size_t);
359 static typename GM::ValueType max(GM
const *,
const size_t ,
const size_t);
361 static typename GM::ValueType sum(GM
const *,
const size_t ,
const size_t);
363 static typename GM::ValueType product(GM
const *,
const size_t ,
const size_t);
365 static bool isSquaredDifference(GM
const *,
const size_t ,
const size_t);
367 static bool isTruncatedSquaredDifference(GM
const *,
const size_t ,
const size_t);
369 static bool isAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
371 static bool isTruncatedAbsoluteDifference(GM
const *,
const size_t ,
const size_t);
373 static bool isLinearConstraint(GM
const *,
const size_t ,
const size_t);
378 namespace detail_graphical_model {
379 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isSubmodular)
380 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isPotts)
381 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isGeneralizedPotts)
382 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isSquaredDifference)
383 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isTruncatedSquaredDifference)
384 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isAbsoluteDifference)
385 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isTruncatedAbsoluteDifference)
386 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
bool, isLinearConstraint)
387 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, min)
388 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, max)
389 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, sum)
390 OPENGM_BASIC_FUNCTION_WRAPPER_CODE_GENERATOR_MACRO(
typename GM::ValueType, product)
392 template<
size_t IX,
size_t DX>
393 template<
class GM,
class ITERATOR>
394 inline typename GM::ValueType
395 FunctionWrapperExecutor<IX,DX,false>::getValue
399 const typename GM::IndexType functionIndex,
400 const size_t functionType
402 if(IX==functionType) {
403 return gm->
template functions<IX>()[functionIndex](iterator);
406 return FunctionWrapperExecutor<
407 meta::Increment<IX>::value,
410 meta::Increment<IX>::value,
413 >::getValue(gm,iterator,functionIndex,functionType);
417 template<
size_t IX,
size_t DX>
418 template <
class GM,
class FUNCTOR>
420 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInAnyOrder
424 const typename GM::IndexType functionIndex,
425 const size_t functionType
427 if(IX==functionType) {
428 gm->
template functions<IX>()[functionIndex].forAllValuesInAnyOrder(functor);
431 FunctionWrapperExecutor<
432 meta::Increment<IX>::value,
435 meta::Increment<IX>::value,
438 >::forAllValuesInAnyOrder(gm,functor,functionIndex,functionType);
442 template<
size_t IX,
size_t DX>
443 template <
class GM,
class FUNCTOR>
445 FunctionWrapperExecutor<IX,DX,false>::forAtLeastAllUniqueValues
449 const typename GM::IndexType functionIndex,
450 const size_t functionType
452 if(IX==functionType) {
453 gm->
template functions<IX>()[functionIndex].forAtLeastAllUniqueValues(functor);
456 FunctionWrapperExecutor<
457 meta::Increment<IX>::value,
460 meta::Increment<IX>::value,
463 >::forAtLeastAllUniqueValues(gm,functor,functionIndex,functionType);
467 template<
size_t IX,
size_t DX>
468 template <
class GM,
class FUNCTOR>
470 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInOrder
474 const typename GM::IndexType functionIndex,
475 const size_t functionType
477 if(IX==functionType) {
478 gm->
template functions<IX>()[functionIndex].forAllValuesInOrder(functor);
481 FunctionWrapperExecutor<
482 meta::Increment<IX>::value,
485 meta::Increment<IX>::value,
488 >::forAllValuesInOrder(gm,functor,functionIndex,functionType);
492 template<
size_t IX,
size_t DX>
493 template <
class GM,
class FUNCTOR>
495 FunctionWrapperExecutor<IX,DX,false>::forAllValuesInSwitchedOrder
499 const typename GM::IndexType functionIndex,
500 const size_t functionType
502 if(IX==functionType) {
503 gm->
template functions<IX>()[functionIndex].forAllValuesInSwitchedOrder(functor);
506 FunctionWrapperExecutor<
507 meta::Increment<IX>::value,
510 meta::Increment<IX>::value,
513 >::forAllValuesInSwitchedOrder(gm,functor,functionIndex,functionType);
518 template<
size_t IX,
size_t DX>
519 template <
class GM,
int PROPERTY>
521 FunctionWrapperExecutor<IX,DX,false>::binaryProperty
524 const typename GM::IndexType functionIndex,
525 const size_t functionType
527 if(IX==functionType) {
528 typedef typename GM::FunctionTypeList FTypeList;
529 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
530 return BinaryFunctionProperties<PROPERTY, FunctionType>::op(gm->
template functions<IX>()[functionIndex]);
533 return FunctionWrapperExecutor<
534 meta::Increment<IX>::value,
537 meta::Increment<IX>::value,
540 >:: template binaryProperty<GM,PROPERTY>(gm,functionIndex,functionType);
544 template<
size_t IX,
size_t DX>
545 template <
class GM,
int PROPERTY>
546 inline typename GM::ValueType
547 FunctionWrapperExecutor<IX,DX,false>::valueProperty
550 const typename GM::IndexType functionIndex,
551 const size_t functionType
553 if(IX==functionType) {
554 typedef typename GM::FunctionTypeList FTypeList;
555 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
556 return ValueFunctionProperties<PROPERTY, FunctionType>::op(gm->
template functions<IX>()[functionIndex]);
559 return FunctionWrapperExecutor<
560 meta::Increment<IX>::value,
563 meta::Increment<IX>::value,
566 >:: template valueProperty<GM,PROPERTY>(gm,functionIndex,functionType);
570 template<
size_t IX,
size_t DX>
571 template<
class GM,
class FUNCTOR>
573 FunctionWrapperExecutor<IX,DX,false>::callFunctor
576 const typename GM::IndexType functionIndex,
577 const size_t functionType,
580 if(IX==functionType) {
582 typedef typename GM::FunctionTypeList FTypeList;
583 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
584 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
586 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
591 return FunctionWrapperExecutor<
592 meta::Increment<IX>::value,
595 meta::Increment<IX>::value,
598 >::callFunctor(gm,functionIndex,functionType,functor);
603 template<
size_t IX,
size_t DX>
604 template<
class GM,
class ITERATOR>
606 FunctionWrapperExecutor<IX,DX,false>::getValues
610 const typename GM::IndexType functionIndex,
611 const size_t functionType
613 if(IX==functionType) {
615 typedef typename GM::FunctionTypeList FTypeList;
616 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
617 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
619 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
620 ShapeWalker< FunctionShapeIteratorType > walker(
function.functionShapeBegin(),
function.dimension());
621 for (
size_t i = 0; i <
function.size(); ++i) {
622 *iterator =
function(walker.coordinateTuple().begin());
629 return FunctionWrapperExecutor<
630 meta::Increment<IX>::value,
633 meta::Increment<IX>::value,
636 >::getValues(gm,iterator,functionIndex,functionType);
640 template<
size_t IX,
size_t DX>
641 template<
class GM,
class ITERATOR>
643 FunctionWrapperExecutor<IX,DX,false>::getValuesSwitchedOrder
647 const typename GM::IndexType functionIndex,
648 const size_t functionType
650 if(IX==functionType) {
652 typedef typename GM::FunctionTypeList FTypeList;
653 typedef typename meta::TypeAtTypeList<FTypeList,IX>::type FunctionType;
654 typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType;
656 const FunctionType &
function = gm->
template functions<IX>()[functionIndex];
657 ShapeWalkerSwitchedOrder< FunctionShapeIteratorType > walker(
function.functionShapeBegin(),
function.dimension());
658 for (
size_t i = 0; i <
function.size(); ++i) {
659 *iterator =
function(walker.coordinateTuple().begin());
666 return FunctionWrapperExecutor<
667 meta::Increment<IX>::value,
670 meta::Increment<IX>::value,
673 >::getValuesSwitchedOrder(gm,iterator,functionIndex,functionType);
677 template<
size_t IX,
size_t DX>
678 template<
class GM,
class ITERATOR>
680 FunctionWrapperExecutor<IX,DX,true>::getValues
684 const typename GM::IndexType functionIndex,
685 const size_t functionType
687 throw RuntimeError(
"Incorrect function type id.");
689 template<
size_t IX,
size_t DX>
690 template<
class GM,
class ITERATOR>
692 FunctionWrapperExecutor<IX,DX,true>::getValuesSwitchedOrder
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,
class FUNCTOR>
705 FunctionWrapperExecutor<IX,DX,true>::callFunctor
708 const typename GM::IndexType functionIndex,
709 const size_t functionType,
712 throw RuntimeError(
"Incorrect function type id.");
715 template<
size_t IX,
size_t DX>
716 template<
class GM,
class ITERATOR>
717 inline typename GM::ValueType
718 FunctionWrapperExecutor<IX,DX,true>::getValue
722 const typename GM::IndexType functionIndex,
723 const size_t functionType
725 throw RuntimeError(
"Incorrect function type id.");
726 return typename GM::ValueType();
729 template<
size_t IX,
size_t DX>
730 template <
class GM,
class FUNCTOR>
732 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInAnyOrder
736 const typename GM::IndexType functionIndex,
737 const size_t functionType
739 throw RuntimeError(
"Incorrect function type id.");
742 template<
size_t IX,
size_t DX>
743 template <
class GM,
class FUNCTOR>
745 FunctionWrapperExecutor<IX,DX,true>::forAtLeastAllUniqueValues
749 const typename GM::IndexType functionIndex,
750 const size_t functionType
752 throw RuntimeError(
"Incorrect function type id.");
755 template<
size_t IX,
size_t DX>
756 template <
class GM,
class FUNCTOR>
758 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInOrder
762 const typename GM::IndexType functionIndex,
763 const size_t functionType
765 throw RuntimeError(
"Incorrect function type id.");
768 template<
size_t IX,
size_t DX>
769 template <
class GM,
class FUNCTOR>
771 FunctionWrapperExecutor<IX,DX,true>::forAllValuesInSwitchedOrder
775 const typename GM::IndexType functionIndex,
776 const size_t functionType
778 throw RuntimeError(
"Incorrect function type id.");
781 template<
size_t IX,
size_t DX>
782 template <
class GM,
int PROPERTY>
784 FunctionWrapperExecutor<IX,DX,true>::binaryProperty
787 const typename GM::IndexType functionIndex,
788 const size_t functionType
790 throw RuntimeError(
"Incorrect function type id.");
794 template<
size_t IX,
size_t DX>
795 template <
class GM,
int PROPERTY>
796 inline typename GM::ValueType
797 FunctionWrapperExecutor<IX,DX,true>::valueProperty
800 const typename GM::IndexType functionIndex,
801 const size_t functionType
803 throw RuntimeError(
"Incorrect function type id.");
807 template<
size_t IX,
size_t DX>
810 FunctionWrapperExecutor<IX,DX,false>::numberOfFunctions
813 const size_t functionType
815 if(IX==functionType) {
816 return gm->template functions<IX>().size();
819 return FunctionWrapperExecutor<
820 meta::Increment<IX>::value,
823 meta::Increment<IX>::value,
826 >::numberOfFunctions(gm,functionType);
830 template<
size_t IX,
size_t DX>
833 FunctionWrapperExecutor<IX,DX,true>::numberOfFunctions
836 const size_t functionType
838 throw RuntimeError(
"Incorrect function type id.");
841 template<
size_t IX,
size_t DX>
842 template<
class GM_SOURCE,
class GM_DEST>
844 FunctionWrapperExecutor<IX,DX,false>::assignFunctions
846 const GM_SOURCE & gmSource,
849 typedef typename meta::TypeAtTypeList<
850 typename GM_SOURCE::FunctionTypeList ,
852 >::type SourceTypeAtIX;
854 meta::GetIndexInTypeList<
855 typename GM_DEST::FunctionTypeList,
858 > PositionOfSourceTypeInDestType;
859 gmDest.template functions<PositionOfSourceTypeInDestType::value> () =
860 gmSource.template functions<IX> ();
863 FunctionWrapperExecutor<
864 meta::Increment<IX>::value,
867 meta::Increment<IX>::value,
870 >::assignFunctions(gmSource,gmDest);
873 template<
size_t IX,
size_t DX>
874 template<
class GM_SOURCE,
class GM_DEST>
876 FunctionWrapperExecutor<IX,DX,true>::assignFunctions
878 const GM_SOURCE & gmSource,
883 template<
size_t NUMBER_OF_FUNCTIONS>
884 template<
class GM_SOURCE,
class GM_DEST>
886 FunctionWrapper<NUMBER_OF_FUNCTIONS>::assignFunctions
888 const GM_SOURCE & gmSource,
891 typedef FunctionWrapperExecutor<0, NUMBER_OF_FUNCTIONS, meta::Bool<NUMBER_OF_FUNCTIONS==0>::value> ExecutorType;
892 return ExecutorType::assignFunctions(gmSource, gmDest);
895 template<
size_t NUMBER_OF_FUNCTIONS>
898 FunctionWrapper<NUMBER_OF_FUNCTIONS>::numberOfFunctions
901 const size_t functionType
903 typedef FunctionWrapperExecutor<0, NUMBER_OF_FUNCTIONS, meta::Bool<NUMBER_OF_FUNCTIONS==0>::value> ExecutorType;
904 return ExecutorType::numberOfFunctions(gm, functionType);
908 template<
size_t NUMBER_OF_FUNCTIONS>
909 template<
class GM,
class FUNCTOR>
911 FunctionWrapper<NUMBER_OF_FUNCTIONS>::callFunctor
914 const typename GM::IndexType functionIndex,
915 const size_t functionType,
918 FunctionWrapperExecutor<
921 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
922 >::callFunctor(gm,functionIndex,functionType,functor);
926 template<
size_t NUMBER_OF_FUNCTIONS>
927 template<
class GM,
class ITERATOR>
929 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValues
933 const typename GM::IndexType functionIndex,
934 const size_t functionType
936 FunctionWrapperExecutor<
939 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
940 >::getValues(gm,iterator,functionIndex,functionType);
943 template<
size_t NUMBER_OF_FUNCTIONS>
944 template<
class GM,
class ITERATOR>
946 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValuesSwitchedOrder
950 const typename GM::IndexType functionIndex,
951 const size_t functionType
953 FunctionWrapperExecutor<
956 opengm::meta::BiggerOrEqualNumber<0,NUMBER_OF_FUNCTIONS>::value
957 >::getValuesSwitchedOrder(gm,iterator,functionIndex,functionType);
960 template<
size_t NUMBER_OF_FUNCTIONS>
961 template<
class GM,
class ITERATOR>
962 inline typename GM::ValueType
963 FunctionWrapper<NUMBER_OF_FUNCTIONS>::getValue
967 const typename GM::IndexType functionIndex,
968 const size_t functionType
970 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
972 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
973 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
976 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
978 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
980 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex](iterator);
983 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
984 switch(functionType) {
986 return gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex](iterator);
988 return gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex](iterator);
990 return gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex](iterator);
992 return gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex](iterator);
994 return gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex](iterator);
996 return gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex](iterator);
998 return gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex](iterator);
1000 return gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex](iterator);
1002 return gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex](iterator);
1004 return gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex](iterator);
1006 return gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex](iterator);
1008 return gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex](iterator);
1010 return gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex](iterator);
1012 return gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex](iterator);
1014 return gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex](iterator);
1016 return gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex](iterator);
1020 return FunctionWrapperExecutor<
1022 NUMBER_OF_FUNCTIONS,
1023 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1024 >::getValue(gm,iterator,functionIndex,functionType);
1030 template<
size_t NUMBER_OF_FUNCTIONS>
1031 template<
class GM,
class FUNCTOR>
1033 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInAnyOrder
1037 const typename GM::IndexType functionIndex,
1038 const size_t functionType
1040 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1042 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1043 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1046 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1048 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1050 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1053 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1054 switch(functionType) {
1056 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1059 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1062 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1065 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1068 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1071 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1074 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1077 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1080 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1083 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1086 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1089 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1092 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1095 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1098 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1101 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInAnyOrder(functor);
1106 FunctionWrapperExecutor<
1108 NUMBER_OF_FUNCTIONS,
1109 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1110 >::forAllValuesInAnyOrder(gm,functor,functionIndex,functionType);
1116 template<
size_t NUMBER_OF_FUNCTIONS>
1117 template<
class GM,
class FUNCTOR>
1119 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAtLeastAllUniqueValues
1123 const typename GM::IndexType functionIndex,
1124 const size_t functionType
1126 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1128 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1129 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1132 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1134 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1136 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1139 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1140 switch(functionType) {
1142 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1145 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1148 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1151 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1154 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1157 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1160 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1163 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1166 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1169 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1172 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1175 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1178 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1181 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1184 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1187 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAtLeastAllUniqueValues(functor);
1192 FunctionWrapperExecutor<
1194 NUMBER_OF_FUNCTIONS,
1195 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1196 >::forAtLeastAllUniqueValues(gm,functor,functionIndex,functionType);
1201 template<
size_t NUMBER_OF_FUNCTIONS>
1202 template<
class GM,
class FUNCTOR>
1204 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInOrder
1208 const typename GM::IndexType functionIndex,
1209 const size_t functionType
1211 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1213 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1214 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1217 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1219 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1221 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1224 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1225 switch(functionType) {
1227 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1230 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1233 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1236 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1239 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1242 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1245 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1248 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1251 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1254 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1257 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1260 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1263 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1266 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1269 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1272 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInOrder(functor);
1277 FunctionWrapperExecutor<
1279 NUMBER_OF_FUNCTIONS,
1280 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1281 >::forAllValuesInOrder(gm,functor,functionIndex,functionType);
1287 template<
size_t NUMBER_OF_FUNCTIONS>
1288 template<
class GM,
class FUNCTOR>
1290 FunctionWrapper<NUMBER_OF_FUNCTIONS>::forAllValuesInSwitchedOrder
1294 const typename GM::IndexType functionIndex,
1295 const size_t functionType
1297 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1299 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {
1300 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1303 else if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1305 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1307 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1310 else if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1311 switch(functionType) {
1313 gm->template functions<meta::MinimumNumber<0,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1316 gm->template functions<meta::MinimumNumber<1,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1319 gm->template functions<meta::MinimumNumber<2,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1322 gm->template functions<meta::MinimumNumber<3,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1325 gm->template functions<meta::MinimumNumber<4,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1328 gm->template functions<meta::MinimumNumber<5,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1331 gm->template functions<meta::MinimumNumber<6,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1334 gm->template functions<meta::MinimumNumber<7,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1337 gm->template functions<meta::MinimumNumber<8,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1340 gm->template functions<meta::MinimumNumber<9,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1343 gm->template functions<meta::MinimumNumber<10,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1346 gm->template functions<meta::MinimumNumber<11,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1349 gm->template functions<meta::MinimumNumber<12,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1352 gm->template functions<meta::MinimumNumber<13,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1355 gm->template functions<meta::MinimumNumber<14,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1358 gm->template functions<meta::MinimumNumber<15,MaxIndex::value >::value >()[functionIndex].forAllValuesInSwitchedOrder(functor);
1363 FunctionWrapperExecutor<
1365 NUMBER_OF_FUNCTIONS,
1366 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1367 >::forAllValuesInSwitchedOrder(gm,functor,functionIndex,functionType);
1373 template<
size_t NUMBER_OF_FUNCTIONS>
1374 template <
class GM,
int PROPERTY>
1376 FunctionWrapper<NUMBER_OF_FUNCTIONS>::binaryProperty
1379 const typename GM::IndexType functionIndex,
1380 const size_t functionType
1382 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1383 typedef typename GM::FunctionTypeList FTypeList;
1387 #define OPENGM_FWRAPPER_PROPERTY_GEN_MACRO( NUMBER) typedef meta::Int< NUMBER > Number; \ 1388 typedef meta::Int<meta::MinimumNumber<Number::value,MaxIndex::value >::value> SaveNumber; \ 1389 typedef typename meta::TypeAtTypeList<FTypeList,SaveNumber::value>::type FunctionType; \ 1390 return BinaryFunctionProperties<PROPERTY, FunctionType>::op(gm-> template functions<SaveNumber::value>()[functionIndex]) 1392 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(0);}
1394 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1395 if(functionType==0){OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(1);}
1396 else{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(2);}
1399 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1400 switch(functionType) {
1401 case 0 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(0);}
1402 case 1 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(1);}
1403 case 2 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(2);}
1404 case 3 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(3);}
1405 case 4 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(4);}
1406 case 5 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(5);}
1407 case 6 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(6);}
1408 case 7 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(7);}
1409 case 8 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(8);}
1410 case 9 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(9);}
1411 case 10 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(10);}
1412 case 11 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(11);}
1413 case 12 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(12);}
1414 case 13 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(13);}
1415 case 14 :{OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(14);}
1416 case 15 :{ OPENGM_FWRAPPER_PROPERTY_GEN_MACRO(15);}
1420 return FunctionWrapperExecutor<
1422 NUMBER_OF_FUNCTIONS,
1423 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1424 >:: template binaryProperty <GM,PROPERTY> (gm,functionIndex,functionType);
1428 #undef OPENGM_FWRAPPER_PROPERTY_GEN_MACRO 1431 template<
size_t NUMBER_OF_FUNCTIONS>
1432 template <
class GM,
int PROPERTY>
1433 inline typename GM::ValueType
1434 FunctionWrapper<NUMBER_OF_FUNCTIONS>::valueProperty
1437 const typename GM::IndexType functionIndex,
1438 const size_t functionType
1440 typedef typename opengm::meta::SizeT< opengm::meta::Decrement<NUMBER_OF_FUNCTIONS>::value > MaxIndex;
1441 typedef typename GM::FunctionTypeList FTypeList;
1445 #define OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO( NUMBER) typedef meta::Int< NUMBER > Number; \ 1446 typedef meta::Int<meta::MinimumNumber<Number::value,MaxIndex::value >::value> SaveNumber; \ 1447 typedef typename meta::TypeAtTypeList<FTypeList,SaveNumber::value>::type FunctionType; \ 1448 return ValueFunctionProperties<PROPERTY, FunctionType>::op(gm-> template functions<SaveNumber::value>()[functionIndex]) 1450 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,1>::value) {OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(0);}
1452 if(meta::EqualNumber<NUMBER_OF_FUNCTIONS,2>::value) {
1453 if(functionType==0){OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(1);}
1454 else{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(2);}
1457 if(meta::BiggerOrEqualNumber<NUMBER_OF_FUNCTIONS,3>::value) {
1458 switch(functionType) {
1459 case 0 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(0);}
1460 case 1 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(1);}
1461 case 2 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(2);}
1462 case 3 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(3);}
1463 case 4 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(4);}
1464 case 5 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(5);}
1465 case 6 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(6);}
1466 case 7 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(7);}
1467 case 8 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(8);}
1468 case 9 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(9);}
1469 case 10 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(10);}
1470 case 11 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(11);}
1471 case 12 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(12);}
1472 case 13 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(13);}
1473 case 14 :{OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(14);}
1474 case 15 :{ OPENGM_FWRAPPER_VALUE_PROPERTY_GEN_MACRO(15);}
1478 return FunctionWrapperExecutor<
1480 NUMBER_OF_FUNCTIONS,
1481 opengm::meta::BiggerOrEqualNumber<16,NUMBER_OF_FUNCTIONS >::value
1482 >:: template valueProperty <GM,PROPERTY> (gm,functionIndex,functionType);
1486 #undef OPENGM_FWRAPPER_PROPERTY_GEN_MACRO 1495 #endif // #ifndef OPENGM_GRAPHICALMODEL_FUNCTION_WRAPPER_HXX
#define OPENGM_CHECK_OP(A, OP, B, TXT)