458
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
458
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
458
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_ComplexMatrix_h) |
|
25 #define octave_ComplexMatrix_h 1 |
|
26 |
1296
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
458
|
31 #include <Complex.h> |
|
32 |
1214
|
33 #include "MArray.h" |
458
|
34 |
|
35 #include "mx-defs.h" |
|
36 |
1214
|
37 class ComplexMatrix : public MArray2<Complex> |
458
|
38 { |
1205
|
39 friend class Matrix; |
532
|
40 friend class ComplexCHOL; |
|
41 friend class ComplexHESS; |
458
|
42 friend class ComplexLU; |
532
|
43 friend class ComplexQR; |
536
|
44 friend class ComplexQRP; |
532
|
45 friend class ComplexSCHUR; |
458
|
46 friend class ComplexSVD; |
|
47 |
|
48 public: |
|
49 |
1214
|
50 ComplexMatrix (void) : MArray2<Complex> () { } |
|
51 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { } |
458
|
52 ComplexMatrix (int r, int c, const Complex& val) |
1214
|
53 : MArray2<Complex> (r, c, val) { } |
458
|
54 ComplexMatrix (const Matrix& a); |
1214
|
55 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { } |
|
56 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { } |
458
|
57 ComplexMatrix (const DiagMatrix& a); |
1214
|
58 ComplexMatrix (const MDiagArray<Complex>& a) : MArray2<Complex> (a) { } |
458
|
59 ComplexMatrix (const ComplexDiagMatrix& a); |
|
60 |
|
61 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
62 { |
1214
|
63 MArray2<Complex>::operator = (a); |
458
|
64 return *this; |
|
65 } |
|
66 |
|
67 int operator == (const ComplexMatrix& a) const; |
|
68 int operator != (const ComplexMatrix& a) const; |
|
69 |
1359
|
70 // destructive insert/delete/reorder operations |
458
|
71 |
|
72 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
73 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
74 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
75 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
76 |
|
77 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
78 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
79 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
80 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
81 |
|
82 ComplexMatrix& fill (double val); |
|
83 ComplexMatrix& fill (const Complex& val); |
|
84 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
85 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
86 |
|
87 ComplexMatrix append (const Matrix& a) const; |
|
88 ComplexMatrix append (const RowVector& a) const; |
|
89 ComplexMatrix append (const ColumnVector& a) const; |
|
90 ComplexMatrix append (const DiagMatrix& a) const; |
|
91 |
|
92 ComplexMatrix append (const ComplexMatrix& a) const; |
|
93 ComplexMatrix append (const ComplexRowVector& a) const; |
|
94 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
95 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
96 |
|
97 ComplexMatrix stack (const Matrix& a) const; |
|
98 ComplexMatrix stack (const RowVector& a) const; |
|
99 ComplexMatrix stack (const ColumnVector& a) const; |
|
100 ComplexMatrix stack (const DiagMatrix& a) const; |
|
101 |
|
102 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
103 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
104 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
105 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
106 |
|
107 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
|
108 ComplexMatrix transpose (void) const; |
|
109 |
|
110 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
111 |
1359
|
112 // resize is the destructive equivalent for this one |
458
|
113 |
|
114 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
115 |
1359
|
116 // extract row or column i. |
458
|
117 |
|
118 ComplexRowVector row (int i) const; |
|
119 ComplexRowVector row (char *s) const; |
|
120 |
|
121 ComplexColumnVector column (int i) const; |
|
122 ComplexColumnVector column (char *s) const; |
|
123 |
|
124 ComplexMatrix inverse (void) const; |
|
125 ComplexMatrix inverse (int& info) const; |
|
126 ComplexMatrix inverse (int& info, double& rcond) const; |
|
127 |
740
|
128 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
129 |
458
|
130 ComplexMatrix fourier (void) const; |
|
131 ComplexMatrix ifourier (void) const; |
|
132 |
677
|
133 ComplexMatrix fourier2d (void) const; |
|
134 ComplexMatrix ifourier2d (void) const; |
|
135 |
458
|
136 ComplexDET determinant (void) const; |
|
137 ComplexDET determinant (int& info) const; |
|
138 ComplexDET determinant (int& info, double& rcond) const; |
|
139 |
|
140 ComplexMatrix solve (const Matrix& b) const; |
|
141 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
142 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
143 |
|
144 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
145 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
146 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
147 |
|
148 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
149 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
150 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
151 double& rcond) const; |
|
152 |
|
153 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
154 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
155 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
156 int& rank) const; |
|
157 |
|
158 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
159 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
160 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
161 int& rank) const; |
|
162 |
1359
|
163 // column vector by row vector -> matrix operations |
1205
|
164 |
|
165 friend ComplexMatrix operator * (const ColumnVector& a, |
|
166 const ComplexRowVector& b); |
|
167 |
|
168 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
169 const RowVector& b); |
|
170 |
|
171 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
172 const ComplexRowVector& b); |
|
173 |
1359
|
174 // diagonal matrix by scalar -> matrix operations |
1205
|
175 |
|
176 friend ComplexMatrix operator + (const DiagMatrix& a, const Complex& s); |
|
177 friend ComplexMatrix operator - (const DiagMatrix& a, const Complex& s); |
|
178 |
|
179 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, double s); |
|
180 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, double s); |
|
181 |
|
182 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
183 const Complex& s); |
|
184 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
185 const Complex& s); |
|
186 |
1359
|
187 // scalar by diagonal matrix -> matrix operations |
1205
|
188 |
|
189 friend ComplexMatrix operator + (const Complex& s, const DiagMatrix& a); |
|
190 friend ComplexMatrix operator - (const Complex& s, const DiagMatrix& a); |
|
191 |
|
192 friend ComplexMatrix operator + (double s, const ComplexDiagMatrix& a); |
|
193 friend ComplexMatrix operator - (double s, const ComplexDiagMatrix& a); |
|
194 |
|
195 friend ComplexMatrix operator + (const Complex& s, |
|
196 const ComplexDiagMatrix& a); |
|
197 friend ComplexMatrix operator - (const Complex& s, |
|
198 const ComplexDiagMatrix& a); |
|
199 |
1359
|
200 // matrix by diagonal matrix -> matrix operations |
458
|
201 |
|
202 ComplexMatrix& operator += (const DiagMatrix& a); |
|
203 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
204 |
|
205 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
206 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
207 |
1205
|
208 friend ComplexMatrix operator + (const Matrix& a, |
|
209 const ComplexDiagMatrix& b); |
|
210 friend ComplexMatrix operator - (const Matrix& a, |
|
211 const ComplexDiagMatrix& b); |
|
212 friend ComplexMatrix operator * (const Matrix& a, |
|
213 const ComplexDiagMatrix& b); |
|
214 |
1359
|
215 // diagonal matrix by matrix -> matrix operations |
1205
|
216 |
|
217 friend ComplexMatrix operator + (const DiagMatrix& a, |
|
218 const ComplexMatrix& b); |
|
219 friend ComplexMatrix operator - (const DiagMatrix& a, |
|
220 const ComplexMatrix& b); |
|
221 friend ComplexMatrix operator * (const DiagMatrix& a, |
|
222 const ComplexMatrix& b); |
|
223 |
|
224 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
225 const Matrix& b); |
|
226 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
227 const Matrix& b); |
|
228 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
229 const Matrix& b); |
|
230 |
|
231 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
232 const ComplexMatrix& b); |
|
233 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
234 const ComplexMatrix& b); |
|
235 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
236 const ComplexMatrix& b); |
|
237 |
1359
|
238 // matrix by matrix -> matrix operations |
458
|
239 |
|
240 ComplexMatrix& operator += (const Matrix& a); |
|
241 ComplexMatrix& operator -= (const Matrix& a); |
|
242 |
|
243 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
244 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
245 |
1359
|
246 // unary operations |
458
|
247 |
|
248 Matrix operator ! (void) const; |
|
249 |
1361
|
250 // matrix by scalar -> matrix operations |
458
|
251 |
1205
|
252 friend ComplexMatrix operator + (const Matrix& a, const Complex& s); |
|
253 friend ComplexMatrix operator - (const Matrix& a, const Complex& s); |
|
254 friend ComplexMatrix operator * (const Matrix& a, const Complex& s); |
|
255 friend ComplexMatrix operator / (const Matrix& a, const Complex& s); |
|
256 |
458
|
257 friend ComplexMatrix operator + (const ComplexMatrix& a, double s); |
|
258 friend ComplexMatrix operator - (const ComplexMatrix& a, double s); |
|
259 friend ComplexMatrix operator * (const ComplexMatrix& a, double s); |
|
260 friend ComplexMatrix operator / (const ComplexMatrix& a, double s); |
|
261 |
1359
|
262 // scalar by matrix -> matrix operations |
458
|
263 |
|
264 friend ComplexMatrix operator + (double s, const ComplexMatrix& a); |
|
265 friend ComplexMatrix operator - (double s, const ComplexMatrix& a); |
|
266 friend ComplexMatrix operator * (double s, const ComplexMatrix& a); |
|
267 friend ComplexMatrix operator / (double s, const ComplexMatrix& a); |
|
268 |
1205
|
269 friend ComplexMatrix operator + (const Complex& s, const Matrix& a); |
|
270 friend ComplexMatrix operator - (const Complex& s, const Matrix& a); |
|
271 friend ComplexMatrix operator * (const Complex& s, const Matrix& a); |
|
272 friend ComplexMatrix operator / (const Complex& s, const Matrix& a); |
458
|
273 |
1359
|
274 // matrix by diagonal matrix -> matrix operations |
458
|
275 |
|
276 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
277 const DiagMatrix& b); |
|
278 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
279 const DiagMatrix& b); |
|
280 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
281 const DiagMatrix& b); |
|
282 |
|
283 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
284 const ComplexDiagMatrix& b); |
|
285 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
286 const ComplexDiagMatrix& b); |
|
287 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
288 const ComplexDiagMatrix& b); |
|
289 |
1359
|
290 // matrix by matrix -> matrix operations |
458
|
291 |
|
292 friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b); |
|
293 friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b); |
|
294 |
1205
|
295 friend ComplexMatrix operator + (const Matrix& a, const ComplexMatrix& b); |
|
296 friend ComplexMatrix operator - (const Matrix& a, const ComplexMatrix& b); |
|
297 |
458
|
298 friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b); |
1205
|
299 |
|
300 friend ComplexMatrix operator * (const Matrix& a, const ComplexMatrix& b); |
|
301 |
458
|
302 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
303 const ComplexMatrix& b); |
|
304 |
|
305 friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b); |
|
306 friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b); |
|
307 |
1205
|
308 friend ComplexMatrix product (const Matrix& a, const ComplexMatrix& b); |
|
309 friend ComplexMatrix quotient (const Matrix& a, const ComplexMatrix& b); |
|
310 |
1359
|
311 // other operations |
458
|
312 |
|
313 friend ComplexMatrix map (c_c_Mapper f, const ComplexMatrix& a); |
|
314 void map (c_c_Mapper f); |
|
315 |
|
316 Matrix all (void) const; |
|
317 Matrix any (void) const; |
|
318 |
|
319 ComplexMatrix cumprod (void) const; |
|
320 ComplexMatrix cumsum (void) const; |
|
321 ComplexMatrix prod (void) const; |
|
322 ComplexMatrix sum (void) const; |
|
323 ComplexMatrix sumsq (void) const; |
|
324 |
|
325 ComplexColumnVector diag (void) const; |
|
326 ComplexColumnVector diag (int k) const; |
|
327 |
|
328 ComplexColumnVector row_min (void) const; |
|
329 ComplexColumnVector row_min_loc (void) const; |
|
330 |
|
331 ComplexColumnVector row_max (void) const; |
|
332 ComplexColumnVector row_max_loc (void) const; |
|
333 |
|
334 ComplexRowVector column_min (void) const; |
|
335 ComplexRowVector column_min_loc (void) const; |
|
336 |
|
337 ComplexRowVector column_max (void) const; |
|
338 ComplexRowVector column_max_loc (void) const; |
|
339 |
1359
|
340 // i/o |
458
|
341 |
|
342 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
343 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
344 |
|
345 private: |
|
346 |
1214
|
347 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
348 }; |
|
349 |
|
350 #endif |
|
351 |
|
352 /* |
|
353 ;;; Local Variables: *** |
|
354 ;;; mode: C++ *** |
|
355 ;;; page-delimiter: "^/\\*" *** |
|
356 ;;; End: *** |
|
357 */ |