Mercurial > octave
annotate liboctave/array/MArray.h @ 31225:3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Sun, 11 Sep 2022 13:53:38 -0400 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30489
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
237 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
26 #if ! defined (octave_MArray_h) |
382 | 27 #define octave_MArray_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
30 |
237 | 31 #include "Array.h" |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
32 #include "MArray-fwd.h" |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
33 #include "mx-inlines.cc" |
237 | 34 |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
35 template <typename T> OCTARRAY_API MArray<T>& operator += (MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
36 template <typename T> OCTARRAY_API MArray<T>& operator -= (MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
37 template <typename T> OCTARRAY_API MArray<T>& operator *= (MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
38 template <typename T> OCTARRAY_API MArray<T>& operator /= (MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
39 template <typename T> OCTARRAY_API MArray<T>& operator += (MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
40 template <typename T> OCTARRAY_API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
41 template <typename T> OCTARRAY_API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
42 template <typename T> OCTARRAY_API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
43 template <typename T> OCTARRAY_API MArray<T> operator + (const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
44 template <typename T> OCTARRAY_API MArray<T> operator - (const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
45 template <typename T> OCTARRAY_API MArray<T> operator + (const MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
46 template <typename T> OCTARRAY_API MArray<T> operator - (const MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
47 template <typename T> OCTARRAY_API MArray<T> operator * (const MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
48 template <typename T> OCTARRAY_API MArray<T> operator / (const MArray<T>&, const T&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
49 template <typename T> OCTARRAY_API MArray<T> operator + (const T&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
50 template <typename T> OCTARRAY_API MArray<T> operator - (const T&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
51 template <typename T> OCTARRAY_API MArray<T> operator * (const T&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
52 template <typename T> OCTARRAY_API MArray<T> operator / (const T&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
53 template <typename T> OCTARRAY_API MArray<T> operator + (const MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
54 template <typename T> OCTARRAY_API MArray<T> operator - (const MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
55 template <typename T> OCTARRAY_API MArray<T> quotient (const MArray<T>&, const MArray<T>&); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
56 template <typename T> OCTARRAY_API MArray<T> product (const MArray<T>&, const MArray<T>&); |
3107 | 57 |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
58 //! Template for N-dimensional array classes with like-type math operators. |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20960
diff
changeset
|
59 template <typename T> |
3585 | 60 class |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
61 OCTARRAY_API |
3585 | 62 MArray : public Array<T> |
237 | 63 { |
64 public: | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
65 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 MArray (void) : Array<T> () { } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
67 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
68 explicit MArray (const dim_vector& dv) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
69 : Array<T> (dv) { } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
70 |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
71 explicit MArray (const dim_vector& dv, const T& val) |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
72 : Array<T> (dv, val) { } |
3585 | 73 |
74 MArray (const MArray<T>& a) : Array<T> (a) { } | |
75 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20960
diff
changeset
|
76 template <typename U> |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
77 MArray (const Array<U>& a) : Array<T> (a) { } |
237 | 78 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
79 ~MArray (void) = default; |
1230 | 80 |
237 | 81 MArray<T>& operator = (const MArray<T>& a) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
82 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 Array<T>::operator = (a); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 } |
3573 | 86 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
87 MArray<T> reshape (const dim_vector& new_dims) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
88 { return Array<T>::reshape (new_dims); } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
89 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
90 MArray<T> permute (const Array<octave_idx_type>& vec, |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
91 bool inv = false) const |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 { return Array<T>::permute (vec, inv); } |
9612
66970dd627f6
further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
8934
diff
changeset
|
93 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
94 MArray<T> ipermute (const Array<octave_idx_type>& vec) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
95 { return Array<T>::ipermute (vec); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
96 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
97 MArray squeeze (void) const { return Array<T>::squeeze (); } |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
98 |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
99 MArray<T> transpose (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 { return Array<T>::transpose (); } |
5602 | 101 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
102 MArray<T> hermitian (T (*fcn) (const T&) = nullptr) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
103 { return Array<T>::hermitian (fcn); } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
104 |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
105 //! Performs indexed accumulative addition. |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
106 //@{ |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
107 OCTARRAY_API void idx_add (const octave::idx_vector& idx, T val); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
108 OCTARRAY_API void |
29646
3e8bc8bee8e9
liboctave/array: Add visibility flags to functions declared in headers (bug #60567).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29569
diff
changeset
|
109 idx_add (const octave::idx_vector& idx, const MArray<T>& vals); |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
110 //@} |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
111 |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
112 OCTARRAY_API void |
29646
3e8bc8bee8e9
liboctave/array: Add visibility flags to functions declared in headers (bug #60567).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29569
diff
changeset
|
113 idx_min (const octave::idx_vector& idx, const MArray<T>& vals); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
114 |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
115 OCTARRAY_API void |
29646
3e8bc8bee8e9
liboctave/array: Add visibility flags to functions declared in headers (bug #60567).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29569
diff
changeset
|
116 idx_max (const octave::idx_vector& idx, const MArray<T>& vals); |
3573 | 117 |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
118 OCTARRAY_API void |
29646
3e8bc8bee8e9
liboctave/array: Add visibility flags to functions declared in headers (bug #60567).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29569
diff
changeset
|
119 idx_add_nd (const octave::idx_vector& idx, const MArray<T>& vals, |
3e8bc8bee8e9
liboctave/array: Add visibility flags to functions declared in headers (bug #60567).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29569
diff
changeset
|
120 int dim = -1); |
10396
a0b51ac0f88a
optimize accumdim with summation
Jaroslav Hajek <highegg@gmail.com>
parents:
10364
diff
changeset
|
121 |
30489
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
122 OCTARRAY_API void changesign (void); |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
123 |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
124 private: |
bd67d0045e21
use separate files for MArray, intNDArray, and range template forward decls
John W. Eaton <jwe@octave.org>
parents:
29949
diff
changeset
|
125 OCTARRAY_API static void instantiation_guard (); |
237 | 126 }; |
127 | |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
128 // Define all the MArray forwarding functions for return type R and |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
129 // MArray element type T |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
130 #define MARRAY_FORWARD_DEFS(B, R, T) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
131 inline R operator += (R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
132 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
133 return R (operator += (dynamic_cast<B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
134 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
135 inline R operator -= (R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
136 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
137 return R (operator -= (dynamic_cast<B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
138 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
139 inline R operator *= (R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
140 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
141 return R (operator *= (dynamic_cast<B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
142 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
143 inline R operator /= (R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
144 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
145 return R (operator /= (dynamic_cast<B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
146 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
147 inline R operator += (R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
148 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
149 return R (operator += (dynamic_cast<B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
150 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
151 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
152 inline R operator -= (R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
153 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
154 return R (operator -= (dynamic_cast<B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
155 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
156 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
157 inline R product_eq (R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
158 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
159 return R (product_eq (dynamic_cast<B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
160 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
161 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
162 inline R quotient_eq (R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
163 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
164 return R (quotient_eq (dynamic_cast<B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
165 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
166 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
167 inline R operator + (const R& x) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
168 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
169 return R (operator + (dynamic_cast<const B<T>&> (x))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
170 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
171 inline R operator - (const R& x) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
172 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
173 return R (operator - (dynamic_cast<const B<T>&> (x))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
174 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
175 inline R operator + (const R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
176 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
177 return R (operator + (dynamic_cast<const B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
178 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
179 inline R operator - (const R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
180 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
181 return R (operator - (dynamic_cast<const B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
182 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
183 inline R operator * (const R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
184 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
185 return R (operator * (dynamic_cast<const B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
186 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
187 inline R operator / (const R& x, const T& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
188 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
189 return R (operator / (dynamic_cast<const B<T>&> (x), (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
190 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
191 inline R operator + (const T& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
192 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
193 return R (operator + ( (x), dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
194 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
195 inline R operator - (const T& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
196 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
197 return R (operator - ( (x), dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
198 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
199 inline R operator * (const T& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
200 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
201 return R (operator * ( (x), dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
202 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
203 inline R operator / (const T& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
204 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
205 return R (operator / ( (x), dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
206 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
207 inline R operator + (const R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
208 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
209 return R (operator + (dynamic_cast<const B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
210 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
211 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
212 inline R operator - (const R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
213 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
214 return R (operator - (dynamic_cast<const B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
215 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
216 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
217 inline R product (const R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
218 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
219 return R (product (dynamic_cast<const B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
220 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
221 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
222 inline R quotient (const R& x, const R& y) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
223 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
224 return R (quotient (dynamic_cast<const B<T>&> (x), \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
225 dynamic_cast<const B<T>&> (y))); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
226 } |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
227 |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
228 // Instantiate all the MArray friends for MArray element type T. |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
229 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
230 template API MArray<T>& operator += (MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
231 template API MArray<T>& operator -= (MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
232 template API MArray<T>& operator *= (MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
233 template API MArray<T>& operator /= (MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
234 template API MArray<T>& operator += (MArray<T>&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
235 template API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
236 template API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
237 template API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
238 template API MArray<T> operator + (const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
239 template API MArray<T> operator - (const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
240 template API MArray<T> operator + (const MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
241 template API MArray<T> operator - (const MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
242 template API MArray<T> operator * (const MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
243 template API MArray<T> operator / (const MArray<T>&, const T&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
244 template API MArray<T> operator + (const T&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
245 template API MArray<T> operator - (const T&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
246 template API MArray<T> operator * (const T&, const MArray<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
247 template API MArray<T> operator / (const T&, const MArray<T>&); \ |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
248 template API MArray<T> operator + (const MArray<T>&, const MArray<T>&); \ |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
249 template API MArray<T> operator - (const MArray<T>&, const MArray<T>&); \ |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
250 template API MArray<T> quotient (const MArray<T>&, const MArray<T>&); \ |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
251 template API MArray<T> product (const MArray<T>&, const MArray<T>&); |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
252 |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
253 // Instantiate all the MDiagArray2 friends for MDiagArray2 element type T. |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
254 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
255 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
256 template API MDiagArray2<T> operator - (const MDiagArray2<T>&); \ |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
257 template API MDiagArray2<T> operator * (const MDiagArray2<T>&, const T&); \ |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
258 template API MDiagArray2<T> operator / (const MDiagArray2<T>&, const T&); \ |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
259 template API MDiagArray2<T> operator * (const T&, const MDiagArray2<T>&); \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
260 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
261 const MDiagArray2<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
262 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
263 const MDiagArray2<T>&); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
264 template API MDiagArray2<T> product (const MDiagArray2<T>&, \ |
20960
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
265 const MDiagArray2<T>&); |
2a99b8b250cd
MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
20791
diff
changeset
|
266 |
237 | 267 #endif |