IT++ Logo

operators.h

Go to the documentation of this file.
00001 
00031 #ifndef OPERATORS_H
00032 #define OPERATORS_H
00033 
00034 #include <itpp/base/vec.h>
00035 #include <itpp/base/mat.h>
00036 #include <itpp/base/converters.h>
00037 
00038 
00039 namespace itpp {
00040 
00041   //---------------------- between scalars and complex<double> -----------------
00043   inline std::complex<double> operator+(const int &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
00045   inline std::complex<double> operator+(const float &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
00047   inline std::complex<double> operator+(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
00049   inline std::complex<double> operator+(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
00050 
00052   inline std::complex<double> operator-(const int &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
00054   inline std::complex<double> operator-(const float &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
00056   inline std::complex<double> operator-(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
00058   inline std::complex<double> operator-(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
00059 
00061   inline std::complex<double> operator*(const int &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
00063   inline std::complex<double> operator*(const float &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
00065   inline std::complex<double> operator*(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
00067   inline std::complex<double> operator*(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
00068 
00070   inline std::complex<double> operator/(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()/y, x.imag()/y);}
00072   inline std::complex<double> operator/(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()/y, x.imag()/y);}
00073 
00074 
00075   //---------------------- between vec and scalar --------------------
00076 
00081   inline vec operator+(const float &s, const vec &v) {return static_cast<double>(s)+v;}
00082 
00087   inline vec operator+(const short &s, const vec &v) {return static_cast<double>(s)+v;}
00088 
00093   inline vec operator+(const int &s, const vec &v) {return static_cast<double>(s)+v;}
00094 
00099   inline vec operator+(const vec &v, const float &s) {return static_cast<double>(s)+v;}
00100 
00105   inline vec operator+(const vec &v, const short &s) {return static_cast<double>(s)+v;}
00106 
00111   inline vec operator+(const vec &v, const int &s) {return static_cast<double>(s)+v;}
00112 
00117   inline vec operator-(const float &s, const vec &v) {return static_cast<double>(s)-v;}
00118 
00123   inline vec operator-(const short &s, const vec &v) {return static_cast<double>(s)-v;}
00124 
00129   inline vec operator-(const int &s, const vec &v) {return static_cast<double>(s)-v;}
00130 
00135   inline vec operator-(const vec &v, const float &s) {return v-static_cast<double>(s);}
00136 
00141   inline vec operator-(const vec &v, const short &s) {return v-static_cast<double>(s);}
00142 
00147   inline vec operator-(const vec &v, const int &s) {return v-static_cast<double>(s);}
00148 
00153   inline vec operator*(const float &s, const vec &v) {return static_cast<double>(s)*v;}
00154 
00159   inline vec operator*(const short &s, const vec &v) {return static_cast<double>(s)*v;}
00160 
00165   inline vec operator*(const int &s, const vec &v) {return static_cast<double>(s)*v;}
00166 
00171   cvec operator*(const std::complex<double> &s, const vec &v);
00172 
00177   inline vec operator*(const vec &v, const float &s) {return static_cast<double>(s)*v;}
00178 
00183   inline vec operator*(const vec &v, const short &s) {return static_cast<double>(s)*v;}
00184 
00189   inline vec operator*(const vec &v, const int &s) {return static_cast<double>(s)*v;}
00190 
00195   cvec operator*(const vec &v, const std::complex<double> &s);
00196 
00201   inline vec operator/(const vec &v, const float &s) {return v/static_cast<double>(s);}
00202 
00207   inline vec operator/(const vec &v, const short &s) {return v/static_cast<double>(s);}
00208 
00213   inline vec operator/(const vec &v, const int &s) {return v/static_cast<double>(s);}
00214 
00215 
00216   //---------------------- between ivec and scalar --------------------
00217 
00222   vec operator+(const double &s, const ivec &v);
00223 
00228   inline vec operator+(const ivec &v, const double &s) { return s+v;}
00229 
00234   vec operator-(const double &s, const ivec &v);
00235 
00240   inline vec operator-(const ivec &v, const double &s) { return v+(-s); }
00241 
00246   vec operator*(const double &s, const ivec &v);
00247 
00252   inline vec operator*(const ivec &v, const double &s) { return s*v; }
00253 
00258   vec operator/(const double &s, const ivec &v);
00259 
00264   vec operator/(const ivec &v, const double &s);
00265 
00270   cvec operator+(const std::complex<double> &s, const ivec &v);
00271 
00276   inline cvec operator+(const ivec &v, const std::complex<double> &s) { return s+v;}
00277 
00282   cvec operator-(const std::complex<double> &s, const ivec &v);
00283 
00288   inline cvec operator-(const ivec &v, const std::complex<double> &s) { return v+(-s); }
00289 
00294   cvec operator*(const std::complex<double> &s, const ivec &v);
00295 
00300   inline cvec operator*(const ivec &v, const std::complex<double> &s) { return s*v; }
00301 
00306   cvec operator/(const std::complex<double> &s, const ivec &v);
00307 
00312   cvec operator/(const ivec &v, const std::complex<double> &s);
00313 
00314   //---------------------- between cvec and scalar --------------------
00315 
00320   cvec operator+(const double &s, const cvec &v);
00321 
00326   inline cvec operator+(const float &s, const cvec &v) {return static_cast<double>(s)+v;}
00327 
00332   inline cvec operator+(const short &s, const cvec &v) {return static_cast<double>(s)+v;}
00333 
00338   inline cvec operator+(const int &s, const cvec &v) {return static_cast<double>(s)+v;}
00339 
00344   inline cvec operator+(const cvec &v, const float &s) {return s+v;}
00345 
00350   inline cvec operator+(const cvec &v, const double &s) {return s+v;}
00351 
00356   inline cvec operator+(const cvec &v, const short &s) {return s+v;}
00357 
00362   inline cvec operator+(const cvec &v, const int &s) {return s+v;}
00363 
00368   cvec operator-(const double &s, const cvec &v);
00369 
00374   inline cvec operator-(const float &s, const cvec &v) {return static_cast<double>(s)-v;}
00375 
00380   inline cvec operator-(const short &s, const cvec &v) {return static_cast<double>(s)-v;}
00381 
00386   inline cvec operator-(const int &s, const cvec &v) {return static_cast<double>(s)-v;}
00387 
00392   inline cvec operator-(const cvec &v, const float &s) {return v+(-s);}
00393 
00398   inline cvec operator-(const cvec &v, const double &s) {return v+(-s);}
00399 
00404   inline cvec operator-(const cvec &v, const short &s) {return v+(-s);}
00405 
00410   inline cvec operator-(const cvec &v, const int &s) {return v+(-s);}
00411 
00416   cvec operator*(const double &s, const cvec &v);
00417 
00422   inline cvec operator*(const float &s, const cvec &v) {return static_cast<double>(s)*v;}
00423 
00428   inline cvec operator*(const short &s, const cvec &v) {return static_cast<double>(s)*v;}
00429 
00434   inline cvec operator*(const int &s, const cvec &v) {return static_cast<double>(s)*v;}
00435 
00440   inline cvec operator*(const cvec &v, const float &s) {return s*v;}
00441 
00446   inline cvec operator*(const cvec &v, const double &s) {return s*v;}
00447 
00452   inline cvec operator*(const cvec &v, const short &s) {return s*v;}
00453 
00458   inline cvec operator*(const cvec &v, const int &s) {return s*v;}
00459 
00464   cvec operator/(const cvec &v, const double &s);
00465 
00470   cvec operator/(const double &s, const cvec &v);
00471 
00476   inline cvec operator/(const cvec &v, const float &s) {return v/static_cast<double>(s);}
00477 
00482   inline cvec operator/(const cvec &v, const short &s) {return v/static_cast<double>(s);}
00483 
00488   inline cvec operator/(const cvec &v, const int &s) {return v/static_cast<double>(s);}
00489 
00490   //---------------------- between mat and scalar --------------------
00491 
00496   inline mat operator+(const float &s, const mat &m) {return static_cast<double>(s)+m;}
00497 
00502   inline mat operator+(const short &s, const mat &m) {return static_cast<double>(s)+m;}
00503 
00508   inline mat operator+(const int &s, const mat &m) {return static_cast<double>(s)+m;}
00509 
00514   inline mat operator+(const mat &m, const float &s) {return static_cast<double>(s)+m;}
00515 
00520   inline mat operator+(const mat &m, const short &s) {return static_cast<double>(s)+m;}
00521 
00526   inline mat operator+(const mat &m, const int &s) {return static_cast<double>(s)+m;}
00527 
00532   inline mat operator-(const float &s, const mat &m) {return static_cast<double>(s)-m;}
00533 
00538   inline mat operator-(const short &s, const mat &m) {return static_cast<double>(s)-m;}
00539 
00544   inline mat operator-(const int &s, const mat &m) {return static_cast<double>(s)-m;}
00545 
00550   inline mat operator-(const mat &m, const float &s) {return m-static_cast<double>(s);}
00551 
00556   inline mat operator-(const mat &m, const short &s) {return m-static_cast<double>(s);}
00557 
00562   inline mat operator-(const mat &m, const int &s) {return m-static_cast<double>(s);}
00563 
00568   inline mat operator*(const float &s, const mat &m) {return static_cast<double>(s)*m;}
00569 
00574   inline mat operator*(const short &s, const mat &m) {return static_cast<double>(s)*m;}
00575 
00580   inline mat operator*(const int &s, const mat &m) {return static_cast<double>(s)*m;}
00581 
00586   inline mat operator*(const mat &m, const float &s) {return static_cast<double>(s)*m;}
00587 
00592   inline mat operator*(const mat &m, const short &s) {return static_cast<double>(s)*m;}
00593 
00598   inline mat operator*(const mat &m, const int &s) {return static_cast<double>(s)*m;}
00599 
00604   inline mat operator/(const mat &m, const float &s) {return m/static_cast<double>(s);}
00605 
00610   inline mat operator/(const mat &m, const short &s) {return m/static_cast<double>(s);}
00611 
00616   inline mat operator/(const mat &m, const int &s) {return m/static_cast<double>(s);}
00617 
00618   //---------------------- between cmat and scalar --------------------
00619 
00624   cmat operator+(const double &s, const cmat &m);
00625 
00630   cmat operator-(const double &s, const cmat &m);
00631 
00636   cmat operator*(const double &s, const cmat &m);
00637 
00642   cmat operator*(const std::complex<double> &s, const mat &m);
00643 
00648   inline cmat operator*(const mat &m, const std::complex<double> &s) {return s*m;}
00649 
00654   cmat operator/(const cmat &m, const double &s);
00655 
00656   //---------------------- between vec and vectors --------------------
00657 
00662   vec operator+(const bvec &a, const vec &b);
00663 
00668   vec operator+(const svec &a, const vec &b);
00669 
00674   vec operator+(const ivec &a, const vec &b);
00675 
00680   inline vec operator+(const vec &a, const bvec &b) {return b+a;}
00681 
00686   inline vec operator+(const vec &a, const svec &b) {return b+a;}
00687 
00692   inline vec operator+(const vec &a, const ivec &b) {return b+a;}
00693 
00698   inline vec operator-(const bvec &a, const vec &b) {return a+(-b);}
00699 
00704   inline vec operator-(const svec &a, const vec &b) {return a+(-b);}
00705 
00710   inline vec operator-(const ivec &a, const vec &b) {return a+(-b);}
00711 
00716   inline vec operator-(const vec &a, const bvec &b) {return a+(-b);}
00717 
00722   inline vec operator-(const vec &a, const svec &b) {return a+(-b);}
00723 
00728   inline vec operator-(const vec &a, const ivec &b) {return a+(-b);}
00729 
00734   double operator*(const bvec &a, const vec &b);
00735 
00740   double operator*(const svec &a, const vec &b);
00741 
00746   double operator*(const ivec &a, const vec &b);
00747 
00752   inline double operator*(const vec &a, const bvec &b) {return b*a;}
00753 
00758   inline double operator*(const vec &a, const svec &b) {return b*a;}
00759 
00764   inline double operator*(const vec &a, const ivec &b) {return b*a;}
00765 
00766   //---------------------- between cvec and vectors --------------------
00767 
00772   cvec operator+(const bvec &a, const cvec &b);
00773 
00778   cvec operator+(const svec &a, const cvec &b);
00779 
00784   cvec operator+(const ivec &a, const cvec &b);
00785 
00790   inline cvec operator+(const cvec &a, const bvec &b) {return b+a;}
00791 
00796   inline cvec operator+(const cvec &a, const svec &b) {return b+a;}
00797 
00802   inline cvec operator+(const cvec &a, const ivec &b) {return b+a;}
00803 
00808   inline cvec operator-(const bvec &a, const cvec &b) {return a+(-b);}
00809 
00814   inline cvec operator-(const svec &a, const cvec &b) {return a+(-b);}
00815 
00820   inline cvec operator-(const ivec &a, const cvec &b) {return a+(-b);}
00821 
00826   inline cvec operator-(const cvec &a, const bvec &b) {return a+(-b);}
00827 
00832   inline cvec operator-(const cvec &a, const svec &b) {return a+(-b);}
00833 
00838   inline cvec operator-(const cvec &a, const ivec &b) {return a+(-b);}
00839 
00844   std::complex<double> operator*(const bvec &a, const cvec &b);
00845 
00850   std::complex<double> operator*(const svec &a, const cvec &b);
00851 
00856   std::complex<double> operator*(const ivec &a, const cvec &b);
00857 
00862   inline std::complex<double> operator*(const cvec &a, const bvec &b) {return b*a;}
00863 
00868   inline std::complex<double> operator*(const cvec &a, const svec &b) {return b*a;}
00869 
00874   inline std::complex<double> operator*(const cvec &a, const ivec &b) {return b*a;}
00875 
00876   //---------------------- between mat and matricies --------------------
00877 
00882   mat operator+(const bmat &a, const mat &b);
00883 
00888   mat operator+(const smat &a, const mat &b);
00889 
00894   mat operator+(const imat &a, const mat &b);
00895 
00900   inline mat operator+(const mat &a, const bmat &b) {return b+a;}
00901 
00906   inline mat operator+(const mat &a, const smat &b) {return b+a;}
00907 
00912   inline mat operator+(const mat &a, const imat &b) {return b+a;}
00913 
00918   inline mat operator-(const bmat &a, const mat &b) {return a+(-b);}
00919 
00924   inline mat operator-(const smat &a, const mat &b) {return a+(-b);}
00925 
00930   inline mat operator-(const imat &a, const mat &b) {return a+(-b);}
00931 
00936   inline mat operator-(const mat &a, const bmat &b) {return a+(-b);}
00937 
00942   inline mat operator-(const mat &a, const smat &b) {return a+(-b);}
00943 
00948   inline mat operator-(const mat &a, const imat &b) {return a+(-b);}
00949 
00950   //---------------------- between cmat and matricies --------------------
00951 
00956   cmat operator+(const bmat &a, const cmat &b);
00957 
00962   cmat operator+(const smat &a, const cmat &b);
00963 
00968   cmat operator+(const imat &a, const cmat &b);
00969 
00974   cmat operator+(const mat &a, const cmat &b);
00975 
00980   inline cmat operator+(const cmat &a, const bmat &b) {return b+a;}
00981 
00986   inline cmat operator+(const cmat &a, const smat &b) {return b+a;}
00987 
00992   inline cmat operator+(const cmat &a, const imat &b) {return b+a;}
00993 
00998   inline cmat operator+(const cmat &a, const mat &b) {return b+a;}
00999 
01004   inline cmat operator-(const bmat &a, const cmat &b) {return a+(-b);}
01005 
01010   inline cmat operator-(const smat &a, const cmat &b) {return a+(-b);}
01011 
01016   inline cmat operator-(const imat &a, const cmat &b) {return a+(-b);}
01017 
01022   inline cmat operator-(const mat &a, const cmat &b) {return a+(-b);}
01023 
01028   inline cmat operator-(const cmat &a, const bmat &b) {return a+(-b);}
01029 
01034   inline cmat operator-(const cmat &a, const smat &b) {return a+(-b);}
01035 
01040   inline cmat operator-(const cmat &a, const imat &b) {return a+(-b);}
01041 
01046   inline cmat operator-(const cmat &a, const mat &b) {return a+(-b);}
01047 
01052   inline cmat operator*(const mat &a, const cmat &b) {return to_cmat(a)*b;}
01053 
01058   inline cmat operator*(const bmat &a, const cmat &b) {return to_cmat(a)*b;}
01059 
01064   inline cmat operator*(const smat &a, const cmat &b) {return to_cmat(a)*b;}
01065 
01070   inline cmat operator*(const imat &a, const cmat &b) {return to_cmat(a)*b;}
01071 
01076   inline cmat operator*(const cmat &a, const mat &b) {return a*to_cmat(b);}
01077 
01082   inline cmat operator*(const cmat &a, const bmat &b) {return a*to_cmat(b);}
01083 
01088   inline cmat operator*(const cmat &a, const smat &b) {return a*to_cmat(b);}
01089 
01094   inline cmat operator*(const cmat &a, const imat &b) {return a*to_cmat(b);}
01095 
01096 } // namespace itpp
01097 
01098 #endif // #ifndef OPERATORS_H
01099 
SourceForge Logo

Generated on Sat Apr 19 10:43:52 2008 for IT++ by Doxygen 1.5.5