normalize.hxx
Go to the documentation of this file.00001 #pragma once
00002 #ifndef OPENGM_OPERATION_NORMALIZE_HXX
00003 #define OPENGM_OPERATION_NORMALIZE_HXX
00004
00005 #include <typeinfo>
00006
00007 #include "opengm/opengm.hxx"
00008 #include "opengm/operations/multiplier.hxx"
00009
00010 namespace opengm
00011 {
00012
00014 struct Normalization {
00015 template<class ACC, class OP, class T>
00016 static void normalize(T& out) {
00017 typename T::ValueType v;
00018 out.template accumulate<ACC>(v);
00019 if(typeid(OP) == typeid(opengm::Multiplier) && v <= 0.00001) {
00020 return;
00021 }
00022 if(typeid(OP) == typeid(opengm::Multiplier)) {
00023 OPENGM_ASSERT(v > 0.00001);
00024 }
00025 OP::iop(v,out);
00026 }
00027 };
00028
00029 }
00030
00031 #endif // #ifndef OPENGM_OPERATION_NORMAIZE_HXX