458
|
1 /* |
|
2 |
1882
|
3 Copyright (C) 1996 John W. Eaton |
458
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
458
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_ComplexMatrix_h) |
|
24 #define octave_ComplexMatrix_h 1 |
|
25 |
1296
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
1989
|
30 #include "MArray2.h" |
|
31 #include "MDiagArray2.h" |
458
|
32 |
|
33 #include "mx-defs.h" |
1650
|
34 #include "oct-cmplx.h" |
458
|
35 |
1214
|
36 class ComplexMatrix : public MArray2<Complex> |
458
|
37 { |
1205
|
38 friend class Matrix; |
532
|
39 friend class ComplexCHOL; |
|
40 friend class ComplexHESS; |
458
|
41 friend class ComplexLU; |
532
|
42 friend class ComplexQR; |
536
|
43 friend class ComplexQRP; |
532
|
44 friend class ComplexSCHUR; |
458
|
45 friend class ComplexSVD; |
|
46 |
|
47 public: |
|
48 |
1214
|
49 ComplexMatrix (void) : MArray2<Complex> () { } |
|
50 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { } |
458
|
51 ComplexMatrix (int r, int c, const Complex& val) |
1214
|
52 : MArray2<Complex> (r, c, val) { } |
458
|
53 ComplexMatrix (const Matrix& a); |
1214
|
54 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { } |
|
55 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { } |
2349
|
56 ComplexMatrix (const RowVector& rv); |
|
57 ComplexMatrix (const ColumnVector& cv); |
458
|
58 ComplexMatrix (const DiagMatrix& a); |
1989
|
59 // ComplexMatrix (const MDiagArray2<Complex>& a) : MArray2<Complex> (a) { } |
2349
|
60 ComplexMatrix (const ComplexRowVector& rv); |
|
61 ComplexMatrix (const ComplexColumnVector& cv); |
458
|
62 ComplexMatrix (const ComplexDiagMatrix& a); |
|
63 |
1574
|
64 ComplexMatrix (const charMatrix& a); |
|
65 |
458
|
66 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
67 { |
1214
|
68 MArray2<Complex>::operator = (a); |
458
|
69 return *this; |
|
70 } |
|
71 |
2384
|
72 bool operator == (const ComplexMatrix& a) const; |
|
73 bool operator != (const ComplexMatrix& a) const; |
458
|
74 |
2815
|
75 bool is_hermitian (void) const; |
|
76 |
1359
|
77 // destructive insert/delete/reorder operations |
458
|
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 ComplexMatrix conj (const ComplexMatrix& a); |
|
118 |
1359
|
119 // resize is the destructive equivalent for this one |
458
|
120 |
|
121 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
122 |
1359
|
123 // extract row or column i. |
458
|
124 |
|
125 ComplexRowVector row (int i) const; |
|
126 ComplexRowVector row (char *s) const; |
|
127 |
|
128 ComplexColumnVector column (int i) const; |
|
129 ComplexColumnVector column (char *s) const; |
|
130 |
|
131 ComplexMatrix inverse (void) const; |
|
132 ComplexMatrix inverse (int& info) const; |
1656
|
133 ComplexMatrix inverse (int& info, double& rcond, int force = 0) const; |
458
|
134 |
740
|
135 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
136 |
458
|
137 ComplexMatrix fourier (void) const; |
|
138 ComplexMatrix ifourier (void) const; |
|
139 |
677
|
140 ComplexMatrix fourier2d (void) const; |
|
141 ComplexMatrix ifourier2d (void) const; |
|
142 |
458
|
143 ComplexDET determinant (void) const; |
|
144 ComplexDET determinant (int& info) const; |
|
145 ComplexDET determinant (int& info, double& rcond) const; |
|
146 |
|
147 ComplexMatrix solve (const Matrix& b) const; |
|
148 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
149 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
150 |
|
151 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
152 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
153 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
154 |
|
155 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
156 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
157 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
158 double& rcond) const; |
|
159 |
|
160 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
161 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
162 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
163 int& rank) const; |
|
164 |
|
165 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
166 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
167 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
168 int& rank) const; |
|
169 |
1819
|
170 ComplexMatrix expm (void) const; |
|
171 |
1359
|
172 // column vector by row vector -> matrix operations |
1205
|
173 |
|
174 friend ComplexMatrix operator * (const ColumnVector& a, |
|
175 const ComplexRowVector& b); |
|
176 |
|
177 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
178 const RowVector& b); |
|
179 |
|
180 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
181 const ComplexRowVector& b); |
|
182 |
1359
|
183 // diagonal matrix by scalar -> matrix operations |
1205
|
184 |
|
185 friend ComplexMatrix operator + (const DiagMatrix& a, const Complex& s); |
|
186 friend ComplexMatrix operator - (const DiagMatrix& a, const Complex& s); |
|
187 |
|
188 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, double s); |
|
189 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, double s); |
|
190 |
|
191 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
192 const Complex& s); |
|
193 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
194 const Complex& s); |
|
195 |
1359
|
196 // scalar by diagonal matrix -> matrix operations |
1205
|
197 |
|
198 friend ComplexMatrix operator + (const Complex& s, const DiagMatrix& a); |
|
199 friend ComplexMatrix operator - (const Complex& s, const DiagMatrix& a); |
|
200 |
|
201 friend ComplexMatrix operator + (double s, const ComplexDiagMatrix& a); |
|
202 friend ComplexMatrix operator - (double s, const ComplexDiagMatrix& a); |
|
203 |
|
204 friend ComplexMatrix operator + (const Complex& s, |
|
205 const ComplexDiagMatrix& a); |
|
206 friend ComplexMatrix operator - (const Complex& s, |
|
207 const ComplexDiagMatrix& a); |
|
208 |
1359
|
209 // matrix by diagonal matrix -> matrix operations |
458
|
210 |
|
211 ComplexMatrix& operator += (const DiagMatrix& a); |
|
212 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
213 |
|
214 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
215 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
216 |
1205
|
217 friend ComplexMatrix operator + (const Matrix& a, |
|
218 const ComplexDiagMatrix& b); |
|
219 friend ComplexMatrix operator - (const Matrix& a, |
|
220 const ComplexDiagMatrix& b); |
|
221 friend ComplexMatrix operator * (const Matrix& a, |
|
222 const ComplexDiagMatrix& b); |
|
223 |
1359
|
224 // diagonal matrix by matrix -> matrix operations |
1205
|
225 |
|
226 friend ComplexMatrix operator + (const DiagMatrix& a, |
|
227 const ComplexMatrix& b); |
|
228 friend ComplexMatrix operator - (const DiagMatrix& a, |
|
229 const ComplexMatrix& b); |
|
230 friend ComplexMatrix operator * (const DiagMatrix& a, |
|
231 const ComplexMatrix& b); |
|
232 |
|
233 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
234 const Matrix& b); |
|
235 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
236 const Matrix& b); |
|
237 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
238 const Matrix& b); |
|
239 |
|
240 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
241 const ComplexMatrix& b); |
|
242 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
243 const ComplexMatrix& b); |
|
244 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
245 const ComplexMatrix& b); |
|
246 |
1359
|
247 // matrix by matrix -> matrix operations |
458
|
248 |
|
249 ComplexMatrix& operator += (const Matrix& a); |
|
250 ComplexMatrix& operator -= (const Matrix& a); |
|
251 |
|
252 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
253 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
254 |
1359
|
255 // unary operations |
458
|
256 |
|
257 Matrix operator ! (void) const; |
|
258 |
1361
|
259 // matrix by scalar -> matrix operations |
458
|
260 |
1205
|
261 friend ComplexMatrix operator + (const Matrix& a, const Complex& s); |
|
262 friend ComplexMatrix operator - (const Matrix& a, const Complex& s); |
|
263 friend ComplexMatrix operator * (const Matrix& a, const Complex& s); |
|
264 friend ComplexMatrix operator / (const Matrix& a, const Complex& s); |
|
265 |
458
|
266 friend ComplexMatrix operator + (const ComplexMatrix& a, double s); |
|
267 friend ComplexMatrix operator - (const ComplexMatrix& a, double s); |
|
268 friend ComplexMatrix operator * (const ComplexMatrix& a, double s); |
|
269 friend ComplexMatrix operator / (const ComplexMatrix& a, double s); |
|
270 |
1359
|
271 // scalar by matrix -> matrix operations |
458
|
272 |
|
273 friend ComplexMatrix operator + (double s, const ComplexMatrix& a); |
|
274 friend ComplexMatrix operator - (double s, const ComplexMatrix& a); |
|
275 friend ComplexMatrix operator * (double s, const ComplexMatrix& a); |
|
276 friend ComplexMatrix operator / (double s, const ComplexMatrix& a); |
|
277 |
1205
|
278 friend ComplexMatrix operator + (const Complex& s, const Matrix& a); |
|
279 friend ComplexMatrix operator - (const Complex& s, const Matrix& a); |
|
280 friend ComplexMatrix operator * (const Complex& s, const Matrix& a); |
|
281 friend ComplexMatrix operator / (const Complex& s, const Matrix& a); |
458
|
282 |
1359
|
283 // matrix by diagonal matrix -> matrix operations |
458
|
284 |
|
285 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
286 const DiagMatrix& b); |
|
287 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
288 const DiagMatrix& b); |
|
289 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
290 const DiagMatrix& b); |
|
291 |
|
292 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
293 const ComplexDiagMatrix& b); |
|
294 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
295 const ComplexDiagMatrix& b); |
|
296 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
297 const ComplexDiagMatrix& b); |
|
298 |
1359
|
299 // matrix by matrix -> matrix operations |
458
|
300 |
|
301 friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b); |
|
302 friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b); |
|
303 |
1205
|
304 friend ComplexMatrix operator + (const Matrix& a, const ComplexMatrix& b); |
|
305 friend ComplexMatrix operator - (const Matrix& a, const ComplexMatrix& b); |
|
306 |
458
|
307 friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b); |
1205
|
308 |
|
309 friend ComplexMatrix operator * (const Matrix& a, const ComplexMatrix& b); |
|
310 |
458
|
311 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
312 const ComplexMatrix& b); |
|
313 |
|
314 friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b); |
|
315 friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b); |
|
316 |
1205
|
317 friend ComplexMatrix product (const Matrix& a, const ComplexMatrix& b); |
|
318 friend ComplexMatrix quotient (const Matrix& a, const ComplexMatrix& b); |
|
319 |
1359
|
320 // other operations |
458
|
321 |
2676
|
322 ComplexMatrix map (c_c_Mapper f) const; |
|
323 Matrix map (d_c_Mapper f) const; |
|
324 |
|
325 ComplexMatrix& apply (c_c_Mapper f); |
458
|
326 |
2384
|
327 bool any_element_is_inf_or_nan (void) const; |
2408
|
328 bool all_elements_are_real (void) const; |
2384
|
329 bool all_integers (double& max_val, double& min_val) const; |
|
330 bool too_large_for_float (void) const; |
1963
|
331 |
458
|
332 Matrix all (void) const; |
|
333 Matrix any (void) const; |
|
334 |
|
335 ComplexMatrix cumprod (void) const; |
|
336 ComplexMatrix cumsum (void) const; |
|
337 ComplexMatrix prod (void) const; |
|
338 ComplexMatrix sum (void) const; |
|
339 ComplexMatrix sumsq (void) const; |
|
340 |
|
341 ComplexColumnVector diag (void) const; |
|
342 ComplexColumnVector diag (int k) const; |
|
343 |
2354
|
344 bool row_is_real_only (int) const; |
|
345 bool column_is_real_only (int) const; |
458
|
346 |
2354
|
347 ComplexColumnVector row_min (void) const; |
458
|
348 ComplexColumnVector row_max (void) const; |
2354
|
349 |
|
350 ComplexColumnVector row_min (Array<int>& index) const; |
|
351 ComplexColumnVector row_max (Array<int>& index) const; |
458
|
352 |
|
353 ComplexRowVector column_min (void) const; |
2354
|
354 ComplexRowVector column_max (void) const; |
458
|
355 |
2354
|
356 ComplexRowVector column_min (Array<int>& index) const; |
|
357 ComplexRowVector column_max (Array<int>& index) const; |
458
|
358 |
1359
|
359 // i/o |
458
|
360 |
|
361 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
362 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
363 |
|
364 private: |
|
365 |
1214
|
366 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
367 }; |
|
368 |
1819
|
369 ComplexMatrix Givens (const Complex&, const Complex&); |
|
370 |
|
371 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&, |
|
372 const ComplexMatrix&); |
|
373 |
458
|
374 #endif |
|
375 |
|
376 /* |
|
377 ;;; Local Variables: *** |
|
378 ;;; mode: C++ *** |
|
379 ;;; End: *** |
|
380 */ |