00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _TERMTOTERM_HPP_
00021 #define _TERMTOTERM_HPP_
00022
00023 template<class T>
00024 class TermToTermProduct
00025 {
00026 private:
00027 T t;
00028 public:
00029 inline const T& operator()(const T& t1, const T& t2)
00030 {
00031 for (size_t i=0; i<t1.size(); ++i)
00032 t[i] = t1[i]*t2[i];
00033 return t;
00034 }
00035 };
00036
00037 template<>
00038 class TermToTermProduct<real_t>
00039 {
00040 public:
00041 inline real_t operator()(const real_t& t1, const real_t& t2)
00042 {
00043 return t1*t2;
00044 }
00045 };
00046
00047
00048 template<class T>
00049 class TermToTermDivision
00050 {
00051 private:
00052 T t;
00053 public:
00054 inline const T& operator()(const T& t1, const T& t2)
00055 {
00056 for (size_t i=0; i<t1.size(); ++i)
00057 t = t1[i]/t2[i];
00058 return t;
00059 }
00060 };
00061
00062 template<>
00063 class TermToTermDivision<real_t>
00064 {
00065 public:
00066 inline real_t operator()(const real_t& t1, const real_t& t2)
00067 {
00068 return t1/t2;
00069 }
00070 };
00071
00072
00073
00074 template<class T>
00075 class TermToTermLess
00076 {
00077 bool less;
00078 public:
00079 inline bool operator()(const T& t1, const T& t2)
00080 {
00081 less = true;
00082 for (size_t i=0; i<t1.size(); ++i)
00083 less = less && t1[i]<t2[i];
00084 return less;
00085 }
00086 };
00087
00088 template<>
00089 class TermToTermLess<real_t>
00090 {
00091 public:
00092 inline real_t operator()(const real_t& t1, const real_t& t2)
00093 {
00094 return (t1<t2);
00095 }
00096 };
00097
00098
00099 #endif // _TERMTOTERM_HPP_
00100