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
00020
00021
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
00032
00033
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
00045
00046
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
00057
00058
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
00070
00071
00072 }
00073 };
00074
00075 }
00076
00078
00079 #endif // #ifndef OPENGM_OPERATION_WEIGTED_OPERATIONS_HXX