annotate liboctave/array/MArray.h @ 26376:00f796120a6d stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:32:43 -0500
parents 6652d3823428
children b442ec6dda5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
1 /*
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
3 Copyright (C) 1993-2019 John W. Eaton
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10396
diff changeset
4 Copyright (C) 2010 VZLU Prague
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
5
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
11 (at your option) any later version.
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 GNU General Public License for more details.
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
17
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6708
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
20 <https://www.gnu.org/licenses/>.
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
21
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
22 */
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
23
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
24 #if ! defined (octave_MArray_h)
382
e02d6b664394 [project @ 1994-03-09 21:08:03 by jwe]
jwe
parents: 237
diff changeset
25 #define octave_MArray_h 1
e02d6b664394 [project @ 1994-03-09 21:08:03 by jwe]
jwe
parents: 237
diff changeset
26
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
27 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
28
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
29 #include "Array.h"
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
30 #include "mx-inlines.cc"
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
31
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 20960
diff changeset
32 template <typename T> class MArray;
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2847
diff changeset
33
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
34 template <typename T> MArray<T>& operator += (MArray<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
35 template <typename T> MArray<T>& operator -= (MArray<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
36 template <typename T> MArray<T>& operator *= (MArray<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
37 template <typename T> MArray<T>& operator /= (MArray<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
38 template <typename T> MArray<T>& operator += (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
39 template <typename T> MArray<T>& operator -= (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
40 template <typename T> MArray<T>& product_eq (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
41 template <typename T> MArray<T>& quotient_eq (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
42 template <typename T> MArray<T> operator + (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
43 template <typename T> MArray<T> operator - (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
44 template <typename T> MArray<T> operator + (const MArray<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
45 template <typename T> MArray<T> operator - (const MArray<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
46 template <typename T> MArray<T> operator * (const MArray<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
47 template <typename T> MArray<T> operator / (const MArray<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
48 template <typename T> MArray<T> operator + (const 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
49 template <typename T> MArray<T> operator - (const 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
50 template <typename T> MArray<T> operator * (const 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
51 template <typename T> MArray<T> operator / (const 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
52 template <typename T> 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
53 template <typename T> 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
54 template <typename T> 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
55 template <typename T> MArray<T> product (const MArray<T>&, const MArray<T>&);
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2847
diff changeset
56
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
57 //! 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
58 template <typename T>
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
59 class
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
60 MArray : public Array<T>
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
61 {
14951
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
62 protected:
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
63
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
64 // For jit support
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
65 MArray (T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
66 : Array<T> (sdata, slen, adims, arep) { }
4c9fd3e31436 Start of jit support for double matricies
Max Brister <max@2bass.com>
parents: 14138
diff changeset
67
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
68 public:
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
69
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 MArray (void) : Array<T> () { }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
71
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
72 explicit MArray (const dim_vector& dv)
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
73 : Array<T> (dv) { }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
74
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
75 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
76 : Array<T> (dv, val) { }
3585
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
77
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
78 MArray (const MArray<T>& a) : Array<T> (a) { }
d9803711e047 [project @ 2000-02-08 04:35:39 by jwe]
jwe
parents: 3573
diff changeset
79
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 20960
diff changeset
80 template <typename U>
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
81 MArray (const Array<U>& a) : Array<T> (a) { }
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
82
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
83 ~MArray (void) = default;
1230
92609e161b29 [project @ 1995-04-10 01:08:57 by jwe]
jwe
parents: 1213
diff changeset
84
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
85 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
86 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
87 Array<T>::operator = (a);
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
88 return *this;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
89 }
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
90
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
91 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
92 { return Array<T>::reshape (new_dims); }
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
93
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
94 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
95 bool inv = false) const
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
96 { return Array<T>::permute (vec, inv); }
9612
66970dd627f6 further liboctave design improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 8934
diff changeset
97
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
98 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
99 { return Array<T>::ipermute (vec); }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7503
diff changeset
100
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
101 MArray squeeze (void) const { return Array<T>::squeeze (); }
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
102
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
103 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
104 { return Array<T>::transpose (); }
5602
dfa2da0563e5 [project @ 2006-01-31 03:43:40 by jwe]
jwe
parents: 5307
diff changeset
105
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23220
diff changeset
106 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
107 { return Array<T>::hermitian (fcn); }
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
108
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
109 //! 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
110 //@{
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
111 void idx_add (const idx_vector& idx, T val);
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
112 void idx_add (const 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
113 //@}
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
114
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
115 void idx_min (const idx_vector& idx, const MArray<T>& vals);
7503
8c32f95c2639 convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
116
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
117 void idx_max (const idx_vector& idx, const MArray<T>& vals);
3573
6ae6f1180e62 [project @ 2000-02-04 09:01:59 by jwe]
jwe
parents: 3504
diff changeset
118
10396
a0b51ac0f88a optimize accumdim with summation
Jaroslav Hajek <highegg@gmail.com>
parents: 10364
diff changeset
119 void idx_add_nd (const idx_vector& idx, const MArray<T>& vals, int dim = -1);
a0b51ac0f88a optimize accumdim with summation
Jaroslav Hajek <highegg@gmail.com>
parents: 10364
diff changeset
120
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
121 void changesign (void);
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
122 };
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
123
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
124 // 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
125 // MArray element type T
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
126 #define MARRAY_FORWARD_DEFS(B, R, T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
127 inline R operator += (R& x, const T& y) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
128 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
129 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
130 } \
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 R& 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), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
146 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
147 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
148 inline R operator -= (R& x, const R& y) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
149 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
150 return R (operator -= (dynamic_cast<B<T>&> (x), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
151 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
152 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
153 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
154 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
155 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
156 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
157 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
158 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
159 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
160 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
161 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
162 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
163 inline R operator + (const R& x) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
164 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
165 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
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, const T& y) \
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), (y))); \
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 T& x, const R& 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 + ( (x), dynamic_cast<const B<T>&> (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 R& 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 + (dynamic_cast<const B<T>&> (x), \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
206 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
207 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
208 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
209 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
210 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
211 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
212 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
213 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
214 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
215 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
216 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
217 } \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
218 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
219 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
220 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
221 dynamic_cast<const B<T>&> (y))); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
222 }
20960
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
223
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
224 // 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
225 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 template API MArray<T> operator + (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 - (const MArray<T>&); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248
2a99b8b250cd MArray macro removal without loss of functionality to improve maintainability.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 20791
diff changeset
249 // 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
250 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
251 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
252 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
253 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
254 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
255 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
256 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
257 const MDiagArray2<T>&); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
258 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
259 const MDiagArray2<T>&); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
260 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
261 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
262
237
5a9e23307fb0 [project @ 1993-11-30 20:23:04 by jwe]
jwe
parents:
diff changeset
263 #endif