OpenGM  2.3.x
Discrete Graphical Model Library
adder.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_OPERATION_ADDER_HXX
3 #define OPENGM_OPERATION_ADDER_HXX
4 
5 namespace opengm {
6 
10 struct Adder
11 {
13  template<class T>
14  static T neutral()
15  { return static_cast<T>(0); }
16 
18  template<class T>
19  static void neutral(T& out)
20  { out = static_cast<T>(0); }
21 
23  template<class T>
24  static T ineutral()
25  { return static_cast<T>(0); }
26 
28  template<class T>
29  static void ineutral(T& out)
30  { out = static_cast<T>(0); }
31 
33  template<class T1, class T2>
34  static void op(const T1& in, T2& out)
35  { out += in; }
36 
38  template<class T1,class T2,class T3>
39  static void op(const T1& in1, const T2& in2, T3& out)
40  { out = in1 + in2; }
41 
43  template<class T1, class T2>
44  static void iop(const T1& in, T2& out)
45  { out -= in; }
46 
48  template<class T1,class T2,class T3>
49  static void iop(const T1& in1, const T2& in2, T3& out)
50  { out = in1 - in2; }
51 
53  static bool hasbop()
54  { return false; }
55 
57  template<class T1, class T2>
58  static void hop(const T1& in, T2& out)
59  { out *= in; }
60 
62  template<class T1,class T2, class T3>
63  static void hop(const T1& in1, const T2& in2, T3& out)
64  { out = in1 * in2; }
65 
67  template<class T1,class T2>
68  static void ihop(const T1& in, T2& out)
69  { out /= in; }
70 
72  template<class T1, class T2, class T3>
73  static void ihop(const T1& in1, const T2& in2, T3& out)
74  { out = in1 / in2; }
75 };
76 
77 } // namespace opengm
78 
79 #endif // #ifndef OPENGM_OPERATION_ADDER_HXX
static void neutral(T &out)
neutral element (call by reference)
Definition: adder.hxx:19
static void iop(const T1 &in1, const T2 &in2, T3 &out)
inverse operation (not in-place)
Definition: adder.hxx:49
The OpenGM namespace.
Definition: config.hxx:43
static void hop(const T1 &in1, const T2 &in2, T3 &out)
hyper-operation (not in-place)
Definition: adder.hxx:63
Addition as a binary operation.
Definition: adder.hxx:10
static void iop(const T1 &in, T2 &out)
inverse operation (in-place)
Definition: adder.hxx:44
static void ihop(const T1 &in1, const T2 &in2, T3 &out)
inverse hyper-operation (same type, not in-place)
Definition: adder.hxx:73
static T neutral()
neutral element (with return)
Definition: adder.hxx:14
static void op(const T1 &in, T2 &out)
operation (in-place)
Definition: adder.hxx:34
static void op(const T1 &in1, const T2 &in2, T3 &out)
operation (not in-place)
Definition: adder.hxx:39
static void ihop(const T1 &in, T2 &out)
inverse hyper-operation (in-place)
Definition: adder.hxx:68
static void hop(const T1 &in, T2 &out)
hyper-operation (in-place)
Definition: adder.hxx:58
static void ineutral(T &out)
inverse neutral element (call by reference)
Definition: adder.hxx:29
static T ineutral()
inverse neutral element (with return)
Definition: adder.hxx:24
static bool hasbop()
bool operation flag
Definition: adder.hxx:53