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