weightedoperations.hxx

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef OPENGM_OPERATION_WEIGTED_OPERATIONS_HXX
00003 #define OPENGM_OPERATION_WEIGTED_OPERATIONS_HXX
00004 
00006 
00007 namespace opengm {
00008 
00009 struct WeightedOperations{
00011    template<class OP, class T1, class T2>
00012    static inline void weightedMean(const T2& in1, const T2& in2, const T1& w, T2& out)
00013    {
00014       OPENGM_ASSERT(&out != &in2);
00015       out = in1;
00016       OP::iop(in2,out);
00017       OP::hop(w,out);
00018       OP::op(in2,out);
00019       //             equivalent to
00020       //             out = in1*w + in2*(1-w) = (in1-in2)*w+in2
00021       //             out = in1^w * in2^(1-w) = (in1/in2)^w*in2
00022    }
00023 
00025    template<class OP, class T1, class T2>
00026    static inline void wop(const T2& in, const T1& w, T2& out)
00027    {
00028       T2 t = in;
00029       OP::hop(w,t);
00030       OP::op(t,out);
00031       //             equivalent to
00032       //             out = out + in*w
00033       //             out = out * in^w
00034    }
00035 
00037    template<class OP, class T1, class T2>
00038    static inline void iwop(const T2& in, const T1& w, T2& out)
00039    {
00040       T2 t = in;
00041       T1 v = 1/w;
00042       OP::hop(v,t);
00043       OP::op(t,out);
00044       //             equivalent to
00045       //             out = out + in/w
00046       //             out = out * in^(1/w)
00047    }
00048 
00050    template<class OP, class T1, class T2>
00051    static inline void wiop(const T2& in, const T1& w, T2& out)
00052    {
00053       T2 t = in;
00054       OP::hop(w,t);
00055       OP::iop(t,out);
00056       //             equivalent to
00057       //             out = out - in*w
00058       //             out = out / in^(w)
00059    }
00060 
00062    template<class OP, class T1, class T2>
00063    static inline void iwiop(const T2& in, const T1& w, T2& out)
00064    {
00065       T2 t = in;
00066       T1 v = 1/w;
00067       OP::hop(v,t);
00068       OP::iop(t,out);
00069       //             equivalent to
00070       //             out = out - in/w
00071       //             out = out / in^(1/w)
00072    }
00073 };
00074 
00075 } // namespace opengm
00076 
00078 
00079 #endif // #ifndef OPENGM_OPERATION_WEIGTED_OPERATIONS_HXX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Jun 17 16:31:07 2013 for OpenGM by  doxygen 1.6.3