IT++ Logo Newcom Logo

operators.h

Go to the documentation of this file.
00001 
00034 #ifndef OPERATORS_H
00035 #define OPERATORS_H
00036 
00037 #include <itpp/base/vec.h>
00038 #include <itpp/base/mat.h>
00039 #include <itpp/base/converters.h>
00040 
00041 
00042 namespace itpp {
00043 
00044   //---------------------- between scalars and complex<double> -----------------
00046   inline std::complex<double> operator+(const int &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
00048   inline std::complex<double> operator+(const float &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
00050   inline std::complex<double> operator+(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
00052   inline std::complex<double> operator+(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
00053 
00055   inline std::complex<double> operator-(const int &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
00057   inline std::complex<double> operator-(const float &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
00059   inline std::complex<double> operator-(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
00061   inline std::complex<double> operator-(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
00062 
00064   inline std::complex<double> operator*(const int &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
00066   inline std::complex<double> operator*(const float &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
00068   inline std::complex<double> operator*(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
00070   inline std::complex<double> operator*(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
00071 
00073   inline std::complex<double> operator/(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()/y, x.imag()/y);}
00075   inline std::complex<double> operator/(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()/y, x.imag()/y);}
00076 
00077 
00078   //---------------------- between vec and scalar --------------------
00079 
00084   inline vec operator+(const float &s, const vec &v) {return static_cast<double>(s)+v;}
00085 
00090   inline vec operator+(const short &s, const vec &v) {return static_cast<double>(s)+v;}
00091 
00096   inline vec operator+(const int &s, const vec &v) {return static_cast<double>(s)+v;}
00097 
00102   inline vec operator+(const vec &v, const float &s) {return static_cast<double>(s)+v;}
00103 
00108   inline vec operator+(const vec &v, const short &s) {return static_cast<double>(s)+v;}
00109 
00114   inline vec operator+(const vec &v, const int &s) {return static_cast<double>(s)+v;}
00115 
00120   inline vec operator-(const float &s, const vec &v) {return static_cast<double>(s)-v;}
00121 
00126   inline vec operator-(const short &s, const vec &v) {return static_cast<double>(s)-v;}
00127 
00132   inline vec operator-(const int &s, const vec &v) {return static_cast<double>(s)-v;}
00133 
00138   inline vec operator-(const vec &v, const float &s) {return v-static_cast<double>(s);}
00139 
00144   inline vec operator-(const vec &v, const short &s) {return v-static_cast<double>(s);}
00145 
00150   inline vec operator-(const vec &v, const int &s) {return v-static_cast<double>(s);}
00151 
00156   inline vec operator*(const float &s, const vec &v) {return static_cast<double>(s)*v;}
00157 
00162   inline vec operator*(const short &s, const vec &v) {return static_cast<double>(s)*v;}
00163 
00168   inline vec operator*(const int &s, const vec &v) {return static_cast<double>(s)*v;}
00169 
00174   cvec operator*(const std::complex<double> &s, const vec &v);
00175 
00180   inline vec operator*(const vec &v, const float &s) {return static_cast<double>(s)*v;}
00181 
00186   inline vec operator*(const vec &v, const short &s) {return static_cast<double>(s)*v;}
00187 
00192   inline vec operator*(const vec &v, const int &s) {return static_cast<double>(s)*v;}
00193 
00198   cvec operator*(const vec &v, const std::complex<double> &s);
00199 
00204   inline vec operator/(const vec &v, const float &s) {return v/static_cast<double>(s);}
00205 
00210   inline vec operator/(const vec &v, const short &s) {return v/static_cast<double>(s);}
00211 
00216   inline vec operator/(const vec &v, const int &s) {return v/static_cast<double>(s);}
00217 
00218 
00219   //---------------------- between ivec and scalar --------------------
00220 
00225   vec operator+(const double &s, const ivec &v);
00226 
00231   inline vec operator+(const ivec &v, const double &s) { return s+v;}
00232 
00237   vec operator-(const double &s, const ivec &v);
00238 
00243   inline vec operator-(const ivec &v, const double &s) { return v+(-s); }
00244 
00249   vec operator*(const double &s, const ivec &v);
00250 
00255   inline vec operator*(const ivec &v, const double &s) { return s*v; }
00256 
00261   vec operator/(const double &s, const ivec &v);
00262 
00267   vec operator/(const ivec &v, const double &s);
00268 
00273   cvec operator+(const std::complex<double> &s, const ivec &v);
00274 
00279   inline cvec operator+(const ivec &v, const std::complex<double> &s) { return s+v;}
00280 
00285   cvec operator-(const std::complex<double> &s, const ivec &v);
00286 
00291   inline cvec operator-(const ivec &v, const std::complex<double> &s) { return v+(-s); }
00292 
00297   cvec operator*(const std::complex<double> &s, const ivec &v);
00298 
00303   inline cvec operator*(const ivec &v, const std::complex<double> &s) { return s*v; }
00304 
00309   cvec operator/(const std::complex<double> &s, const ivec &v);
00310 
00315   cvec operator/(const ivec &v, const std::complex<double> &s);
00316 
00317   //---------------------- between cvec and scalar --------------------
00318 
00323   cvec operator+(const double &s, const cvec &v);
00324 
00329   inline cvec operator+(const float &s, const cvec &v) {return static_cast<double>(s)+v;}
00330 
00335   inline cvec operator+(const short &s, const cvec &v) {return static_cast<double>(s)+v;}
00336 
00341   inline cvec operator+(const int &s, const cvec &v) {return static_cast<double>(s)+v;}
00342 
00347   inline cvec operator+(const cvec &v, const float &s) {return s+v;}
00348 
00353   inline cvec operator+(const cvec &v, const double &s) {return s+v;}
00354 
00359   inline cvec operator+(const cvec &v, const short &s) {return s+v;}
00360 
00365   inline cvec operator+(const cvec &v, const int &s) {return s+v;}
00366 
00371   cvec operator-(const double &s, const cvec &v);
00372 
00377   inline cvec operator-(const float &s, const cvec &v) {return static_cast<double>(s)-v;}
00378 
00383   inline cvec operator-(const short &s, const cvec &v) {return static_cast<double>(s)-v;}
00384 
00389   inline cvec operator-(const int &s, const cvec &v) {return static_cast<double>(s)-v;}
00390 
00395   inline cvec operator-(const cvec &v, const float &s) {return v+(-s);}
00396 
00401   inline cvec operator-(const cvec &v, const double &s) {return v+(-s);}
00402 
00407   inline cvec operator-(const cvec &v, const short &s) {return v+(-s);}
00408 
00413   inline cvec operator-(const cvec &v, const int &s) {return v+(-s);}
00414 
00419   cvec operator*(const double &s, const cvec &v);
00420 
00425   inline cvec operator*(const float &s, const cvec &v) {return static_cast<double>(s)*v;}
00426 
00431   inline cvec operator*(const short &s, const cvec &v) {return static_cast<double>(s)*v;}
00432 
00437   inline cvec operator*(const int &s, const cvec &v) {return static_cast<double>(s)*v;}
00438 
00443   inline cvec operator*(const cvec &v, const float &s) {return s*v;}
00444 
00449   inline cvec operator*(const cvec &v, const double &s) {return s*v;}
00450 
00455   inline cvec operator*(const cvec &v, const short &s) {return s*v;}
00456 
00461   inline cvec operator*(const cvec &v, const int &s) {return s*v;}
00462 
00467   cvec operator/(const cvec &v, const double &s);
00468 
00473   cvec operator/(const double &s, const cvec &v);
00474 
00479   inline cvec operator/(const cvec &v, const float &s) {return v/static_cast<double>(s);}
00480 
00485   inline cvec operator/(const cvec &v, const short &s) {return v/static_cast<double>(s);}
00486 
00491   inline cvec operator/(const cvec &v, const int &s) {return v/static_cast<double>(s);}
00492 
00493   //---------------------- between mat and scalar --------------------
00494 
00499   inline mat operator+(const float &s, const mat &m) {return static_cast<double>(s)+m;}
00500 
00505   inline mat operator+(const short &s, const mat &m) {return static_cast<double>(s)+m;}
00506 
00511   inline mat operator+(const int &s, const mat &m) {return static_cast<double>(s)+m;}
00512 
00517   inline mat operator+(const mat &m, const float &s) {return static_cast<double>(s)+m;}
00518 
00523   inline mat operator+(const mat &m, const short &s) {return static_cast<double>(s)+m;}
00524 
00529   inline mat operator+(const mat &m, const int &s) {return static_cast<double>(s)+m;}
00530 
00535   inline mat operator-(const float &s, const mat &m) {return static_cast<double>(s)-m;}
00536 
00541   inline mat operator-(const short &s, const mat &m) {return static_cast<double>(s)-m;}
00542 
00547   inline mat operator-(const int &s, const mat &m) {return static_cast<double>(s)-m;}
00548 
00553   inline mat operator-(const mat &m, const float &s) {return m-static_cast<double>(s);}
00554 
00559   inline mat operator-(const mat &m, const short &s) {return m-static_cast<double>(s);}
00560 
00565   inline mat operator-(const mat &m, const int &s) {return m-static_cast<double>(s);}
00566 
00571   inline mat operator*(const float &s, const mat &m) {return static_cast<double>(s)*m;}
00572 
00577   inline mat operator*(const short &s, const mat &m) {return static_cast<double>(s)*m;}
00578 
00583   inline mat operator*(const int &s, const mat &m) {return static_cast<double>(s)*m;}
00584 
00589   inline mat operator*(const mat &m, const float &s) {return static_cast<double>(s)*m;}
00590 
00595   inline mat operator*(const mat &m, const short &s) {return static_cast<double>(s)*m;}
00596 
00601   inline mat operator*(const mat &m, const int &s) {return static_cast<double>(s)*m;}
00602 
00607   inline mat operator/(const mat &m, const float &s) {return m/static_cast<double>(s);}
00608 
00613   inline mat operator/(const mat &m, const short &s) {return m/static_cast<double>(s);}
00614 
00619   inline mat operator/(const mat &m, const int &s) {return m/static_cast<double>(s);}
00620 
00621   //---------------------- between cmat and scalar --------------------
00622 
00627   cmat operator+(const double &s, const cmat &m);
00628 
00633   cmat operator-(const double &s, const cmat &m);
00634 
00639   cmat operator*(const double &s, const cmat &m);
00640 
00645   cmat operator*(const std::complex<double> &s, const mat &m);
00646 
00651   inline cmat operator*(const mat &m, const std::complex<double> &s) {return s*m;}
00652 
00657   cmat operator/(const cmat &m, const double &s);
00658 
00659   //---------------------- between vec and vectors --------------------
00660 
00661   //#ifdef _MSC_VER
00662   // These operators are uncommented when using the Microsoft Developer Studio compiler due
00663   // to internal compiling error. Hopefully this compiler-bug will be fixed in the near future.
00664   //#else
00665 
00670   vec operator+(const bvec &a, const vec &b);
00671 
00676   vec operator+(const svec &a, const vec &b);
00677 
00682   vec operator+(const ivec &a, const vec &b);
00683 
00688   inline vec operator+(const vec &a, const bvec &b) {return b+a;}
00689 
00694   inline vec operator+(const vec &a, const svec &b) {return b+a;}
00695 
00700   inline vec operator+(const vec &a, const ivec &b) {return b+a;}
00701 
00706   inline vec operator-(const bvec &a, const vec &b) {return a+(-b);}
00707 
00712   inline vec operator-(const svec &a, const vec &b) {return a+(-b);}
00713 
00718   inline vec operator-(const ivec &a, const vec &b) {return a+(-b);}
00719 
00724   inline vec operator-(const vec &a, const bvec &b) {return a+(-b);}
00725 
00730   inline vec operator-(const vec &a, const svec &b) {return a+(-b);}
00731 
00736   inline vec operator-(const vec &a, const ivec &b) {return a+(-b);}
00737 
00742   double operator*(const bvec &a, const vec &b);
00743 
00748   double operator*(const svec &a, const vec &b);
00749 
00754   double operator*(const ivec &a, const vec &b);
00755 
00760   inline double operator*(const vec &a, const bvec &b) {return b*a;}
00761 
00766   inline double operator*(const vec &a, const svec &b) {return b*a;}
00767 
00772   inline double operator*(const vec &a, const ivec &b) {return b*a;}
00773 
00774   //---------------------- between cvec and vectors --------------------
00775 
00780   cvec operator+(const bvec &a, const cvec &b);
00781 
00786   cvec operator+(const svec &a, const cvec &b);
00787 
00792   cvec operator+(const ivec &a, const cvec &b);
00793 
00798   inline cvec operator+(const cvec &a, const bvec &b) {return b+a;}
00799 
00804   inline cvec operator+(const cvec &a, const svec &b) {return b+a;}
00805 
00810   inline cvec operator+(const cvec &a, const ivec &b) {return b+a;}
00811 
00816   inline cvec operator-(const bvec &a, const cvec &b) {return a+(-b);}
00817 
00822   inline cvec operator-(const svec &a, const cvec &b) {return a+(-b);}
00823 
00828   inline cvec operator-(const ivec &a, const cvec &b) {return a+(-b);}
00829 
00834   inline cvec operator-(const cvec &a, const bvec &b) {return a+(-b);}
00835 
00840   inline cvec operator-(const cvec &a, const svec &b) {return a+(-b);}
00841 
00846   inline cvec operator-(const cvec &a, const ivec &b) {return a+(-b);}
00847 
00852   std::complex<double> operator*(const bvec &a, const cvec &b);
00853 
00858   std::complex<double> operator*(const svec &a, const cvec &b);
00859 
00864   std::complex<double> operator*(const ivec &a, const cvec &b);
00865 
00870   inline std::complex<double> operator*(const cvec &a, const bvec &b) {return b*a;}
00871 
00876   inline std::complex<double> operator*(const cvec &a, const svec &b) {return b*a;}
00877 
00882   inline std::complex<double> operator*(const cvec &a, const ivec &b) {return b*a;}
00883 
00884   //---------------------- between mat and matricies --------------------
00885 
00890   mat operator+(const bmat &a, const mat &b);
00891 
00896   mat operator+(const smat &a, const mat &b);
00897 
00902   mat operator+(const imat &a, const mat &b);
00903 
00908   inline mat operator+(const mat &a, const bmat &b) {return b+a;}
00909 
00914   inline mat operator+(const mat &a, const smat &b) {return b+a;}
00915 
00920   inline mat operator+(const mat &a, const imat &b) {return b+a;}
00921 
00926   inline mat operator-(const bmat &a, const mat &b) {return a+(-b);}
00927 
00932   inline mat operator-(const smat &a, const mat &b) {return a+(-b);}
00933 
00938   inline mat operator-(const imat &a, const mat &b) {return a+(-b);}
00939 
00944   inline mat operator-(const mat &a, const bmat &b) {return a+(-b);}
00945 
00950   inline mat operator-(const mat &a, const smat &b) {return a+(-b);}
00951 
00956   inline mat operator-(const mat &a, const imat &b) {return a+(-b);}
00957 
00958   //---------------------- between cmat and matricies --------------------
00959 
00964   cmat operator+(const bmat &a, const cmat &b);
00965 
00970   cmat operator+(const smat &a, const cmat &b);
00971 
00976   cmat operator+(const imat &a, const cmat &b);
00977 
00982   cmat operator+(const mat &a, const cmat &b);
00983 
00988   inline cmat operator+(const cmat &a, const bmat &b) {return b+a;}
00989 
00994   inline cmat operator+(const cmat &a, const smat &b) {return b+a;}
00995 
01000   inline cmat operator+(const cmat &a, const imat &b) {return b+a;}
01001 
01006   inline cmat operator+(const cmat &a, const mat &b) {return b+a;}
01007 
01012   inline cmat operator-(const bmat &a, const cmat &b) {return a+(-b);}
01013 
01018   inline cmat operator-(const smat &a, const cmat &b) {return a+(-b);}
01019 
01024   inline cmat operator-(const imat &a, const cmat &b) {return a+(-b);}
01025 
01030   inline cmat operator-(const mat &a, const cmat &b) {return a+(-b);}
01031 
01036   inline cmat operator-(const cmat &a, const bmat &b) {return a+(-b);}
01037 
01042   inline cmat operator-(const cmat &a, const smat &b) {return a+(-b);}
01043 
01048   inline cmat operator-(const cmat &a, const imat &b) {return a+(-b);}
01049 
01054   inline cmat operator-(const cmat &a, const mat &b) {return a+(-b);}
01055 
01060   inline cmat operator*(const mat &a, const cmat &b) {return to_cmat(a)*b;}
01061 
01066   inline cmat operator*(const bmat &a, const cmat &b) {return to_cmat(a)*b;}
01067 
01072   inline cmat operator*(const smat &a, const cmat &b) {return to_cmat(a)*b;}
01073 
01078   inline cmat operator*(const imat &a, const cmat &b) {return to_cmat(a)*b;}
01079 
01084   inline cmat operator*(const cmat &a, const mat &b) {return a*to_cmat(b);}
01085 
01090   inline cmat operator*(const cmat &a, const bmat &b) {return a*to_cmat(b);}
01091 
01096   inline cmat operator*(const cmat &a, const smat &b) {return a*to_cmat(b);}
01097 
01102   inline cmat operator*(const cmat &a, const imat &b) {return a*to_cmat(b);}
01103 
01104   //#endif // _MSC_VER ifdef
01105 
01106 } // namespace itpp
01107 
01108 #endif // #ifndef OPERATORS_H
01109 
SourceForge Logo

Generated on Sat Aug 25 23:40:25 2007 for IT++ by Doxygen 1.5.2