2 #ifndef OPENGM_OPERATIONS_LOGSUMEXP_HXX 3 #define OPENGM_OPERATIONS_LOGSUMEXP_HXX 18 {
return -std::numeric_limits<T>::infinity(); }
23 { out = -std::numeric_limits<T>::infinity(); }
28 {
return std::numeric_limits<T>::infinity(); }
33 { out = std::numeric_limits<T>::infinity(); }
36 template<
class T1,
class T2>
37 static void op(
const T1& in1, T2& out)
40 T2 theMax = std::max(in1, out);
41 T2 theMin = std::min(in1, out);
42 out = theMax + log(1 + exp(theMin - theMax));
46 template<
class T1,
class T2,
class T3>
47 static void op(
const T1 in1,
const T2 in2, T3& out)
50 T2 theMax = std::max(in1, out);
51 T2 theMin = std::min(in1, out);
52 out = theMax + log(1 + exp(theMin - theMax));
56 template<
class T1,
class T2>
57 static void iop(
const T1& in1, T2& out)
59 {
throw "not implemented"; }
62 template<
class T1,
class T2,
class T3>
63 static void iop(
const T1 in1,
const T2 in2, T3& out)
64 { out = log(exp(in1) - exp(in2)); }
72 static bool bop(
const T& in1,
const T& in2)
77 static bool ibop(
const T& in1,
const T& in2)
83 #endif // #ifndef OPENGM_OPERATIONS_INTEGRATOR_HXX
static void neutral(T &out)
neutral element (call by reference)
static void iop(const T1 in1, const T2 in2, T3 &out)
inverse operation (call by reference)
static void op(const T1 &in1, T2 &out)
operation (in-place)
static T neutral()
neutral element (with return)
static T ineutral()
inverse neutral element (with return)
static bool hasbop()
bool operation flag
static bool bop(const T &in1, const T &in2)
inverse boolean operation boolean operation (obsolete)
static void op(const T1 in1, const T2 in2, T3 &out)
operation (not in-place)
Logsumexp (addition in log space) as a unary accumulation.
static bool ibop(const T &in1, const T &in2)
inverse boolean operation inverse boolean operation (obsolete)
static void iop(const T1 &in1, T2 &out)
inverse operation (in-place)
static void ineutral(T &out)
inverse neutral element (call by reference)