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