1993
|
1 // Template array classes with like-type math ops |
1988
|
2 /* |
|
3 |
|
4 Copyright (C) 1996 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if defined (__GNUG__) |
|
25 #pragma interface |
|
26 #endif |
|
27 |
|
28 #if !defined (octave_MArray2_h) |
|
29 #define octave_MArray2_h 1 |
|
30 |
|
31 #include "Array2.h" |
|
32 |
|
33 // Two dimensional array with math ops. |
|
34 |
|
35 template <class T> |
|
36 class MArray2 : public Array2<T> |
|
37 { |
|
38 protected: |
|
39 |
|
40 MArray2 (T *d, int n, int m) : Array2<T> (d, n, m) { } |
|
41 |
|
42 public: |
|
43 |
|
44 MArray2 (void) : Array2<T> () { } |
|
45 MArray2 (int n, int m) : Array2<T> (n, m) { } |
|
46 MArray2 (int n, int m, const T& val) : Array2<T> (n, m, val) { } |
|
47 MArray2 (const Array2<T>& a) : Array2<T> (a) { } |
|
48 MArray2 (const MArray2<T>& a) : Array2<T> (a) { } |
|
49 |
|
50 ~MArray2 (void) { } |
|
51 |
|
52 MArray2<T>& operator = (const MArray2<T>& a) |
|
53 { |
|
54 Array2<T>::operator = (a); |
|
55 return *this; |
|
56 } |
|
57 |
|
58 // element by element MArray2 by scalar ops |
|
59 |
|
60 friend MArray2<T>& operator += (MArray2<T>& a, const T& s); |
|
61 friend MArray2<T>& operator -= (MArray2<T>& a, const T& s); |
|
62 |
|
63 // element by element MArray2 by MArray2 ops |
|
64 |
|
65 friend MArray2<T>& operator += (MArray2<T>& a, const MArray2<T>& b); |
|
66 friend MArray2<T>& operator -= (MArray2<T>& a, const MArray2<T>& b); |
|
67 |
|
68 // element by element MArray2 by scalar ops |
|
69 |
|
70 friend MArray2<T> operator + (const MArray2<T>& a, const T& s); |
|
71 friend MArray2<T> operator - (const MArray2<T>& a, const T& s); |
|
72 friend MArray2<T> operator * (const MArray2<T>& a, const T& s); |
|
73 friend MArray2<T> operator / (const MArray2<T>& a, const T& s); |
|
74 |
|
75 // element by element scalar by MArray2 ops |
|
76 |
|
77 friend MArray2<T> operator + (const T& s, const MArray2<T>& a); |
|
78 friend MArray2<T> operator - (const T& s, const MArray2<T>& a); |
|
79 friend MArray2<T> operator * (const T& s, const MArray2<T>& a); |
|
80 friend MArray2<T> operator / (const T& s, const MArray2<T>& a); |
|
81 |
|
82 // element by element MArray2 by MArray2 ops |
|
83 |
|
84 friend MArray2<T> operator + (const MArray2<T>& a, const MArray2<T>& b); |
|
85 friend MArray2<T> operator - (const MArray2<T>& a, const MArray2<T>& b); |
|
86 |
|
87 friend MArray2<T> product (const MArray2<T>& a, const MArray2<T>& b); |
|
88 friend MArray2<T> quotient (const MArray2<T>& a, const MArray2<T>& b); |
|
89 |
|
90 friend MArray2<T> operator - (const MArray2<T>& a); |
|
91 }; |
|
92 |
|
93 #define INSTANTIATE_MARRAY2_FRIENDS(T) \ |
1992
|
94 template MArray2<T>& operator += (MArray2<T>& a, const T& s); \ |
|
95 template MArray2<T>& operator -= (MArray2<T>& a, const T& s); \ |
|
96 template MArray2<T>& operator += (MArray2<T>& a, const MArray2<T>& b); \ |
|
97 template MArray2<T>& operator -= (MArray2<T>& a, const MArray2<T>& b); \ |
1988
|
98 template MArray2<T> operator + (const MArray2<T>& a, const T& s); \ |
|
99 template MArray2<T> operator - (const MArray2<T>& a, const T& s); \ |
|
100 template MArray2<T> operator * (const MArray2<T>& a, const T& s); \ |
|
101 template MArray2<T> operator / (const MArray2<T>& a, const T& s); \ |
|
102 template MArray2<T> operator + (const T& s, const MArray2<T>& a); \ |
|
103 template MArray2<T> operator - (const T& s, const MArray2<T>& a); \ |
|
104 template MArray2<T> operator * (const T& s, const MArray2<T>& a); \ |
|
105 template MArray2<T> operator / (const T& s, const MArray2<T>& a); \ |
|
106 template MArray2<T> operator + (const MArray2<T>& a, const MArray2<T>& b); \ |
|
107 template MArray2<T> operator - (const MArray2<T>& a, const MArray2<T>& b); \ |
|
108 template MArray2<T> product (const MArray2<T>& a, const MArray2<T>& b); \ |
|
109 template MArray2<T> quotient (const MArray2<T>& a, const MArray2<T>& b); \ |
|
110 template MArray2<T> operator - (const MArray2<T>& a); |
|
111 |
|
112 #endif |
|
113 |
|
114 /* |
|
115 ;;; Local Variables: *** |
|
116 ;;; mode: C++ *** |
|
117 ;;; End: *** |
|
118 */ |