00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_ASSIGN_MODE_INCLUDE
00013 #define MTL_ASSIGN_MODE_INCLUDE
00014
00015 #include <boost/numeric/linear_algebra/identity.hpp>
00016
00017 namespace mtl { namespace assign {
00018
00019 struct assign_sum
00020 {
00021 static const bool init_to_zero= true;
00022
00023 template <typename T>
00024 static void init(T& v)
00025 {
00026 using math::zero;
00027 v= zero(v);
00028 }
00029
00030
00031 template <typename T, typename U>
00032 static void first_update(T& x, const U& y)
00033 {
00034 x= y;
00035 }
00036
00037 template <typename T, typename U>
00038 static void update(T& x, const U& y)
00039 {
00040 x+= y;
00041 }
00042 };
00043
00044
00045 struct plus_sum
00046 {
00047 static const bool init_to_zero= false;
00048
00049 template <typename T>
00050 static void init(T& v) {}
00051
00052 template <typename T, typename U>
00053 static void first_update(T& x, const U& y)
00054 {
00055 x+= y;
00056 }
00057
00058 template <typename T, typename U>
00059 static void update(T& x, const U& y)
00060 {
00061 x+= y;
00062 }
00063 };
00064
00065
00066 struct minus_sum
00067 {
00068 static const bool init_to_zero= false;
00069
00070 template <typename T>
00071 static void init(T& v) {}
00072
00073 template <typename T, typename U>
00074 static void first_update(T& x, const U& y)
00075 {
00076 x-= y;
00077 }
00078
00079 template <typename T, typename U>
00080 static void update(T& x, const U& y)
00081 {
00082 x-= y;
00083 }
00084 };
00085
00086
00087 }}
00088
00089 #endif // MTL_ASSIGN_MODE_INCLUDE