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 |
|
72 int operator == (const ComplexMatrix& a) const; |
|
73 int operator != (const ComplexMatrix& a) const; |
|
74 |
1359
|
75 // destructive insert/delete/reorder operations |
458
|
76 |
|
77 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
78 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
79 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
80 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
81 |
|
82 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
83 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
84 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
85 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
86 |
|
87 ComplexMatrix& fill (double val); |
|
88 ComplexMatrix& fill (const Complex& val); |
|
89 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
90 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
91 |
|
92 ComplexMatrix append (const Matrix& a) const; |
|
93 ComplexMatrix append (const RowVector& a) const; |
|
94 ComplexMatrix append (const ColumnVector& a) const; |
|
95 ComplexMatrix append (const DiagMatrix& a) const; |
|
96 |
|
97 ComplexMatrix append (const ComplexMatrix& a) const; |
|
98 ComplexMatrix append (const ComplexRowVector& a) const; |
|
99 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
100 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
101 |
|
102 ComplexMatrix stack (const Matrix& a) const; |
|
103 ComplexMatrix stack (const RowVector& a) const; |
|
104 ComplexMatrix stack (const ColumnVector& a) const; |
|
105 ComplexMatrix stack (const DiagMatrix& a) const; |
|
106 |
|
107 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
108 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
109 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
110 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
111 |
|
112 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
|
113 ComplexMatrix transpose (void) const; |
|
114 |
|
115 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
116 |
1359
|
117 // resize is the destructive equivalent for this one |
458
|
118 |
|
119 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
120 |
1359
|
121 // extract row or column i. |
458
|
122 |
|
123 ComplexRowVector row (int i) const; |
|
124 ComplexRowVector row (char *s) const; |
|
125 |
|
126 ComplexColumnVector column (int i) const; |
|
127 ComplexColumnVector column (char *s) const; |
|
128 |
|
129 ComplexMatrix inverse (void) const; |
|
130 ComplexMatrix inverse (int& info) const; |
1656
|
131 ComplexMatrix inverse (int& info, double& rcond, int force = 0) const; |
458
|
132 |
740
|
133 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
134 |
458
|
135 ComplexMatrix fourier (void) const; |
|
136 ComplexMatrix ifourier (void) const; |
|
137 |
677
|
138 ComplexMatrix fourier2d (void) const; |
|
139 ComplexMatrix ifourier2d (void) const; |
|
140 |
458
|
141 ComplexDET determinant (void) const; |
|
142 ComplexDET determinant (int& info) const; |
|
143 ComplexDET determinant (int& info, double& rcond) const; |
|
144 |
|
145 ComplexMatrix solve (const Matrix& b) const; |
|
146 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
147 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
148 |
|
149 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
150 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
151 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
152 |
|
153 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
154 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
155 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
156 double& rcond) const; |
|
157 |
|
158 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
159 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
160 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
161 int& rank) const; |
|
162 |
|
163 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
164 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
165 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
166 int& rank) const; |
|
167 |
1819
|
168 ComplexMatrix expm (void) const; |
|
169 |
1359
|
170 // column vector by row vector -> matrix operations |
1205
|
171 |
|
172 friend ComplexMatrix operator * (const ColumnVector& a, |
|
173 const ComplexRowVector& b); |
|
174 |
|
175 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
176 const RowVector& b); |
|
177 |
|
178 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
179 const ComplexRowVector& b); |
|
180 |
1359
|
181 // diagonal matrix by scalar -> matrix operations |
1205
|
182 |
|
183 friend ComplexMatrix operator + (const DiagMatrix& a, const Complex& s); |
|
184 friend ComplexMatrix operator - (const DiagMatrix& a, const Complex& s); |
|
185 |
|
186 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, double s); |
|
187 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, double s); |
|
188 |
|
189 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
190 const Complex& s); |
|
191 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
192 const Complex& s); |
|
193 |
1359
|
194 // scalar by diagonal matrix -> matrix operations |
1205
|
195 |
|
196 friend ComplexMatrix operator + (const Complex& s, const DiagMatrix& a); |
|
197 friend ComplexMatrix operator - (const Complex& s, const DiagMatrix& a); |
|
198 |
|
199 friend ComplexMatrix operator + (double s, const ComplexDiagMatrix& a); |
|
200 friend ComplexMatrix operator - (double s, const ComplexDiagMatrix& a); |
|
201 |
|
202 friend ComplexMatrix operator + (const Complex& s, |
|
203 const ComplexDiagMatrix& a); |
|
204 friend ComplexMatrix operator - (const Complex& s, |
|
205 const ComplexDiagMatrix& a); |
|
206 |
1359
|
207 // matrix by diagonal matrix -> matrix operations |
458
|
208 |
|
209 ComplexMatrix& operator += (const DiagMatrix& a); |
|
210 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
211 |
|
212 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
213 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
214 |
1205
|
215 friend ComplexMatrix operator + (const Matrix& a, |
|
216 const ComplexDiagMatrix& b); |
|
217 friend ComplexMatrix operator - (const Matrix& a, |
|
218 const ComplexDiagMatrix& b); |
|
219 friend ComplexMatrix operator * (const Matrix& a, |
|
220 const ComplexDiagMatrix& b); |
|
221 |
1359
|
222 // diagonal matrix by matrix -> matrix operations |
1205
|
223 |
|
224 friend ComplexMatrix operator + (const DiagMatrix& a, |
|
225 const ComplexMatrix& b); |
|
226 friend ComplexMatrix operator - (const DiagMatrix& a, |
|
227 const ComplexMatrix& b); |
|
228 friend ComplexMatrix operator * (const DiagMatrix& a, |
|
229 const ComplexMatrix& b); |
|
230 |
|
231 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
232 const Matrix& b); |
|
233 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
234 const Matrix& b); |
|
235 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
236 const Matrix& b); |
|
237 |
|
238 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
239 const ComplexMatrix& b); |
|
240 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
241 const ComplexMatrix& b); |
|
242 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
243 const ComplexMatrix& b); |
|
244 |
1359
|
245 // matrix by matrix -> matrix operations |
458
|
246 |
|
247 ComplexMatrix& operator += (const Matrix& a); |
|
248 ComplexMatrix& operator -= (const Matrix& a); |
|
249 |
|
250 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
251 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
252 |
1359
|
253 // unary operations |
458
|
254 |
|
255 Matrix operator ! (void) const; |
|
256 |
1361
|
257 // matrix by scalar -> matrix operations |
458
|
258 |
1205
|
259 friend ComplexMatrix operator + (const Matrix& a, const Complex& s); |
|
260 friend ComplexMatrix operator - (const Matrix& a, const Complex& s); |
|
261 friend ComplexMatrix operator * (const Matrix& a, const Complex& s); |
|
262 friend ComplexMatrix operator / (const Matrix& a, const Complex& s); |
|
263 |
458
|
264 friend ComplexMatrix operator + (const ComplexMatrix& a, double s); |
|
265 friend ComplexMatrix operator - (const ComplexMatrix& a, double s); |
|
266 friend ComplexMatrix operator * (const ComplexMatrix& a, double s); |
|
267 friend ComplexMatrix operator / (const ComplexMatrix& a, double s); |
|
268 |
1359
|
269 // scalar by matrix -> matrix operations |
458
|
270 |
|
271 friend ComplexMatrix operator + (double s, const ComplexMatrix& a); |
|
272 friend ComplexMatrix operator - (double s, const ComplexMatrix& a); |
|
273 friend ComplexMatrix operator * (double s, const ComplexMatrix& a); |
|
274 friend ComplexMatrix operator / (double s, const ComplexMatrix& a); |
|
275 |
1205
|
276 friend ComplexMatrix operator + (const Complex& s, const Matrix& a); |
|
277 friend ComplexMatrix operator - (const Complex& s, const Matrix& a); |
|
278 friend ComplexMatrix operator * (const Complex& s, const Matrix& a); |
|
279 friend ComplexMatrix operator / (const Complex& s, const Matrix& a); |
458
|
280 |
1359
|
281 // matrix by diagonal matrix -> matrix operations |
458
|
282 |
|
283 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
284 const DiagMatrix& b); |
|
285 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
286 const DiagMatrix& b); |
|
287 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
288 const DiagMatrix& b); |
|
289 |
|
290 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
291 const ComplexDiagMatrix& b); |
|
292 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
293 const ComplexDiagMatrix& b); |
|
294 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
295 const ComplexDiagMatrix& b); |
|
296 |
1359
|
297 // matrix by matrix -> matrix operations |
458
|
298 |
|
299 friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b); |
|
300 friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b); |
|
301 |
1205
|
302 friend ComplexMatrix operator + (const Matrix& a, const ComplexMatrix& b); |
|
303 friend ComplexMatrix operator - (const Matrix& a, const ComplexMatrix& b); |
|
304 |
458
|
305 friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b); |
1205
|
306 |
|
307 friend ComplexMatrix operator * (const Matrix& a, const ComplexMatrix& b); |
|
308 |
458
|
309 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
310 const ComplexMatrix& b); |
|
311 |
|
312 friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b); |
|
313 friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b); |
|
314 |
1205
|
315 friend ComplexMatrix product (const Matrix& a, const ComplexMatrix& b); |
|
316 friend ComplexMatrix quotient (const Matrix& a, const ComplexMatrix& b); |
|
317 |
1359
|
318 // other operations |
458
|
319 |
|
320 friend ComplexMatrix map (c_c_Mapper f, const ComplexMatrix& a); |
|
321 void map (c_c_Mapper f); |
|
322 |
1963
|
323 int all_integers (double& max_val, double& min_val) const; |
|
324 int too_large_for_float (void) const; |
|
325 |
458
|
326 Matrix all (void) const; |
|
327 Matrix any (void) const; |
|
328 |
|
329 ComplexMatrix cumprod (void) const; |
|
330 ComplexMatrix cumsum (void) const; |
|
331 ComplexMatrix prod (void) const; |
|
332 ComplexMatrix sum (void) const; |
|
333 ComplexMatrix sumsq (void) const; |
|
334 |
|
335 ComplexColumnVector diag (void) const; |
|
336 ComplexColumnVector diag (int k) const; |
|
337 |
2354
|
338 bool row_is_real_only (int) const; |
|
339 bool column_is_real_only (int) const; |
458
|
340 |
2354
|
341 ComplexColumnVector row_min (void) const; |
458
|
342 ComplexColumnVector row_max (void) const; |
2354
|
343 |
|
344 ComplexColumnVector row_min (Array<int>& index) const; |
|
345 ComplexColumnVector row_max (Array<int>& index) const; |
458
|
346 |
|
347 ComplexRowVector column_min (void) const; |
2354
|
348 ComplexRowVector column_max (void) const; |
458
|
349 |
2354
|
350 ComplexRowVector column_min (Array<int>& index) const; |
|
351 ComplexRowVector column_max (Array<int>& index) const; |
458
|
352 |
1359
|
353 // i/o |
458
|
354 |
|
355 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
356 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
357 |
|
358 private: |
|
359 |
1214
|
360 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
361 }; |
|
362 |
1819
|
363 ComplexMatrix Givens (const Complex&, const Complex&); |
|
364 |
|
365 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&, |
|
366 const ComplexMatrix&); |
|
367 |
458
|
368 #endif |
|
369 |
|
370 /* |
|
371 ;;; Local Variables: *** |
|
372 ;;; mode: C++ *** |
|
373 ;;; End: *** |
|
374 */ |