458
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 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 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1296
|
27 #pragma interface |
|
28 #endif |
|
29 |
1989
|
30 #include "MArray2.h" |
|
31 #include "MDiagArray2.h" |
458
|
32 |
|
33 #include "mx-defs.h" |
2870
|
34 #include "mx-op-defs.h" |
1650
|
35 #include "oct-cmplx.h" |
458
|
36 |
3585
|
37 class |
|
38 ComplexMatrix : public MArray2<Complex> |
458
|
39 { |
|
40 public: |
|
41 |
3480
|
42 typedef void (*solve_singularity_handler) (double rcond); |
|
43 |
1214
|
44 ComplexMatrix (void) : MArray2<Complex> () { } |
3585
|
45 |
1214
|
46 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { } |
3585
|
47 |
458
|
48 ComplexMatrix (int r, int c, const Complex& val) |
1214
|
49 : MArray2<Complex> (r, c, val) { } |
3585
|
50 |
1214
|
51 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { } |
3585
|
52 |
|
53 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { } |
|
54 |
|
55 explicit ComplexMatrix (const Matrix& a); |
|
56 |
|
57 explicit ComplexMatrix (const RowVector& rv); |
|
58 |
|
59 explicit ComplexMatrix (const ColumnVector& cv); |
458
|
60 |
3585
|
61 explicit ComplexMatrix (const DiagMatrix& a); |
|
62 |
|
63 explicit ComplexMatrix (const ComplexRowVector& rv); |
|
64 |
|
65 explicit ComplexMatrix (const ComplexColumnVector& cv); |
|
66 |
|
67 explicit ComplexMatrix (const ComplexDiagMatrix& a); |
|
68 |
|
69 explicit ComplexMatrix (const boolMatrix& a); |
|
70 |
|
71 explicit ComplexMatrix (const charMatrix& a); |
1574
|
72 |
458
|
73 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
74 { |
1214
|
75 MArray2<Complex>::operator = (a); |
458
|
76 return *this; |
|
77 } |
|
78 |
2384
|
79 bool operator == (const ComplexMatrix& a) const; |
|
80 bool operator != (const ComplexMatrix& a) const; |
458
|
81 |
2815
|
82 bool is_hermitian (void) const; |
|
83 |
1359
|
84 // destructive insert/delete/reorder operations |
458
|
85 |
|
86 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
87 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
88 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
89 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
90 |
|
91 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
92 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
93 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
94 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
95 |
|
96 ComplexMatrix& fill (double val); |
|
97 ComplexMatrix& fill (const Complex& val); |
|
98 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
99 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
100 |
|
101 ComplexMatrix append (const Matrix& a) const; |
|
102 ComplexMatrix append (const RowVector& a) const; |
|
103 ComplexMatrix append (const ColumnVector& a) const; |
|
104 ComplexMatrix append (const DiagMatrix& a) const; |
|
105 |
|
106 ComplexMatrix append (const ComplexMatrix& a) const; |
|
107 ComplexMatrix append (const ComplexRowVector& a) const; |
|
108 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
109 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
110 |
|
111 ComplexMatrix stack (const Matrix& a) const; |
|
112 ComplexMatrix stack (const RowVector& a) const; |
|
113 ComplexMatrix stack (const ColumnVector& a) const; |
|
114 ComplexMatrix stack (const DiagMatrix& a) const; |
|
115 |
|
116 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
117 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
118 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
119 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
120 |
|
121 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
3225
|
122 ComplexMatrix transpose (void) const |
|
123 { return MArray2<Complex>::transpose (); } |
458
|
124 |
|
125 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
126 |
1359
|
127 // resize is the destructive equivalent for this one |
458
|
128 |
|
129 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
130 |
1359
|
131 // extract row or column i. |
458
|
132 |
|
133 ComplexRowVector row (int i) const; |
|
134 ComplexRowVector row (char *s) const; |
|
135 |
|
136 ComplexColumnVector column (int i) const; |
|
137 ComplexColumnVector column (char *s) const; |
|
138 |
|
139 ComplexMatrix inverse (void) const; |
|
140 ComplexMatrix inverse (int& info) const; |
1656
|
141 ComplexMatrix inverse (int& info, double& rcond, int force = 0) const; |
458
|
142 |
740
|
143 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
144 |
458
|
145 ComplexMatrix fourier (void) const; |
|
146 ComplexMatrix ifourier (void) const; |
|
147 |
677
|
148 ComplexMatrix fourier2d (void) const; |
|
149 ComplexMatrix ifourier2d (void) const; |
|
150 |
458
|
151 ComplexDET determinant (void) const; |
|
152 ComplexDET determinant (int& info) const; |
|
153 ComplexDET determinant (int& info, double& rcond) const; |
|
154 |
|
155 ComplexMatrix solve (const Matrix& b) const; |
|
156 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
157 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
3480
|
158 ComplexMatrix solve (const Matrix& b, int& info, double& rcond, |
|
159 solve_singularity_handler sing_handler) const; |
458
|
160 |
|
161 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
162 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
163 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
3480
|
164 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond, |
|
165 solve_singularity_handler sing_handler) const; |
458
|
166 |
3585
|
167 ComplexColumnVector solve (const ColumnVector& b) const; |
|
168 ComplexColumnVector solve (const ColumnVector& b, int& info) const; |
|
169 ComplexColumnVector solve (const ColumnVector& b, int& info, |
|
170 double& rcond) const; |
|
171 ComplexColumnVector solve (const ColumnVector& b, int& info, double& rcond, |
|
172 solve_singularity_handler sing_handler) const; |
|
173 |
458
|
174 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
175 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
176 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
177 double& rcond) const; |
3480
|
178 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
179 double& rcond, |
|
180 solve_singularity_handler sing_handler) const; |
458
|
181 |
3585
|
182 ComplexMatrix lssolve (const Matrix& b) const; |
|
183 ComplexMatrix lssolve (const Matrix& b, int& info) const; |
|
184 ComplexMatrix lssolve (const Matrix& b, int& info, int& rank) const; |
|
185 |
458
|
186 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
187 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
188 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
189 int& rank) const; |
|
190 |
3585
|
191 ComplexColumnVector lssolve (const ColumnVector& b) const; |
|
192 ComplexColumnVector lssolve (const ColumnVector& b, int& info) const; |
|
193 ComplexColumnVector lssolve (const ColumnVector& b, int& info, |
|
194 int& rank) const; |
|
195 |
458
|
196 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
197 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
198 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
199 int& rank) const; |
|
200 |
1819
|
201 ComplexMatrix expm (void) const; |
|
202 |
1359
|
203 // column vector by row vector -> matrix operations |
1205
|
204 |
|
205 friend ComplexMatrix operator * (const ColumnVector& a, |
|
206 const ComplexRowVector& b); |
|
207 |
|
208 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
209 const RowVector& b); |
|
210 |
|
211 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
212 const ComplexRowVector& b); |
|
213 |
1359
|
214 // matrix by diagonal matrix -> matrix operations |
458
|
215 |
|
216 ComplexMatrix& operator += (const DiagMatrix& a); |
|
217 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
218 |
|
219 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
220 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
221 |
1359
|
222 // matrix by matrix -> matrix operations |
458
|
223 |
|
224 ComplexMatrix& operator += (const Matrix& a); |
|
225 ComplexMatrix& operator -= (const Matrix& a); |
|
226 |
1359
|
227 // unary operations |
458
|
228 |
2964
|
229 boolMatrix operator ! (void) const; |
458
|
230 |
1359
|
231 // other operations |
458
|
232 |
2676
|
233 ComplexMatrix map (c_c_Mapper f) const; |
|
234 Matrix map (d_c_Mapper f) const; |
3248
|
235 boolMatrix map (b_c_Mapper f) const; |
2676
|
236 |
|
237 ComplexMatrix& apply (c_c_Mapper f); |
458
|
238 |
2384
|
239 bool any_element_is_inf_or_nan (void) const; |
2408
|
240 bool all_elements_are_real (void) const; |
2384
|
241 bool all_integers (double& max_val, double& min_val) const; |
|
242 bool too_large_for_float (void) const; |
1963
|
243 |
4017
|
244 boolMatrix all (int dim = -1) const; |
|
245 boolMatrix any (int dim = -1) const; |
458
|
246 |
4017
|
247 ComplexMatrix cumprod (int dim = -1) const; |
|
248 ComplexMatrix cumsum (int dim = -1) const; |
|
249 ComplexMatrix prod (int dim = -1) const; |
|
250 ComplexMatrix sum (int dim = -1) const; |
|
251 ComplexMatrix sumsq (int dim = -1) const; |
458
|
252 |
|
253 ComplexColumnVector diag (void) const; |
|
254 ComplexColumnVector diag (int k) const; |
|
255 |
2354
|
256 bool row_is_real_only (int) const; |
|
257 bool column_is_real_only (int) const; |
458
|
258 |
2354
|
259 ComplexColumnVector row_min (void) const; |
458
|
260 ComplexColumnVector row_max (void) const; |
2354
|
261 |
|
262 ComplexColumnVector row_min (Array<int>& index) const; |
|
263 ComplexColumnVector row_max (Array<int>& index) const; |
458
|
264 |
|
265 ComplexRowVector column_min (void) const; |
2354
|
266 ComplexRowVector column_max (void) const; |
458
|
267 |
2354
|
268 ComplexRowVector column_min (Array<int>& index) const; |
|
269 ComplexRowVector column_max (Array<int>& index) const; |
458
|
270 |
1359
|
271 // i/o |
458
|
272 |
3504
|
273 friend std::ostream& operator << (std::ostream& os, const ComplexMatrix& a); |
|
274 friend std::istream& operator >> (std::istream& is, ComplexMatrix& a); |
458
|
275 |
3933
|
276 static Complex resize_fill_value (void) { return Complex (0.0, 0.0); } |
|
277 |
458
|
278 private: |
|
279 |
1214
|
280 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
281 }; |
|
282 |
1819
|
283 ComplexMatrix Givens (const Complex&, const Complex&); |
|
284 |
|
285 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&, |
|
286 const ComplexMatrix&); |
|
287 |
2828
|
288 extern ComplexMatrix operator * (const Matrix&, const ComplexMatrix&); |
|
289 extern ComplexMatrix operator * (const ComplexMatrix&, const Matrix&); |
|
290 extern ComplexMatrix operator * (const ComplexMatrix&, const ComplexMatrix&); |
|
291 |
4309
|
292 extern ComplexMatrix min (const Complex& c, const ComplexMatrix& m); |
|
293 extern ComplexMatrix min (const ComplexMatrix& m, const Complex& c); |
|
294 extern ComplexMatrix min (const ComplexMatrix& a, const ComplexMatrix& b); |
|
295 |
|
296 extern ComplexMatrix max (const Complex& c, const ComplexMatrix& m); |
|
297 extern ComplexMatrix max (const ComplexMatrix& m, const Complex& c); |
|
298 extern ComplexMatrix max (const ComplexMatrix& a, const ComplexMatrix& b); |
|
299 |
2870
|
300 MS_CMP_OP_DECLS (ComplexMatrix, Complex) |
|
301 MS_BOOL_OP_DECLS (ComplexMatrix, Complex) |
|
302 |
|
303 SM_CMP_OP_DECLS (Complex, ComplexMatrix) |
|
304 SM_BOOL_OP_DECLS (Complex, ComplexMatrix) |
|
305 |
|
306 MM_CMP_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
307 MM_BOOL_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
308 |
3573
|
309 MARRAY_FORWARD_DEFS (MArray2, ComplexMatrix, Complex) |
|
310 |
458
|
311 #endif |
|
312 |
|
313 /* |
|
314 ;;; Local Variables: *** |
|
315 ;;; mode: C++ *** |
|
316 ;;; End: *** |
|
317 */ |