IT++ Logo
operators.h
Go to the documentation of this file.
1 
30 #ifndef OPERATORS_H
31 #define OPERATORS_H
32 
33 #include <itpp/base/vec.h>
34 #include <itpp/base/mat.h>
35 #include <itpp/base/converters.h>
36 #include <itpp/itexports.h>
37 
38 namespace itpp
39 {
40 
41 //---------------------- between scalars and complex<double> -----------------
43 inline std::complex<double> operator+(const int &x, const std::complex<double> &y) {return std::complex<double>(x + y.real(), y.imag());}
45 inline std::complex<double> operator+(const float &x, const std::complex<double> &y) {return std::complex<double>(x + y.real(), y.imag());}
47 inline std::complex<double> operator+(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() + y, x.imag());}
49 inline std::complex<double> operator+(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() + y, x.imag());}
50 
52 inline std::complex<double> operator-(const int &x, const std::complex<double> &y) {return std::complex<double>(x - y.real(), -y.imag());}
54 inline std::complex<double> operator-(const float &x, const std::complex<double> &y) {return std::complex<double>(x - y.real(), -y.imag());}
56 inline std::complex<double> operator-(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() - y, x.imag());}
58 inline std::complex<double> operator-(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() - y, x.imag());}
59 
61 inline std::complex<double> operator*(const int &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
63 inline std::complex<double> operator*(const float &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
65 inline std::complex<double> operator*(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
67 inline std::complex<double> operator*(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
68 
70 inline std::complex<double> operator/(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real() / y, x.imag() / y);}
72 inline std::complex<double> operator/(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real() / y, x.imag() / y);}
73 
74 
75 //---------------------- between vec and scalar --------------------
76 
81 inline vec operator+(const float &s, const vec &v) {return static_cast<double>(s) + v;}
82 
87 inline vec operator+(const short &s, const vec &v) {return static_cast<double>(s) + v;}
88 
93 inline vec operator+(const int &s, const vec &v) {return static_cast<double>(s) + v;}
94 
99 inline vec operator+(const vec &v, const float &s) {return static_cast<double>(s) + v;}
100 
105 inline vec operator+(const vec &v, const short &s) {return static_cast<double>(s) + v;}
106 
111 inline vec operator+(const vec &v, const int &s) {return static_cast<double>(s) + v;}
112 
117 inline vec operator-(const float &s, const vec &v) {return static_cast<double>(s) - v;}
118 
123 inline vec operator-(const short &s, const vec &v) {return static_cast<double>(s) - v;}
124 
129 inline vec operator-(const int &s, const vec &v) {return static_cast<double>(s) - v;}
130 
135 inline vec operator-(const vec &v, const float &s) {return v -static_cast<double>(s);}
136 
141 inline vec operator-(const vec &v, const short &s) {return v -static_cast<double>(s);}
142 
147 inline vec operator-(const vec &v, const int &s) {return v -static_cast<double>(s);}
148 
153 inline vec operator*(const float &s, const vec &v) {return static_cast<double>(s)*v;}
154 
159 inline vec operator*(const short &s, const vec &v) {return static_cast<double>(s)*v;}
160 
165 inline vec operator*(const int &s, const vec &v) {return static_cast<double>(s)*v;}
166 
171 cvec operator*(const std::complex<double> &s, const vec &v);
172 
177 inline vec operator*(const vec &v, const float &s) {return static_cast<double>(s)*v;}
178 
183 inline vec operator*(const vec &v, const short &s) {return static_cast<double>(s)*v;}
184 
189 inline vec operator*(const vec &v, const int &s) {return static_cast<double>(s)*v;}
190 
195 cvec operator*(const vec &v, const std::complex<double> &s);
196 
201 inline vec operator/(const vec &v, const float &s) {return v / static_cast<double>(s);}
202 
207 inline vec operator/(const vec &v, const short &s) {return v / static_cast<double>(s);}
208 
213 inline vec operator/(const vec &v, const int &s) {return v / static_cast<double>(s);}
214 
215 
216 //---------------------- between ivec and scalar --------------------
217 
222 ITPP_EXPORT vec operator+(const double &s, const ivec &v);
223 
228 inline vec operator+(const ivec &v, const double &s) { return s + v;}
229 
234 ITPP_EXPORT vec operator-(const double &s, const ivec &v);
235 
240 inline vec operator-(const ivec &v, const double &s) { return v + (-s); }
241 
246 ITPP_EXPORT vec operator*(const double &s, const ivec &v);
247 
252 inline vec operator*(const ivec &v, const double &s) { return s*v; }
253 
258 ITPP_EXPORT vec operator/(const double &s, const ivec &v);
259 
264 ITPP_EXPORT vec operator/(const ivec &v, const double &s);
265 
270 ITPP_EXPORT cvec operator+(const std::complex<double> &s, const ivec &v);
271 
276 inline cvec operator+(const ivec &v, const std::complex<double> &s) { return s + v;}
277 
282 ITPP_EXPORT cvec operator-(const std::complex<double> &s, const ivec &v);
283 
288 inline cvec operator-(const ivec &v, const std::complex<double> &s) { return v + (-s); }
289 
294 ITPP_EXPORT cvec operator*(const std::complex<double> &s, const ivec &v);
295 
300 inline cvec operator*(const ivec &v, const std::complex<double> &s) { return s*v; }
301 
306 ITPP_EXPORT cvec operator/(const std::complex<double> &s, const ivec &v);
307 
312 ITPP_EXPORT cvec operator/(const ivec &v, const std::complex<double> &s);
313 
314 //---------------------- between cvec and scalar --------------------
315 
320 ITPP_EXPORT cvec operator+(const double &s, const cvec &v);
321 
326 inline cvec operator+(const float &s, const cvec &v) {return static_cast<double>(s) + v;}
327 
332 inline cvec operator+(const short &s, const cvec &v) {return static_cast<double>(s) + v;}
333 
338 inline cvec operator+(const int &s, const cvec &v) {return static_cast<double>(s) + v;}
339 
344 inline cvec operator+(const cvec &v, const float &s) {return s + v;}
345 
350 inline cvec operator+(const cvec &v, const double &s) {return s + v;}
351 
356 inline cvec operator+(const cvec &v, const short &s) {return s + v;}
357 
362 inline cvec operator+(const cvec &v, const int &s) {return s + v;}
363 
368 ITPP_EXPORT cvec operator-(const double &s, const cvec &v);
369 
374 inline cvec operator-(const float &s, const cvec &v) {return static_cast<double>(s) - v;}
375 
380 inline cvec operator-(const short &s, const cvec &v) {return static_cast<double>(s) - v;}
381 
386 inline cvec operator-(const int &s, const cvec &v) {return static_cast<double>(s) - v;}
387 
392 inline cvec operator-(const cvec &v, const float &s) {return v + (-s);}
393 
398 inline cvec operator-(const cvec &v, const double &s) {return v + (-s);}
399 
404 inline cvec operator-(const cvec &v, const short &s) {return v + (-s);}
405 
410 inline cvec operator-(const cvec &v, const int &s) {return v + (-s);}
411 
416 ITPP_EXPORT cvec operator*(const double &s, const cvec &v);
417 
422 inline cvec operator*(const float &s, const cvec &v) {return static_cast<double>(s)*v;}
423 
428 inline cvec operator*(const short &s, const cvec &v) {return static_cast<double>(s)*v;}
429 
434 inline cvec operator*(const int &s, const cvec &v) {return static_cast<double>(s)*v;}
435 
440 inline cvec operator*(const cvec &v, const float &s) {return s*v;}
441 
446 inline cvec operator*(const cvec &v, const double &s) {return s*v;}
447 
452 inline cvec operator*(const cvec &v, const short &s) {return s*v;}
453 
458 inline cvec operator*(const cvec &v, const int &s) {return s*v;}
459 
464 ITPP_EXPORT cvec operator/(const cvec &v, const double &s);
465 
470 ITPP_EXPORT cvec operator/(const double &s, const cvec &v);
471 
476 inline cvec operator/(const cvec &v, const float &s) {return v / static_cast<double>(s);}
477 
482 inline cvec operator/(const cvec &v, const short &s) {return v / static_cast<double>(s);}
483 
488 inline cvec operator/(const cvec &v, const int &s) {return v / static_cast<double>(s);}
489 
490 //---------------------- between mat and scalar --------------------
491 
496 inline mat operator+(const float &s, const mat &m) {return static_cast<double>(s) + m;}
497 
502 inline mat operator+(const short &s, const mat &m) {return static_cast<double>(s) + m;}
503 
508 inline mat operator+(const int &s, const mat &m) {return static_cast<double>(s) + m;}
509 
514 inline mat operator+(const mat &m, const float &s) {return static_cast<double>(s) + m;}
515 
520 inline mat operator+(const mat &m, const short &s) {return static_cast<double>(s) + m;}
521 
526 inline mat operator+(const mat &m, const int &s) {return static_cast<double>(s) + m;}
527 
532 inline mat operator-(const float &s, const mat &m) {return static_cast<double>(s) - m;}
533 
538 inline mat operator-(const short &s, const mat &m) {return static_cast<double>(s) - m;}
539 
544 inline mat operator-(const int &s, const mat &m) {return static_cast<double>(s) - m;}
545 
550 inline mat operator-(const mat &m, const float &s) {return m -static_cast<double>(s);}
551 
556 inline mat operator-(const mat &m, const short &s) {return m -static_cast<double>(s);}
557 
562 inline mat operator-(const mat &m, const int &s) {return m -static_cast<double>(s);}
563 
568 inline mat operator*(const float &s, const mat &m) {return static_cast<double>(s)*m;}
569 
574 inline mat operator*(const short &s, const mat &m) {return static_cast<double>(s)*m;}
575 
580 inline mat operator*(const int &s, const mat &m) {return static_cast<double>(s)*m;}
581 
586 inline mat operator*(const mat &m, const float &s) {return static_cast<double>(s)*m;}
587 
592 inline mat operator*(const mat &m, const short &s) {return static_cast<double>(s)*m;}
593 
598 inline mat operator*(const mat &m, const int &s) {return static_cast<double>(s)*m;}
599 
604 inline mat operator/(const mat &m, const float &s) {return m / static_cast<double>(s);}
605 
610 inline mat operator/(const mat &m, const short &s) {return m / static_cast<double>(s);}
611 
616 inline mat operator/(const mat &m, const int &s) {return m / static_cast<double>(s);}
617 
618 //---------------------- between cmat and scalar --------------------
619 
624 ITPP_EXPORT cmat operator+(const double &s, const cmat &m);
625 
630 ITPP_EXPORT cmat operator-(const double &s, const cmat &m);
631 
636 ITPP_EXPORT cmat operator*(const double &s, const cmat &m);
637 
642 ITPP_EXPORT cmat operator*(const std::complex<double> &s, const mat &m);
643 
648 inline cmat operator*(const mat &m, const std::complex<double> &s) {return s*m;}
649 
654 ITPP_EXPORT cmat operator/(const cmat &m, const double &s);
655 
656 //---------------------- between vec and vectors --------------------
657 
662 ITPP_EXPORT vec operator+(const bvec &a, const vec &b);
663 
668 ITPP_EXPORT vec operator+(const svec &a, const vec &b);
669 
674 ITPP_EXPORT vec operator+(const ivec &a, const vec &b);
675 
680 inline vec operator+(const vec &a, const bvec &b) {return b + a;}
681 
686 inline vec operator+(const vec &a, const svec &b) {return b + a;}
687 
692 inline vec operator+(const vec &a, const ivec &b) {return b + a;}
693 
698 inline vec operator-(const bvec &a, const vec &b) {return a + (-b);}
699 
704 inline vec operator-(const svec &a, const vec &b) {return a + (-b);}
705 
710 inline vec operator-(const ivec &a, const vec &b) {return a + (-b);}
711 
716 inline vec operator-(const vec &a, const bvec &b) {return a + (-b);}
717 
722 inline vec operator-(const vec &a, const svec &b) {return a + (-b);}
723 
728 inline vec operator-(const vec &a, const ivec &b) {return a + (-b);}
729 
734 ITPP_EXPORT double operator*(const bvec &a, const vec &b);
735 
740 ITPP_EXPORT double operator*(const svec &a, const vec &b);
741 
746 ITPP_EXPORT double operator*(const ivec &a, const vec &b);
747 
752 inline double operator*(const vec &a, const bvec &b) {return b*a;}
753 
758 inline double operator*(const vec &a, const svec &b) {return b*a;}
759 
764 inline double operator*(const vec &a, const ivec &b) {return b*a;}
765 
766 //---------------------- between cvec and vectors --------------------
767 
772 ITPP_EXPORT cvec operator+(const bvec &a, const cvec &b);
773 
778 ITPP_EXPORT cvec operator+(const svec &a, const cvec &b);
779 
784 ITPP_EXPORT cvec operator+(const ivec &a, const cvec &b);
785 
790 inline cvec operator+(const cvec &a, const bvec &b) {return b + a;}
791 
796 inline cvec operator+(const cvec &a, const svec &b) {return b + a;}
797 
802 inline cvec operator+(const cvec &a, const ivec &b) {return b + a;}
803 
808 inline cvec operator-(const bvec &a, const cvec &b) {return a + (-b);}
809 
814 inline cvec operator-(const svec &a, const cvec &b) {return a + (-b);}
815 
820 inline cvec operator-(const ivec &a, const cvec &b) {return a + (-b);}
821 
826 inline cvec operator-(const cvec &a, const bvec &b) {return a + (-b);}
827 
832 inline cvec operator-(const cvec &a, const svec &b) {return a + (-b);}
833 
838 inline cvec operator-(const cvec &a, const ivec &b) {return a + (-b);}
839 
844 ITPP_EXPORT std::complex<double> operator*(const bvec &a, const cvec &b);
845 
850 ITPP_EXPORT std::complex<double> operator*(const svec &a, const cvec &b);
851 
856 ITPP_EXPORT std::complex<double> operator*(const ivec &a, const cvec &b);
857 
862 inline std::complex<double> operator*(const cvec &a, const bvec &b) {return b*a;}
863 
868 inline std::complex<double> operator*(const cvec &a, const svec &b) {return b*a;}
869 
874 inline std::complex<double> operator*(const cvec &a, const ivec &b) {return b*a;}
875 
876 //---------------------- between mat and matricies --------------------
877 
882 ITPP_EXPORT mat operator+(const bmat &a, const mat &b);
883 
888 ITPP_EXPORT mat operator+(const smat &a, const mat &b);
889 
894 ITPP_EXPORT mat operator+(const imat &a, const mat &b);
895 
900 inline mat operator+(const mat &a, const bmat &b) {return b + a;}
901 
906 inline mat operator+(const mat &a, const smat &b) {return b + a;}
907 
912 inline mat operator+(const mat &a, const imat &b) {return b + a;}
913 
918 inline mat operator-(const bmat &a, const mat &b) {return a + (-b);}
919 
924 inline mat operator-(const smat &a, const mat &b) {return a + (-b);}
925 
930 inline mat operator-(const imat &a, const mat &b) {return a + (-b);}
931 
936 inline mat operator-(const mat &a, const bmat &b) {return a + (-b);}
937 
942 inline mat operator-(const mat &a, const smat &b) {return a + (-b);}
943 
948 inline mat operator-(const mat &a, const imat &b) {return a + (-b);}
949 
950 //---------------------- between cmat and matricies --------------------
951 
956 ITPP_EXPORT cmat operator+(const bmat &a, const cmat &b);
957 
962 ITPP_EXPORT cmat operator+(const smat &a, const cmat &b);
963 
968 ITPP_EXPORT cmat operator+(const imat &a, const cmat &b);
969 
974 ITPP_EXPORT cmat operator+(const mat &a, const cmat &b);
975 
980 inline cmat operator+(const cmat &a, const bmat &b) {return b + a;}
981 
986 inline cmat operator+(const cmat &a, const smat &b) {return b + a;}
987 
992 inline cmat operator+(const cmat &a, const imat &b) {return b + a;}
993 
998 inline cmat operator+(const cmat &a, const mat &b) {return b + a;}
999 
1004 inline cmat operator-(const bmat &a, const cmat &b) {return a + (-b);}
1005 
1010 inline cmat operator-(const smat &a, const cmat &b) {return a + (-b);}
1011 
1016 inline cmat operator-(const imat &a, const cmat &b) {return a + (-b);}
1017 
1022 inline cmat operator-(const mat &a, const cmat &b) {return a + (-b);}
1023 
1028 inline cmat operator-(const cmat &a, const bmat &b) {return a + (-b);}
1029 
1034 inline cmat operator-(const cmat &a, const smat &b) {return a + (-b);}
1035 
1040 inline cmat operator-(const cmat &a, const imat &b) {return a + (-b);}
1041 
1046 inline cmat operator-(const cmat &a, const mat &b) {return a + (-b);}
1047 
1052 inline cmat operator*(const mat &a, const cmat &b) {return to_cmat(a)*b;}
1053 
1058 inline cmat operator*(const bmat &a, const cmat &b) {return to_cmat(a)*b;}
1059 
1064 inline cmat operator*(const smat &a, const cmat &b) {return to_cmat(a)*b;}
1065 
1070 inline cmat operator*(const imat &a, const cmat &b) {return to_cmat(a)*b;}
1071 
1076 inline cmat operator*(const cmat &a, const mat &b) {return a*to_cmat(b);}
1077 
1082 inline cmat operator*(const cmat &a, const bmat &b) {return a*to_cmat(b);}
1083 
1088 inline cmat operator*(const cmat &a, const smat &b) {return a*to_cmat(b);}
1089 
1094 inline cmat operator*(const cmat &a, const imat &b) {return a*to_cmat(b);}
1095 
1096 } // namespace itpp
1097 
1098 #endif // #ifndef OPERATORS_H
1099 
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:21 for IT++ by Doxygen 1.8.2