OpenGM  2.3.x
Discrete Graphical Model Library
minimizer.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_OPERATIONS_MINIMIZER_HXX
3 #define OPENGM_OPERATIONS_MINIMIZER_HXX
4 
5 #include <limits>
6 
7 namespace opengm {
8 
12 struct Minimizer
13 {
15  template<class T>
16  static T neutral()
17  { return std::numeric_limits<T>::infinity(); }
19  template<class T>
20  static void neutral(T& out)
21  { out = std::numeric_limits<T>::infinity(); }
22 
24  template<class T>
25  static T ineutral()
26  { return -std::numeric_limits<T>::infinity(); }
28  template<class T>
29  static void ineutral(T& out)
30  { out = -std::numeric_limits<T>::infinity(); }
31 
33  template<class T1, class T2>
34  static void op(const T1& in1, T2& out)
35  { out = out < in1 ? out : in1; }
37  template<class T1,class T2,class T3>
38  static void op(const T1& in1, const T2& in2, T3& out)
39  { out = in1 < in2 ? in1 : in2; }
40 
42  template<class T1, class T2>
43  static void iop(const T1& in1, T2& out)
44  { out = out > in1 ? out : in1; }
46  template<class T1,class T2,class T3>
47  static void iop(const T1& in1, const T2& in2, T3& out)
48  { out = in1 > in2 ? in1:in2; }
49 
51  static bool hasbop()
52  {return true;}
53 
55  template<class T>
56  static bool bop(const T& in1, const T& in2)
57  { return (in1 < in2); }
58 
60  template<class T>
61  static bool ibop(const T& in1, const T& in2)
62  { return (in1 > in2); }
63 };
64 
65 } // namespace opengm
66 
67 #endif // #ifndef OPENGM_OPERATIONS_MINIMIZER_HXX
static void op(const T1 &in1, T2 &out)
operation (in-place)
Definition: minimizer.hxx:34
The OpenGM namespace.
Definition: config.hxx:43
static void iop(const T1 &in1, const T2 &in2, T3 &out)
inverse operation (not in-place)
Definition: minimizer.hxx:47
static void op(const T1 &in1, const T2 &in2, T3 &out)
operation (not in-place)
Definition: minimizer.hxx:38
static bool hasbop()
bool operation flag
Definition: minimizer.hxx:51
static bool bop(const T &in1, const T &in2)
boolean operation
Definition: minimizer.hxx:56
static void ineutral(T &out)
inverse neutral element (call by reference)
Definition: minimizer.hxx:29
static void neutral(T &out)
neutral element (call by reference)
Definition: minimizer.hxx:20
static T ineutral()
inverse neutral element (with return)
Definition: minimizer.hxx:25
static T neutral()
neutral element (with return)
Definition: minimizer.hxx:16
static bool ibop(const T &in1, const T &in2)
inverse boolean operation
Definition: minimizer.hxx:61
static void iop(const T1 &in1, T2 &out)
inverse operation (in-place)
Definition: minimizer.hxx:43
Minimization as a unary accumulation.
Definition: minimizer.hxx:12