root/win32/itpp-4.0.1/itpp/base/operators.h @ 44

Revision 35, 30.2 kB (checked in by mido, 16 years ago)

zasadni zmeny ve /win32

Line 
1/*!
2 * \file
3 * \brief Definitions of operators for vectors and matricies of different
4 *        types
5 * \author Tony Ottosson
6 *
7 * -------------------------------------------------------------------------
8 *
9 * IT++ - C++ library of mathematical, signal processing, speech processing,
10 *        and communications classes and functions
11 *
12 * Copyright (C) 1995-2007  (see AUTHORS file for a list of contributors)
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 *
28 * -------------------------------------------------------------------------
29 */
30
31#ifndef OPERATORS_H
32#define OPERATORS_H
33
34#include <itpp/base/vec.h>
35#include <itpp/base/mat.h>
36#include <itpp/base/converters.h>
37
38
39namespace itpp {
40
41  //---------------------- between scalars and complex<double> -----------------
42  //! Addition operator for int and complex double
43  inline std::complex<double> operator+(const int &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
44  //! Addition operator for float and complex double
45  inline std::complex<double> operator+(const float &x, const std::complex<double> &y) {return std::complex<double>(x+y.real(), x+y.imag());}
46  //! Addition operator for int and complex double
47  inline std::complex<double> operator+(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
48  //! Addition operator for float and complex double
49  inline std::complex<double> operator+(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()+y, x.imag()+y);}
50
51  //! Subtraction operator for int and complex double
52  inline std::complex<double> operator-(const int &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
53  //! Subtraction operator for float and complex double
54  inline std::complex<double> operator-(const float &x, const std::complex<double> &y) {return std::complex<double>(x-y.real(), x-y.imag());}
55  //! Subtraction operator for int and complex double
56  inline std::complex<double> operator-(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
57  //! Subtraction operator for float and complex double
58  inline std::complex<double> operator-(const std::complex<double> &x, const float &y) {return std::complex<double>(x.real()-y, x.imag()-y);}
59
60  //! Multiplication operator for int and complex double
61  inline std::complex<double> operator*(const int &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
62  //! Multiplication operator for float and complex double
63  inline std::complex<double> operator*(const float &x, const std::complex<double> &y) {return std::complex<double>(x*y.real(), x*y.imag());}
64  //! Multiplication operator for int and complex double
65  inline std::complex<double> operator*(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()*y, x.imag()*y);}
66  //! Multiplication operator for float and complex double
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
69  //! Division operator for complex double and int
70  inline std::complex<double> operator/(const std::complex<double> &x, const int &y) {return std::complex<double>(x.real()/y, x.imag()/y);}
71  //! Division operator for complex double and float
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
77  /*!
78    \relatesalso Vec
79    \brief Addition operator for float and vec
80  */
81  inline vec operator+(const float &s, const vec &v) {return static_cast<double>(s)+v;}
82
83  /*!
84    \relatesalso Vec
85    \brief Addition operator for short and vec
86  */
87  inline vec operator+(const short &s, const vec &v) {return static_cast<double>(s)+v;}
88
89  /*!
90    \relatesalso Vec
91    \brief Addition operator for int and vec
92  */
93  inline vec operator+(const int &s, const vec &v) {return static_cast<double>(s)+v;}
94
95  /*!
96    \relatesalso Vec
97    \brief Addition operator for vec and float
98  */
99  inline vec operator+(const vec &v, const float &s) {return static_cast<double>(s)+v;}
100
101  /*!
102    \relatesalso Vec
103    \brief Addition operator for vec and short
104  */
105  inline vec operator+(const vec &v, const short &s) {return static_cast<double>(s)+v;}
106
107  /*!
108    \relatesalso Vec
109    \brief Addition operator for vec and int
110  */
111  inline vec operator+(const vec &v, const int &s) {return static_cast<double>(s)+v;}
112
113  /*!
114    \relatesalso Vec
115    \brief Subtraction operator for float and vec
116  */
117  inline vec operator-(const float &s, const vec &v) {return static_cast<double>(s)-v;}
118
119  /*!
120    \relatesalso Vec
121    \brief Subtraction operator for short and vec
122  */
123  inline vec operator-(const short &s, const vec &v) {return static_cast<double>(s)-v;}
124
125  /*!
126    \relatesalso Vec
127    \brief Subtraction operator for int and vec
128  */
129  inline vec operator-(const int &s, const vec &v) {return static_cast<double>(s)-v;}
130
131  /*!
132    \relatesalso Vec
133    \brief Subtraction operator for vec and float
134  */
135  inline vec operator-(const vec &v, const float &s) {return v-static_cast<double>(s);}
136
137  /*!
138    \relatesalso Vec
139    \brief Subtraction operator for vec and short
140  */
141  inline vec operator-(const vec &v, const short &s) {return v-static_cast<double>(s);}
142
143  /*!
144    \relatesalso Vec
145    \brief Subtraction operator for vec and int
146  */
147  inline vec operator-(const vec &v, const int &s) {return v-static_cast<double>(s);}
148
149  /*!
150    \relatesalso Vec
151    \brief Multiplication operator for float and vec
152  */
153  inline vec operator*(const float &s, const vec &v) {return static_cast<double>(s)*v;}
154
155  /*!
156    \relatesalso Vec
157    \brief Multiplication operator for short and vec
158  */
159  inline vec operator*(const short &s, const vec &v) {return static_cast<double>(s)*v;}
160
161  /*!
162    \relatesalso Vec
163    \brief Multiplication operator for int and vec
164  */
165  inline vec operator*(const int &s, const vec &v) {return static_cast<double>(s)*v;}
166
167  /*!
168    \relatesalso Vec
169    \brief Multiplication operator for complex<double> and vec
170  */
171  cvec operator*(const std::complex<double> &s, const vec &v);
172
173  /*!
174    \relatesalso Vec
175    \brief Multiplication operator for vec and float
176  */
177  inline vec operator*(const vec &v, const float &s) {return static_cast<double>(s)*v;}
178
179  /*!
180    \relatesalso Vec
181    \brief Multiplication operator for vec and short
182  */
183  inline vec operator*(const vec &v, const short &s) {return static_cast<double>(s)*v;}
184
185  /*!
186    \relatesalso Vec
187    \brief Multiplication operator for vec and int
188  */
189  inline vec operator*(const vec &v, const int &s) {return static_cast<double>(s)*v;}
190
191  /*!
192    \relatesalso Vec
193    \brief Multiplication operator for vec and complex<double>
194  */
195  cvec operator*(const vec &v, const std::complex<double> &s);
196
197  /*!
198    \relatesalso Vec
199    \brief Division operator for vec and float
200  */
201  inline vec operator/(const vec &v, const float &s) {return v/static_cast<double>(s);}
202
203  /*!
204    \relatesalso Vec
205    \brief Division operator for vec and short
206  */
207  inline vec operator/(const vec &v, const short &s) {return v/static_cast<double>(s);}
208
209  /*!
210    \relatesalso Vec
211    \brief Division operator for vec and int
212  */
213  inline vec operator/(const vec &v, const int &s) {return v/static_cast<double>(s);}
214
215
216  //---------------------- between ivec and scalar --------------------
217
218  /*!
219    \relatesalso Vec
220    \brief Addition operator for double and ivec
221  */
222  vec operator+(const double &s, const ivec &v);
223
224  /*!
225    \relatesalso Vec
226    \brief Addition operator for ivec and double
227  */
228  inline vec operator+(const ivec &v, const double &s) { return s+v;}
229
230  /*!
231    \relatesalso Vec
232    \brief Subtraction operator for double and ivec
233  */
234  vec operator-(const double &s, const ivec &v);
235
236  /*!
237    \relatesalso Vec
238    \brief Subtraction operator for ivec and double
239  */
240  inline vec operator-(const ivec &v, const double &s) { return v+(-s); }
241
242  /*!
243    \relatesalso Vec
244    \brief Multiplication operator for double and ivec
245  */
246  vec operator*(const double &s, const ivec &v);
247
248  /*!
249    \relatesalso Vec
250    \brief Multiplication operator for ivec and double
251  */
252  inline vec operator*(const ivec &v, const double &s) { return s*v; }
253
254  /*!
255    \relatesalso Vec
256    \brief Division operator for double and ivec
257  */
258  vec operator/(const double &s, const ivec &v);
259
260  /*!
261    \relatesalso Vec
262    \brief Division operator for ivec and double
263  */
264  vec operator/(const ivec &v, const double &s);
265
266  /*!
267    \relatesalso Vec
268    \brief Addition operator for complex<double> and ivec
269  */
270  cvec operator+(const std::complex<double> &s, const ivec &v);
271
272  /*!
273    \relatesalso Vec
274    \brief Addition operator for ivec and complex<double>
275  */
276  inline cvec operator+(const ivec &v, const std::complex<double> &s) { return s+v;}
277
278  /*!
279    \relatesalso Vec
280    \brief Subtraction operator for complex<double> and ivec
281  */
282  cvec operator-(const std::complex<double> &s, const ivec &v);
283
284  /*!
285    \relatesalso Vec
286    \brief Subtraction operator for ivec and complex<double>
287  */
288  inline cvec operator-(const ivec &v, const std::complex<double> &s) { return v+(-s); }
289
290  /*!
291    \relatesalso Vec
292    \brief Multiplication operator for complex<double> and ivec
293  */
294  cvec operator*(const std::complex<double> &s, const ivec &v);
295
296  /*!
297    \relatesalso Vec
298    \brief Multiplication operator for ivec and complex<double>
299  */
300  inline cvec operator*(const ivec &v, const std::complex<double> &s) { return s*v; }
301
302  /*!
303    \relatesalso Vec
304    \brief Division operator for complex<double> and ivec
305  */
306  cvec operator/(const std::complex<double> &s, const ivec &v);
307
308  /*!
309    \relatesalso Vec
310    \brief Division operator for ivec and complex<double>
311  */
312  cvec operator/(const ivec &v, const std::complex<double> &s);
313
314  //---------------------- between cvec and scalar --------------------
315
316  /*!
317    \relatesalso Vec
318    \brief Addition operator for double and cvec
319  */
320  cvec operator+(const double &s, const cvec &v);
321
322  /*!
323    \relatesalso Vec
324    \brief Addition operator for float and cvec
325  */
326  inline cvec operator+(const float &s, const cvec &v) {return static_cast<double>(s)+v;}
327
328  /*!
329    \relatesalso Vec
330    \brief Addition operator for short and cvec
331  */
332  inline cvec operator+(const short &s, const cvec &v) {return static_cast<double>(s)+v;}
333
334  /*!
335    \relatesalso Vec
336    \brief Addition operator for int and cvec
337  */
338  inline cvec operator+(const int &s, const cvec &v) {return static_cast<double>(s)+v;}
339
340  /*!
341    \relatesalso Vec
342    \brief Addition operator for cvec and float
343  */
344  inline cvec operator+(const cvec &v, const float &s) {return s+v;}
345
346  /*!
347    \relatesalso Vec
348    \brief Addition operator for cvec and double
349  */
350  inline cvec operator+(const cvec &v, const double &s) {return s+v;}
351
352  /*!
353    \relatesalso Vec
354    \brief Addition operator for cvec and short
355  */
356  inline cvec operator+(const cvec &v, const short &s) {return s+v;}
357
358  /*!
359    \relatesalso Vec
360    \brief Addition operator for cvec and int
361  */
362  inline cvec operator+(const cvec &v, const int &s) {return s+v;}
363
364  /*!
365    \relatesalso Vec
366    \brief Subtraction operator for double and cvec
367  */
368  cvec operator-(const double &s, const cvec &v);
369
370  /*!
371    \relatesalso Vec
372    \brief Subtraction operator for float and cvec
373  */
374  inline cvec operator-(const float &s, const cvec &v) {return static_cast<double>(s)-v;}
375
376  /*!
377    \relatesalso Vec
378    \brief Subtraction operator for short and cvec
379  */
380  inline cvec operator-(const short &s, const cvec &v) {return static_cast<double>(s)-v;}
381
382  /*!
383    \relatesalso Vec
384    \brief Subtraction operator for int and cvec
385  */
386  inline cvec operator-(const int &s, const cvec &v) {return static_cast<double>(s)-v;}
387
388  /*!
389    \relatesalso Vec
390    \brief Subtraction operator for cvec and float
391  */
392  inline cvec operator-(const cvec &v, const float &s) {return v+(-s);}
393
394  /*!
395    \relatesalso Vec
396    \brief Subtraction operator for cvec and double
397  */
398  inline cvec operator-(const cvec &v, const double &s) {return v+(-s);}
399
400  /*!
401    \relatesalso Vec
402    \brief Subtraction operator for cvec and short
403  */
404  inline cvec operator-(const cvec &v, const short &s) {return v+(-s);}
405
406  /*!
407    \relatesalso Vec
408    \brief Subtraction operator for cvec and int
409  */
410  inline cvec operator-(const cvec &v, const int &s) {return v+(-s);}
411
412  /*!
413    \relatesalso Vec
414    \brief Multiplication operator for double and cvec
415  */
416  cvec operator*(const double &s, const cvec &v);
417
418  /*!
419    \relatesalso Vec
420    \brief Multiplication operator for float and cvec
421  */
422  inline cvec operator*(const float &s, const cvec &v) {return static_cast<double>(s)*v;}
423
424  /*!
425    \relatesalso Vec
426    \brief Multiplication operator for short and cvec
427  */
428  inline cvec operator*(const short &s, const cvec &v) {return static_cast<double>(s)*v;}
429
430  /*!
431    \relatesalso Vec
432    \brief Multiplication operator for int and cvec
433  */
434  inline cvec operator*(const int &s, const cvec &v) {return static_cast<double>(s)*v;}
435
436  /*!
437    \relatesalso Vec
438    \brief Multiplication operator for cvec and float
439  */
440  inline cvec operator*(const cvec &v, const float &s) {return s*v;}
441
442  /*!
443    \relatesalso Vec
444    \brief Multiplication operator for cvec and double
445  */
446  inline cvec operator*(const cvec &v, const double &s) {return s*v;}
447
448  /*!
449    \relatesalso Vec
450    \brief Multiplication operator for cvec and short
451  */
452  inline cvec operator*(const cvec &v, const short &s) {return s*v;}
453
454  /*!
455    \relatesalso Vec
456    \brief Multiplication operator for cvec and int
457  */
458  inline cvec operator*(const cvec &v, const int &s) {return s*v;}
459
460  /*!
461    \relatesalso Vec
462    \brief Division operator for cvec and double
463  */
464  cvec operator/(const cvec &v, const double &s);
465
466  /*!
467    \relatesalso Vec
468    \brief Division operator for double and cvec
469  */
470  cvec operator/(const double &s, const cvec &v);
471
472  /*!
473    \relatesalso Vec
474    \brief Division operator for cvec and float
475  */
476  inline cvec operator/(const cvec &v, const float &s) {return v/static_cast<double>(s);}
477
478  /*!
479    \relatesalso Vec
480    \brief Division operator for cvec and short
481  */
482  inline cvec operator/(const cvec &v, const short &s) {return v/static_cast<double>(s);}
483
484  /*!
485    \relatesalso Vec
486    \brief Division operator for cvec and int
487  */
488  inline cvec operator/(const cvec &v, const int &s) {return v/static_cast<double>(s);}
489
490  //---------------------- between mat and scalar --------------------
491
492  /*!
493    \relatesalso Mat
494    \brief Addition operator for float and mat
495  */
496  inline mat operator+(const float &s, const mat &m) {return static_cast<double>(s)+m;}
497
498  /*!
499    \relatesalso Mat
500    \brief Addition operator for short and mat
501  */
502  inline mat operator+(const short &s, const mat &m) {return static_cast<double>(s)+m;}
503
504  /*!
505    \relatesalso Mat
506    \brief Addition operator for int and mat
507  */
508  inline mat operator+(const int &s, const mat &m) {return static_cast<double>(s)+m;}
509
510  /*!
511    \relatesalso Mat
512    \brief Addition operator for mat and float
513  */
514  inline mat operator+(const mat &m, const float &s) {return static_cast<double>(s)+m;}
515
516  /*!
517    \relatesalso Mat
518    \brief Addition operator for mat and short
519  */
520  inline mat operator+(const mat &m, const short &s) {return static_cast<double>(s)+m;}
521
522  /*!
523    \relatesalso Mat
524    \brief Addition operator for mat and int
525  */
526  inline mat operator+(const mat &m, const int &s) {return static_cast<double>(s)+m;}
527
528  /*!
529    \relatesalso Mat
530    \brief Subtraction operator for float and mat
531  */
532  inline mat operator-(const float &s, const mat &m) {return static_cast<double>(s)-m;}
533
534  /*!
535    \relatesalso Mat
536    \brief Subtraction operator for short and mat
537  */
538  inline mat operator-(const short &s, const mat &m) {return static_cast<double>(s)-m;}
539
540  /*!
541    \relatesalso Mat
542    \brief Subtraction operator for int and mat
543  */
544  inline mat operator-(const int &s, const mat &m) {return static_cast<double>(s)-m;}
545
546  /*!
547    \relatesalso Mat
548    \brief Subtraction operator for mat and float
549  */
550  inline mat operator-(const mat &m, const float &s) {return m-static_cast<double>(s);}
551
552  /*!
553    \relatesalso Mat
554    \brief Subtraction operator for mat and short
555  */
556  inline mat operator-(const mat &m, const short &s) {return m-static_cast<double>(s);}
557
558  /*!
559    \relatesalso Mat
560    \brief Subtraction operator for mat and int
561  */
562  inline mat operator-(const mat &m, const int &s) {return m-static_cast<double>(s);}
563
564  /*!
565    \relatesalso Mat
566    \brief Multiplication operator for float and mat
567  */
568  inline mat operator*(const float &s, const mat &m) {return static_cast<double>(s)*m;}
569
570  /*!
571    \relatesalso Mat
572    \brief Multiplication operator for short and mat
573  */
574  inline mat operator*(const short &s, const mat &m) {return static_cast<double>(s)*m;}
575
576  /*!
577    \relatesalso Mat
578    \brief Multiplication operator for int and mat
579  */
580  inline mat operator*(const int &s, const mat &m) {return static_cast<double>(s)*m;}
581
582  /*!
583    \relatesalso Mat
584    \brief Multiplication operator for mat and float
585  */
586  inline mat operator*(const mat &m, const float &s) {return static_cast<double>(s)*m;}
587
588  /*!
589    \relatesalso Mat
590    \brief Multiplication operator for mat and short
591  */
592  inline mat operator*(const mat &m, const short &s) {return static_cast<double>(s)*m;}
593
594  /*!
595    \relatesalso Mat
596    \brief Multiplication operator for mat and int
597  */
598  inline mat operator*(const mat &m, const int &s) {return static_cast<double>(s)*m;}
599
600  /*!
601    \relatesalso Mat
602    \brief Division operator for mat and float
603  */
604  inline mat operator/(const mat &m, const float &s) {return m/static_cast<double>(s);}
605
606  /*!
607    \relatesalso Mat
608    \brief Division operator for mat and short
609  */
610  inline mat operator/(const mat &m, const short &s) {return m/static_cast<double>(s);}
611
612  /*!
613    \relatesalso Mat
614    \brief Division operator for mat and int
615  */
616  inline mat operator/(const mat &m, const int &s) {return m/static_cast<double>(s);}
617
618  //---------------------- between cmat and scalar --------------------
619
620  /*!
621    \relatesalso Mat
622    \brief Addition operator for double and cmat
623  */
624  cmat operator+(const double &s, const cmat &m);
625
626  /*!
627    \relatesalso Mat
628    \brief Subtraction operator for double and cmat
629  */
630  cmat operator-(const double &s, const cmat &m);
631
632  /*!
633    \relatesalso Mat
634    \brief Multiplication operator for double and cmat
635  */
636  cmat operator*(const double &s, const cmat &m);
637
638  /*!
639    \relatesalso Mat
640    \brief Multiplication operator for complex<double> and mat
641  */
642  cmat operator*(const std::complex<double> &s, const mat &m);
643
644  /*!
645    \relatesalso Mat
646    \brief Multiplication operator for mat and complex<double>
647  */
648  inline cmat operator*(const mat &m, const std::complex<double> &s) {return s*m;}
649
650  /*!
651    \relatesalso Mat
652    \brief Division operator for cmat and double
653  */
654  cmat operator/(const cmat &m, const double &s);
655
656  //---------------------- between vec and vectors --------------------
657
658  /*!
659    \relatesalso Vec
660    \brief Addition operator for bvec and vec
661  */
662  vec operator+(const bvec &a, const vec &b);
663
664  /*!
665    \relatesalso Vec
666    \brief Addition operator for svec and vec
667  */
668  vec operator+(const svec &a, const vec &b);
669
670  /*!
671    \relatesalso Vec
672    \brief Addition operator for ivec and vec
673  */
674  vec operator+(const ivec &a, const vec &b);
675
676  /*!
677    \relatesalso Vec
678    \brief Addition operator for vec and bvec
679  */
680  inline vec operator+(const vec &a, const bvec &b) {return b+a;}
681
682  /*!
683    \relatesalso Vec
684    \brief Addition operator for vec and svec
685  */
686  inline vec operator+(const vec &a, const svec &b) {return b+a;}
687
688  /*!
689    \relatesalso Vec
690    \brief Addition operator for vec and ivec
691  */
692  inline vec operator+(const vec &a, const ivec &b) {return b+a;}
693
694  /*!
695    \relatesalso Vec
696    \brief Subtraction operator for bvec and vec
697  */
698  inline vec operator-(const bvec &a, const vec &b) {return a+(-b);}
699
700  /*!
701    \relatesalso Vec
702    \brief Subtraction operator for svec and vec
703  */
704  inline vec operator-(const svec &a, const vec &b) {return a+(-b);}
705
706  /*!
707    \relatesalso Vec
708    \brief Subtraction operator for ivec and vec
709  */
710  inline vec operator-(const ivec &a, const vec &b) {return a+(-b);}
711
712  /*!
713    \relatesalso Vec
714    \brief Subtraction operator for vec and bvec
715  */
716  inline vec operator-(const vec &a, const bvec &b) {return a+(-b);}
717
718  /*!
719    \relatesalso Vec
720    \brief Subtraction operator for vec and svec
721  */
722  inline vec operator-(const vec &a, const svec &b) {return a+(-b);}
723
724  /*!
725    \relatesalso Vec
726    \brief Subtraction operator for vec and ivec
727  */
728  inline vec operator-(const vec &a, const ivec &b) {return a+(-b);}
729
730  /*!
731    \relatesalso Vec
732    \brief Multiplication operator for bvec and vec
733  */
734  double operator*(const bvec &a, const vec &b);
735
736  /*!
737    \relatesalso Vec
738    \brief Multiplication operator for svec and vec
739  */
740  double operator*(const svec &a, const vec &b);
741
742  /*!
743    \relatesalso Vec
744    \brief Multiplication operator for ivec and vec
745  */
746  double operator*(const ivec &a, const vec &b);
747
748  /*!
749    \relatesalso Vec
750    \brief Multiplication operator for vec and bvec
751  */
752  inline double operator*(const vec &a, const bvec &b) {return b*a;}
753
754  /*!
755    \relatesalso Vec
756    \brief Multiplication operator for vec and svec
757  */
758  inline double operator*(const vec &a, const svec &b) {return b*a;}
759
760  /*!
761    \relatesalso Vec
762    \brief Multiplication operator for vec and ivec
763  */
764  inline double operator*(const vec &a, const ivec &b) {return b*a;}
765
766  //---------------------- between cvec and vectors --------------------
767
768  /*!
769    \relatesalso Vec
770    \brief Addition operator for bvec and cvec
771  */
772  cvec operator+(const bvec &a, const cvec &b);
773
774  /*!
775    \relatesalso Vec
776    \brief Addition operator for svec and cvec
777  */
778  cvec operator+(const svec &a, const cvec &b);
779
780  /*!
781    \relatesalso Vec
782    \brief Addition operator for ivec and cvec
783  */
784  cvec operator+(const ivec &a, const cvec &b);
785
786  /*!
787    \relatesalso Vec
788    \brief Addition operator for cvec and bvec
789  */
790  inline cvec operator+(const cvec &a, const bvec &b) {return b+a;}
791
792  /*!
793    \relatesalso Vec
794    \brief Addition operator for cvec and svec
795  */
796  inline cvec operator+(const cvec &a, const svec &b) {return b+a;}
797
798  /*!
799    \relatesalso Vec
800    \brief Addition operator for cvec and ivec
801  */
802  inline cvec operator+(const cvec &a, const ivec &b) {return b+a;}
803
804  /*!
805    \relatesalso Vec
806    \brief Subtraction operator for bvec and cvec
807  */
808  inline cvec operator-(const bvec &a, const cvec &b) {return a+(-b);}
809
810  /*!
811    \relatesalso Vec
812    \brief Subtraction operator for svec and cvec
813  */
814  inline cvec operator-(const svec &a, const cvec &b) {return a+(-b);}
815
816  /*!
817    \relatesalso Vec
818    \brief Subtraction operator for ivec and cvec
819  */
820  inline cvec operator-(const ivec &a, const cvec &b) {return a+(-b);}
821
822  /*!
823    \relatesalso Vec
824    \brief Subtraction operator for cvec and bvec
825  */
826  inline cvec operator-(const cvec &a, const bvec &b) {return a+(-b);}
827
828  /*!
829    \relatesalso Vec
830    \brief Subtraction operator for cvec and svec
831  */
832  inline cvec operator-(const cvec &a, const svec &b) {return a+(-b);}
833
834  /*!
835    \relatesalso Vec
836    \brief Subtraction operator for cvec and ivec
837  */
838  inline cvec operator-(const cvec &a, const ivec &b) {return a+(-b);}
839
840  /*!
841    \relatesalso Vec
842    \brief Multiplication operator for bvec and cvec
843  */
844  std::complex<double> operator*(const bvec &a, const cvec &b);
845
846  /*!
847    \relatesalso Vec
848    \brief Multiplication operator for svec and cvec
849  */
850  std::complex<double> operator*(const svec &a, const cvec &b);
851
852  /*!
853    \relatesalso Vec
854    \brief Multiplication operator for ivec and cvec
855  */
856  std::complex<double> operator*(const ivec &a, const cvec &b);
857
858  /*!
859    \relatesalso Vec
860    \brief Multiplication operator for cvec and bvec
861  */
862  inline std::complex<double> operator*(const cvec &a, const bvec &b) {return b*a;}
863
864  /*!
865    \relatesalso Vec
866    \brief Multiplication operator for cvec and svec
867  */
868  inline std::complex<double> operator*(const cvec &a, const svec &b) {return b*a;}
869
870  /*!
871    \relatesalso Vec
872    \brief Multiplication operator for cvec and ivec
873  */
874  inline std::complex<double> operator*(const cvec &a, const ivec &b) {return b*a;}
875
876  //---------------------- between mat and matricies --------------------
877
878  /*!
879    \relatesalso Mat
880    \brief Addition operator for bmat and mat
881  */
882  mat operator+(const bmat &a, const mat &b);
883
884  /*!
885    \relatesalso Mat
886    \brief Addition operator for smat and mat
887  */
888  mat operator+(const smat &a, const mat &b);
889
890  /*!
891    \relatesalso Mat
892    \brief Addition operator for imat and mat
893  */
894  mat operator+(const imat &a, const mat &b);
895
896  /*!
897    \relatesalso Mat
898    \brief Addition operator for mat and bmat
899  */
900  inline mat operator+(const mat &a, const bmat &b) {return b+a;}
901
902  /*!
903    \relatesalso Mat
904    \brief Addition operator for mat and smat
905  */
906  inline mat operator+(const mat &a, const smat &b) {return b+a;}
907
908  /*!
909    \relatesalso Mat
910    \brief Addition operator for mat and imat
911  */
912  inline mat operator+(const mat &a, const imat &b) {return b+a;}
913
914  /*!
915    \relatesalso Mat
916    \brief Subtraction operator for bmat and mat
917  */
918  inline mat operator-(const bmat &a, const mat &b) {return a+(-b);}
919
920  /*!
921    \relatesalso Mat
922    \brief Subtraction operator for smat and mat
923  */
924  inline mat operator-(const smat &a, const mat &b) {return a+(-b);}
925
926  /*!
927    \relatesalso Mat
928    \brief Subtraction operator for imat and mat
929  */
930  inline mat operator-(const imat &a, const mat &b) {return a+(-b);}
931
932  /*!
933    \relatesalso Mat
934    \brief Subtraction operator for mat and bmat
935  */
936  inline mat operator-(const mat &a, const bmat &b) {return a+(-b);}
937
938  /*!
939    \relatesalso Mat
940    \brief Subtraction operator for mat and smat
941  */
942  inline mat operator-(const mat &a, const smat &b) {return a+(-b);}
943
944  /*!
945    \relatesalso Mat
946    \brief Subtraction operator for mat and imat
947  */
948  inline mat operator-(const mat &a, const imat &b) {return a+(-b);}
949
950  //---------------------- between cmat and matricies --------------------
951
952  /*!
953    \relatesalso Mat
954    \brief Addition operator for bmat and cmat
955  */
956  cmat operator+(const bmat &a, const cmat &b);
957
958  /*!
959    \relatesalso Mat
960    \brief Addition operator for smat and cmat
961  */
962  cmat operator+(const smat &a, const cmat &b);
963
964  /*!
965    \relatesalso Mat
966    \brief Addition operator for imat and cmat
967  */
968  cmat operator+(const imat &a, const cmat &b);
969
970  /*!
971    \relatesalso Mat
972    \brief Addition operator for mat and cmat
973  */
974  cmat operator+(const mat &a, const cmat &b);
975
976  /*!
977    \relatesalso Mat
978    \brief Addition operator for cmat and bmat
979  */
980  inline cmat operator+(const cmat &a, const bmat &b) {return b+a;}
981
982  /*!
983    \relatesalso Mat
984    \brief Addition operator for cmat and smat
985  */
986  inline cmat operator+(const cmat &a, const smat &b) {return b+a;}
987
988  /*!
989    \relatesalso Mat
990    \brief Addition operator for cmat and imat
991  */
992  inline cmat operator+(const cmat &a, const imat &b) {return b+a;}
993
994  /*!
995    \relatesalso Mat
996    \brief Addition operator for cmat and mat
997  */
998  inline cmat operator+(const cmat &a, const mat &b) {return b+a;}
999
1000  /*!
1001    \relatesalso Mat
1002    \brief Subtraction operator for bmat and cmat
1003  */
1004  inline cmat operator-(const bmat &a, const cmat &b) {return a+(-b);}
1005
1006  /*!
1007    \relatesalso Mat
1008    \brief Subtraction operator for smat and cmat
1009  */
1010  inline cmat operator-(const smat &a, const cmat &b) {return a+(-b);}
1011
1012  /*!
1013    \relatesalso Mat
1014    \brief Subtraction operator for imat and cmat
1015  */
1016  inline cmat operator-(const imat &a, const cmat &b) {return a+(-b);}
1017
1018  /*!
1019    \relatesalso Mat
1020    \brief Subtraction operator for mat and cmat
1021  */
1022  inline cmat operator-(const mat &a, const cmat &b) {return a+(-b);}
1023
1024  /*!
1025    \relatesalso Mat
1026    \brief Subtraction operator for cmat and bmat
1027  */
1028  inline cmat operator-(const cmat &a, const bmat &b) {return a+(-b);}
1029
1030  /*!
1031    \relatesalso Mat
1032    \brief Subtraction operator for cmat and smat
1033  */
1034  inline cmat operator-(const cmat &a, const smat &b) {return a+(-b);}
1035
1036  /*!
1037    \relatesalso Mat
1038    \brief Subtraction operator for cmat and imat
1039  */
1040  inline cmat operator-(const cmat &a, const imat &b) {return a+(-b);}
1041
1042  /*!
1043    \relatesalso Mat
1044    \brief Subtraction operator for cmat and mat
1045  */
1046  inline cmat operator-(const cmat &a, const mat &b) {return a+(-b);}
1047
1048  /*!
1049    \relatesalso Mat
1050    \brief Multiplication operator for mat and cmat
1051  */
1052  inline cmat operator*(const mat &a, const cmat &b) {return to_cmat(a)*b;}
1053
1054  /*!
1055    \relatesalso Mat
1056    \brief Multiplication operator for bmat and cmat
1057  */
1058  inline cmat operator*(const bmat &a, const cmat &b) {return to_cmat(a)*b;}
1059
1060  /*!
1061    \relatesalso Mat
1062    \brief Multiplication operator for smat and cmat
1063  */
1064  inline cmat operator*(const smat &a, const cmat &b) {return to_cmat(a)*b;}
1065
1066  /*!
1067    \relatesalso Mat
1068    \brief Multiplication operator for imat and cmat
1069  */
1070  inline cmat operator*(const imat &a, const cmat &b) {return to_cmat(a)*b;}
1071
1072  /*!
1073    \relatesalso Mat
1074    \brief Multiplication operator for cmat and mat
1075  */
1076  inline cmat operator*(const cmat &a, const mat &b) {return a*to_cmat(b);}
1077
1078  /*!
1079    \relatesalso Mat
1080    \brief Multiplication operator for cmat and bmat
1081  */
1082  inline cmat operator*(const cmat &a, const bmat &b) {return a*to_cmat(b);}
1083
1084  /*!
1085    \relatesalso Mat
1086    \brief Multiplication operator for cmat and smat
1087  */
1088  inline cmat operator*(const cmat &a, const smat &b) {return a*to_cmat(b);}
1089
1090  /*!
1091    \relatesalso Mat
1092    \brief Multiplication operator for cmat and imat
1093  */
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
Note: See TracBrowser for help on using the browser.