OpenGM  2.3.x
Discrete Graphical Model Library
normalize.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_OPERATION_NORMALIZE_HXX
3 #define OPENGM_OPERATION_NORMALIZE_HXX
4 
5 #include <typeinfo>
6 
7 #include "opengm/opengm.hxx"
9 
10 namespace opengm
11 {
12 
14 struct Normalization {
15  template<class ACC, class OP, class T>
16  static void normalize(T& out) {
17  typename T::ValueType v;
18  out.template accumulate<ACC>(v);
19  if(typeid(OP) == typeid(opengm::Multiplier) && v <= 0.00001) {
20  return;
21  }
22  if(typeid(OP) == typeid(opengm::Multiplier)) {
23  OPENGM_ASSERT(v > 0.00001);
24  }
25  OP::iop(v,out);
26  }
27 };
28 
29 } // namespace opengm
30 
31 #endif // #ifndef OPENGM_OPERATION_NORMAIZE_HXX
The OpenGM namespace.
Definition: config.hxx:43
Multiplication as a binary operation.
Definition: multiplier.hxx:12
Normalization w.r.t. a binary operation (e.g. Multiplier) and a unary accumulation (e...
Definition: normalize.hxx:14
#define OPENGM_ASSERT(expression)
Definition: opengm.hxx:77
static void normalize(T &out)
Definition: normalize.hxx:16