458
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993, 1994 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_ComplexMatrix_h) |
|
25 #define octave_ComplexMatrix_h 1 |
|
26 |
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
|
31 #include <Complex.h> |
|
32 |
|
33 #include "Array.h" |
|
34 |
|
35 #include "mx-defs.h" |
|
36 |
|
37 extern "C++" { |
|
38 |
|
39 class ComplexMatrix : public Array2<Complex> |
|
40 { |
532
|
41 friend class ComplexCHOL; |
|
42 friend class ComplexHESS; |
458
|
43 friend class ComplexLU; |
532
|
44 friend class ComplexQR; |
536
|
45 friend class ComplexQRP; |
532
|
46 friend class ComplexSCHUR; |
458
|
47 friend class ComplexSVD; |
532
|
48 friend class ComplexColumnVector; |
|
49 friend class Matrix; |
458
|
50 |
|
51 public: |
|
52 |
|
53 ComplexMatrix (void) : Array2<Complex> () { } |
|
54 ComplexMatrix (int r, int c) : Array2<Complex> (r, c) { } |
|
55 ComplexMatrix (int r, int c, const Complex& val) |
|
56 : Array2<Complex> (r, c, val) { } |
|
57 ComplexMatrix (const Matrix& a); |
|
58 ComplexMatrix (const Array2<Complex>& a) : Array2<Complex> (a) { } |
|
59 ComplexMatrix (const ComplexMatrix& a) : Array2<Complex> (a) { } |
|
60 ComplexMatrix (const DiagMatrix& a); |
|
61 ComplexMatrix (const DiagArray<Complex>& a) : Array2<Complex> (a) { } |
|
62 ComplexMatrix (const ComplexDiagMatrix& a); |
|
63 // ComplexMatrix (double a) : Array2<Complex> (1, 1, a) { } |
|
64 // ComplexMatrix (const Complex& a) : Array2<Complex> (1, 1, a) { } |
|
65 |
|
66 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
67 { |
|
68 Array2<Complex>::operator = (a); |
|
69 return *this; |
|
70 } |
|
71 |
|
72 // operator Array2<Complex>& () const { return *this; } |
|
73 |
|
74 int operator == (const ComplexMatrix& a) const; |
|
75 int operator != (const ComplexMatrix& a) const; |
|
76 |
|
77 // destructive insert/delete/reorder operations |
|
78 |
|
79 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
80 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
81 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
82 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
83 |
|
84 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
85 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
86 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
87 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
88 |
|
89 ComplexMatrix& fill (double val); |
|
90 ComplexMatrix& fill (const Complex& val); |
|
91 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
92 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
93 |
|
94 ComplexMatrix append (const Matrix& a) const; |
|
95 ComplexMatrix append (const RowVector& a) const; |
|
96 ComplexMatrix append (const ColumnVector& a) const; |
|
97 ComplexMatrix append (const DiagMatrix& a) const; |
|
98 |
|
99 ComplexMatrix append (const ComplexMatrix& a) const; |
|
100 ComplexMatrix append (const ComplexRowVector& a) const; |
|
101 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
102 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
103 |
|
104 ComplexMatrix stack (const Matrix& a) const; |
|
105 ComplexMatrix stack (const RowVector& a) const; |
|
106 ComplexMatrix stack (const ColumnVector& a) const; |
|
107 ComplexMatrix stack (const DiagMatrix& a) const; |
|
108 |
|
109 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
110 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
111 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
112 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
113 |
|
114 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
|
115 ComplexMatrix transpose (void) const; |
|
116 |
|
117 friend Matrix real (const ComplexMatrix& a); |
|
118 friend Matrix imag (const ComplexMatrix& a); |
|
119 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
120 |
|
121 // resize is the destructive equivalent for this one |
|
122 |
|
123 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
124 |
|
125 // extract row or column i. |
|
126 |
|
127 ComplexRowVector row (int i) const; |
|
128 ComplexRowVector row (char *s) const; |
|
129 |
|
130 ComplexColumnVector column (int i) const; |
|
131 ComplexColumnVector column (char *s) const; |
|
132 |
|
133 ComplexMatrix inverse (void) const; |
|
134 ComplexMatrix inverse (int& info) const; |
|
135 ComplexMatrix inverse (int& info, double& rcond) const; |
|
136 |
|
137 ComplexMatrix fourier (void) const; |
|
138 ComplexMatrix ifourier (void) const; |
|
139 |
|
140 ComplexDET determinant (void) const; |
|
141 ComplexDET determinant (int& info) const; |
|
142 ComplexDET determinant (int& info, double& rcond) const; |
|
143 |
|
144 ComplexMatrix solve (const Matrix& b) const; |
|
145 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
146 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
147 |
|
148 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
149 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
150 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
151 |
|
152 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
153 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
154 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
155 double& rcond) const; |
|
156 |
|
157 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
158 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
159 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
160 int& rank) const; |
|
161 |
|
162 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
163 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
164 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
165 int& rank) const; |
|
166 |
|
167 // matrix by diagonal matrix -> matrix operations |
|
168 |
|
169 ComplexMatrix& operator += (const DiagMatrix& a); |
|
170 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
171 |
|
172 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
173 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
174 |
|
175 // matrix by matrix -> matrix operations |
|
176 |
|
177 ComplexMatrix& operator += (const Matrix& a); |
|
178 ComplexMatrix& operator -= (const Matrix& a); |
|
179 |
|
180 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
181 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
182 |
|
183 // unary operations |
|
184 |
|
185 Matrix operator ! (void) const; |
|
186 |
|
187 // matrix by scalar -> matrix operations |
|
188 |
|
189 friend ComplexMatrix operator + (const ComplexMatrix& a, double s); |
|
190 friend ComplexMatrix operator - (const ComplexMatrix& a, double s); |
|
191 friend ComplexMatrix operator * (const ComplexMatrix& a, double s); |
|
192 friend ComplexMatrix operator / (const ComplexMatrix& a, double s); |
|
193 |
|
194 // scalar by matrix -> matrix operations |
|
195 |
|
196 friend ComplexMatrix operator + (double s, const ComplexMatrix& a); |
|
197 friend ComplexMatrix operator - (double s, const ComplexMatrix& a); |
|
198 friend ComplexMatrix operator * (double s, const ComplexMatrix& a); |
|
199 friend ComplexMatrix operator / (double s, const ComplexMatrix& a); |
|
200 |
|
201 // matrix by column vector -> column vector operations |
|
202 |
|
203 friend ComplexColumnVector operator * (const ComplexMatrix& a, |
|
204 const ColumnVector& b); |
|
205 |
|
206 friend ComplexColumnVector operator * (const ComplexMatrix& a, |
|
207 const ComplexColumnVector& b); |
|
208 |
|
209 // matrix by diagonal matrix -> matrix operations |
|
210 |
|
211 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
212 const DiagMatrix& b); |
|
213 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
214 const DiagMatrix& b); |
|
215 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
216 const DiagMatrix& b); |
|
217 |
|
218 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
219 const ComplexDiagMatrix& b); |
|
220 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
221 const ComplexDiagMatrix& b); |
|
222 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
223 const ComplexDiagMatrix& b); |
|
224 |
|
225 // matrix by matrix -> matrix operations |
|
226 |
|
227 friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b); |
|
228 friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b); |
|
229 |
|
230 friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b); |
|
231 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
232 const ComplexMatrix& b); |
|
233 |
|
234 friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b); |
|
235 friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b); |
|
236 |
|
237 // other operations |
|
238 |
|
239 friend ComplexMatrix map (c_c_Mapper f, const ComplexMatrix& a); |
|
240 friend Matrix map (d_c_Mapper f, const ComplexMatrix& a); |
|
241 void map (c_c_Mapper f); |
|
242 |
|
243 Matrix all (void) const; |
|
244 Matrix any (void) const; |
|
245 |
|
246 ComplexMatrix cumprod (void) const; |
|
247 ComplexMatrix cumsum (void) const; |
|
248 ComplexMatrix prod (void) const; |
|
249 ComplexMatrix sum (void) const; |
|
250 ComplexMatrix sumsq (void) const; |
|
251 |
|
252 ComplexColumnVector diag (void) const; |
|
253 ComplexColumnVector diag (int k) const; |
|
254 |
|
255 ComplexColumnVector row_min (void) const; |
|
256 ComplexColumnVector row_min_loc (void) const; |
|
257 |
|
258 ComplexColumnVector row_max (void) const; |
|
259 ComplexColumnVector row_max_loc (void) const; |
|
260 |
|
261 ComplexRowVector column_min (void) const; |
|
262 ComplexRowVector column_min_loc (void) const; |
|
263 |
|
264 ComplexRowVector column_max (void) const; |
|
265 ComplexRowVector column_max_loc (void) const; |
|
266 |
|
267 // i/o |
|
268 |
|
269 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
270 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
271 |
|
272 #define KLUDGE_MATRICES |
|
273 #define TYPE Complex |
|
274 #define KL_MAT_TYPE ComplexMatrix |
|
275 #include "mx-kludge.h" |
|
276 #undef KLUDGE_MATRICES |
|
277 #undef TYPE |
|
278 #undef KL_MAT_TYPE |
|
279 |
|
280 private: |
|
281 |
|
282 ComplexMatrix (Complex *d, int r, int c) : Array2<Complex> (d, r, c) { } |
|
283 }; |
|
284 |
|
285 } // extern "C++" |
|
286 |
|
287 #endif |
|
288 |
|
289 /* |
|
290 ;;; Local Variables: *** |
|
291 ;;; mode: C++ *** |
|
292 ;;; page-delimiter: "^/\\*" *** |
|
293 ;;; End: *** |
|
294 */ |