IT++ Logo Newcom Logo

fix_operators.h

Go to the documentation of this file.
00001 
00034 #ifndef FIX_OPERATORS_H
00035 #define FIX_OPERATORS_H
00036 
00037 #include <itpp/fixedpoint/cfix.h>
00038 #include <itpp/fixedpoint/fix_functions.h>
00039 
00040 
00041 namespace itpp {
00042 
00045 
00047   // Operators for Fix and Fixed //
00049 
00051   Fix operator+(const Fix &x, const Fix &y);
00053   Fix operator-(const Fix &x, const Fix &y);
00055   Fix operator*(const Fix &x, const Fix &y);
00057   Fix operator/(const Fix &x, const Fix &y);
00058 
00060   Fix operator+(const Fix &x, const int y);
00062   Fix operator-(const Fix &x, const int y);
00064   Fix operator*(const Fix &x, const int y);
00066   Fix operator/(const Fix &x, const int y);
00068   Fix operator+(const int x, const Fix &y);
00070   Fix operator-(const int x, const Fix &y);
00072   Fix operator*(const int x, const Fix &y);
00074   Fix operator/(const int x, const Fix &y);
00075 
00077   inline fixvec operator+(const fixvec &v, const int s) {return v + Fix(s);}
00079   inline fixvec operator+(const int s, const fixvec &v) {return Fix(s) + v;}
00081   inline fixvec operator-(const fixvec &v, const int s) {return v - Fix(s);}
00083   inline fixvec operator-(const int s, const fixvec &v) {return Fix(s) - v;}
00085   inline fixvec operator*(const fixvec &v, const int s) {return v * Fix(s);}
00087   inline fixvec operator*(const int s, const fixvec &v) {return Fix(s) * v;}
00089   inline fixvec operator/(const fixvec &v, const int s) {return v / Fix(s);}
00090 
00092   inline fixmat operator+(const fixmat &v, const int s) {return v + Fix(s);}
00094   inline fixmat operator+(const int s, const fixmat &v) {return Fix(s) + v;}
00096   inline fixmat operator-(const fixmat &v, const int s) {return v - Fix(s);}
00098   inline fixmat operator-(const int s, const fixmat &v) {return Fix(s) - v;}
00100   inline fixmat operator*(const fixmat &v, const int s) {return v * Fix(s);}
00102   inline fixmat operator*(const int s, const fixmat &v) {return Fix(s) * v;}
00104   inline fixmat operator/(const fixmat &v, const int s) {return v / Fix(s);}
00105 
00106   //#ifdef _MSC_VER
00107   // These operators are not defined when using the Microsoft Developer Studio compiler due
00108   // to internal compiling error. Hopefully this compiler-bug will be fixed in the near future.
00109   //#else
00110 
00112   fixvec operator+(const fixvec &a, const ivec &b);
00114   inline fixvec operator+(const ivec &a, const fixvec &b) {return b+a;}
00116   inline fixvec operator-(const fixvec &a, const ivec &b) {return a+(-b);}
00118   inline fixvec operator-(const ivec &a, const fixvec &b) {return (-b)+a;}
00120   Fix operator*(const fixvec &a, const ivec &b);
00122   inline Fix operator*(const ivec &a, const fixvec &b) {return b*a;}
00123 
00125   fixmat operator+(const fixmat &a, const imat &b);
00127   inline fixmat operator+(const imat &a, const fixmat &b) {return b+a;}
00129   inline fixmat operator-(const fixmat &a, const imat &b) {return a+(-b);}
00131   inline fixmat operator-(const imat &a, const fixmat &b) {return (-b)+a;}
00133   fixmat operator*(const fixmat &a, const imat &b);
00135   inline fixmat operator*(const imat &a, const fixmat &b) {return b*a;}
00136 
00137   //#endif // _MSC_VER ifdef
00138 
00140   // Operators for CFix and CFixed //
00142 
00144   CFix operator+(const CFix &x, const CFix &y);
00146   CFix operator-(const CFix &x, const CFix &y);
00148   CFix operator*(const CFix &x, const CFix &y);
00150   CFix operator/(const CFix &x, const CFix &y);
00151 
00153   CFix operator+(const CFix &x, const Fix &y);
00155   CFix operator-(const CFix &x, const Fix &y);
00157   CFix operator*(const CFix &x, const Fix &y);
00159   CFix operator/(const CFix &x, const Fix &y);
00161   CFix operator+(const Fix &x, const CFix &y);
00163   CFix operator-(const Fix &x, const CFix &y);
00165   CFix operator*(const Fix &x, const CFix &y);
00167   CFix operator/(const Fix &x, const CFix &y);
00168 
00170   CFix operator+(const CFix &x, const int y);
00172   CFix operator-(const CFix &x, const int y);
00174   CFix operator*(const CFix &x, const int y);
00176   CFix operator/(const CFix &x, const int y);
00178   CFix operator+(const int x, const CFix &y);
00180   CFix operator-(const int x, const CFix &y);
00182   CFix operator*(const int x, const CFix &y);
00184   CFix operator/(const int x, const CFix &y);
00185 
00187   inline cfixvec operator+(const fixvec &v, const CFix &s) {return to<CFix>(v) + s;}
00189   inline cfixvec operator+(const CFix &s, const fixvec &v) {return s + to<CFix>(v);}
00191   inline cfixvec operator-(const fixvec &v, const CFix &s) {return to<CFix>(v) - s;}
00193   inline cfixvec operator-(const CFix &s, const fixvec &v) {return s - to<CFix>(v);}
00195   inline cfixvec operator*(const fixvec &v, const CFix &s) {return to<CFix>(v) * s;}
00197   inline cfixvec operator*(const CFix &s, const fixvec &v) {return s * to<CFix>(v);}
00199   inline cfixvec operator/(const fixvec &v, const CFix &s) {return to<CFix>(v) / s;}
00200 
00202   inline cfixmat operator+(const fixmat &m, const CFix &s) {return to<CFix>(m) + s;}
00204   inline cfixmat operator+(const CFix &s, const fixmat &m) {return s + to<CFix>(m);}
00206   inline cfixmat operator-(const fixmat &m, const CFix &s) {return to<CFix>(m) - s;}
00208   inline cfixmat operator-(const CFix &s, const fixmat &m) {return s - to<CFix>(m);}
00210   inline cfixmat operator*(const fixmat &m, const CFix &s) {return to<CFix>(m) * s;}
00212   inline cfixmat operator*(const CFix &s, const fixmat &m) {return s * to<CFix>(m);}
00214   inline cfixmat operator/(const fixmat &m, const CFix &s) {return to<CFix>(m) / s;}
00215 
00217   inline cfixvec operator+(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) + s;}
00219   inline cfixvec operator+(const CFix &s, const ivec &v) {return s + to<CFix>(to_vec(v));}
00221   inline cfixvec operator-(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) - s;}
00223   inline cfixvec operator-(const CFix &s, const ivec &v) {return s - to<CFix>(to_vec(v));}
00225   inline cfixvec operator*(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) * s;}
00227   inline cfixvec operator*(const CFix &s, const ivec &v) {return s * to<CFix>(to_vec(v));}
00229   inline cfixvec operator/(const ivec &v, const CFix &s) {return to<CFix>(to_vec(v)) / s;}
00230 
00232   inline cfixmat operator+(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) + s;}
00234   inline cfixmat operator+(const CFix &s, const imat &m) {return s + to<CFix>(to_mat(m));}
00236   inline cfixmat operator-(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) - s;}
00238   inline cfixmat operator-(const CFix &s, const imat &m) {return s - to<CFix>(to_mat(m));}
00240   inline cfixmat operator*(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) * s;}
00242   inline cfixmat operator*(const CFix &s, const imat &m) {return s * to<CFix>(to_mat(m));}
00244   inline cfixmat operator/(const imat &m, const CFix &s) {return to<CFix>(to_mat(m)) / s;}
00245 
00247   inline cfixvec operator+(const cfixvec &v, const Fix &s) {return v + CFix(s);}
00249   inline cfixvec operator+(const Fix &s, const cfixvec &v) {return CFix(s) + v;}
00251   inline cfixvec operator-(const cfixvec &v, const Fix &s) {return v - CFix(s);}
00253   inline cfixvec operator-(const Fix &s, const cfixvec &v) {return CFix(s) - v;}
00255   inline cfixvec operator*(const cfixvec &v, const Fix &s) {return v * CFix(s);}
00257   inline cfixvec operator*(const Fix &s, const cfixvec &v) {return CFix(s) * v;}
00259   inline cfixvec operator/(const cfixvec &v, const Fix &s) {return v / CFix(s);}
00260 
00262   inline cfixmat operator+(const cfixmat &m, const Fix &s) {return m + CFix(s);}
00264   inline cfixmat operator+(const Fix &s, const cfixmat &m) {return CFix(s) + m;}
00266   inline cfixmat operator-(const cfixmat &m, const Fix &s) {return m - CFix(s);}
00268   inline cfixmat operator-(const Fix &s, const cfixmat &m) {return CFix(s) - m;}
00270   inline cfixmat operator*(const cfixmat &m, const Fix &s) {return m * CFix(s);}
00272   inline cfixmat operator*(const Fix &s, const cfixmat &m) {return CFix(s) * m;}
00274   inline cfixmat operator/(const cfixmat &m, const Fix &s) {return m / CFix(s);}
00275 
00277   inline cfixvec operator+(const cfixvec &v, const int s) {return v + CFix(s);}
00279   inline cfixvec operator+(const int s, const cfixvec &v) {return CFix(s) + v;}
00281   inline cfixvec operator-(const cfixvec &v, const int s) {return v - CFix(s);}
00283   inline cfixvec operator-(const int s, const cfixvec &v) {return CFix(s) - v;}
00285   inline cfixvec operator*(const cfixvec &v, const int s) {return v * CFix(s);}
00287   inline cfixvec operator*(const int s, const cfixvec &v) {return CFix(s) * v;}
00289   inline cfixvec operator/(const cfixvec &v, const int s) {return v / CFix(s);}
00290 
00292   inline cfixmat operator+(const cfixmat &m, const int s) {return m + CFix(s);}
00294   inline cfixmat operator+(const int s, const cfixmat &m) {return CFix(s) + m;}
00296   inline cfixmat operator-(const cfixmat &m, const int s) {return m - CFix(s);}
00298   inline cfixmat operator-(const int s, const cfixmat &m) {return CFix(s) - m;}
00300   inline cfixmat operator*(const cfixmat &m, const int s) {return m * CFix(s);}
00302   inline cfixmat operator*(const int s, const cfixmat &m) {return CFix(s) * m;}
00304   inline cfixmat operator/(const cfixmat &m, const int s) {return m / CFix(s);}
00305 
00306   //#ifdef _MSC_VER
00307   // These operators are not defined when using the Microsoft Developer Studio compiler due
00308   // to internal compiling error. Hopefully this compiler-bug will be fixed in the near future.
00309   //#else
00310 
00312   cfixvec operator+(const cfixvec &a, const fixvec &b);
00314   inline cfixvec operator+(const fixvec &a, const cfixvec &b) {return b+a;}
00316   inline cfixvec operator-(const cfixvec &a, const fixvec &b) {return a+(-b);}
00318   inline cfixvec operator-(const fixvec &a, const cfixvec &b) {return (-b)+a;}
00320   CFix operator*(const cfixvec &a, const fixvec &b);
00322   inline CFix operator*(const fixvec &a, const cfixvec &b) {return b*a;}
00323 
00325   cfixmat operator+(const cfixmat &a, const fixmat &b);
00327   inline cfixmat operator+(const fixmat &a, const cfixmat &b) {return b+a;}
00329   inline cfixmat operator-(const cfixmat &a, const fixmat &b) {return a+(-b);}
00331   inline cfixmat operator-(const fixmat &a, const cfixmat &b) {return (-b)+a;}
00333   cfixmat operator*(const cfixmat &a, const fixmat &b);
00335   inline cfixmat operator*(const fixmat &a, const cfixmat &b) {return b*a;}
00336 
00338   cfixvec operator+(const cfixvec &a, const ivec &b);
00340   inline cfixvec operator+(const ivec &a, const cfixvec &b) {return b+a;}
00342   inline cfixvec operator-(const cfixvec &a, const ivec &b) {return a+(-b);}
00344   inline cfixvec operator-(const ivec &a, const cfixvec &b) {return (-b)+a;}
00346   CFix operator*(const cfixvec &a, const ivec &b);
00348   inline CFix operator*(const ivec &a, const cfixvec &b) {return b*a;}
00349 
00351   cfixmat operator+(const cfixmat &a, const imat &b);
00353   inline cfixmat operator+(const imat &a, const cfixmat &b) {return b+a;}
00355   inline cfixmat operator-(const cfixmat &a, const imat &b) {return a+(-b);}
00357   inline cfixmat operator-(const imat &a, const cfixmat &b) {return (-b)+a;}
00359   cfixmat operator*(const cfixmat &a, const imat &b);
00361   inline cfixmat operator*(const imat &a, const cfixmat &b) {return b*a;}
00362 
00363   //#endif // _MSC_VER ifdef
00364 
00366 
00367 } // namespace itpp
00368 
00369 #endif // #ifndef FIX_OPERATORS_H
SourceForge Logo

Generated on Fri Jun 8 01:07:13 2007 for IT++ by Doxygen 1.5.2