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 |
1989
|
26 #include "MArray2.h" |
|
27 #include "MDiagArray2.h" |
458
|
28 |
|
29 #include "mx-defs.h" |
2870
|
30 #include "mx-op-defs.h" |
1650
|
31 #include "oct-cmplx.h" |
458
|
32 |
3585
|
33 class |
|
34 ComplexMatrix : public MArray2<Complex> |
458
|
35 { |
|
36 public: |
|
37 |
3480
|
38 typedef void (*solve_singularity_handler) (double rcond); |
|
39 |
1214
|
40 ComplexMatrix (void) : MArray2<Complex> () { } |
3585
|
41 |
1214
|
42 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { } |
3585
|
43 |
458
|
44 ComplexMatrix (int r, int c, const Complex& val) |
1214
|
45 : MArray2<Complex> (r, c, val) { } |
3585
|
46 |
1214
|
47 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { } |
3585
|
48 |
|
49 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { } |
|
50 |
|
51 explicit ComplexMatrix (const Matrix& a); |
|
52 |
|
53 explicit ComplexMatrix (const RowVector& rv); |
|
54 |
|
55 explicit ComplexMatrix (const ColumnVector& cv); |
458
|
56 |
3585
|
57 explicit ComplexMatrix (const DiagMatrix& a); |
|
58 |
|
59 explicit ComplexMatrix (const ComplexRowVector& rv); |
|
60 |
|
61 explicit ComplexMatrix (const ComplexColumnVector& cv); |
|
62 |
|
63 explicit ComplexMatrix (const ComplexDiagMatrix& a); |
|
64 |
|
65 explicit ComplexMatrix (const boolMatrix& a); |
|
66 |
|
67 explicit ComplexMatrix (const charMatrix& a); |
1574
|
68 |
458
|
69 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
70 { |
1214
|
71 MArray2<Complex>::operator = (a); |
458
|
72 return *this; |
|
73 } |
|
74 |
2384
|
75 bool operator == (const ComplexMatrix& a) const; |
|
76 bool operator != (const ComplexMatrix& a) const; |
458
|
77 |
2815
|
78 bool is_hermitian (void) const; |
|
79 |
1359
|
80 // destructive insert/delete/reorder operations |
458
|
81 |
|
82 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
83 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
84 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
85 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
86 |
|
87 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
88 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
89 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
90 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
91 |
|
92 ComplexMatrix& fill (double val); |
|
93 ComplexMatrix& fill (const Complex& val); |
|
94 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
95 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
96 |
|
97 ComplexMatrix append (const Matrix& a) const; |
|
98 ComplexMatrix append (const RowVector& a) const; |
|
99 ComplexMatrix append (const ColumnVector& a) const; |
|
100 ComplexMatrix append (const DiagMatrix& a) const; |
|
101 |
|
102 ComplexMatrix append (const ComplexMatrix& a) const; |
|
103 ComplexMatrix append (const ComplexRowVector& a) const; |
|
104 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
105 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
106 |
|
107 ComplexMatrix stack (const Matrix& a) const; |
|
108 ComplexMatrix stack (const RowVector& a) const; |
|
109 ComplexMatrix stack (const ColumnVector& a) const; |
|
110 ComplexMatrix stack (const DiagMatrix& a) const; |
|
111 |
|
112 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
113 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
114 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
115 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
116 |
|
117 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
3225
|
118 ComplexMatrix transpose (void) const |
|
119 { return MArray2<Complex>::transpose (); } |
458
|
120 |
|
121 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
122 |
1359
|
123 // resize is the destructive equivalent for this one |
458
|
124 |
|
125 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
126 |
4316
|
127 ComplexMatrix extract_n (int r1, int c1, int nr, int nc) const; |
|
128 |
1359
|
129 // extract row or column i. |
458
|
130 |
|
131 ComplexRowVector row (int i) const; |
|
132 ComplexRowVector row (char *s) const; |
|
133 |
|
134 ComplexColumnVector column (int i) const; |
|
135 ComplexColumnVector column (char *s) const; |
|
136 |
|
137 ComplexMatrix inverse (void) const; |
|
138 ComplexMatrix inverse (int& info) const; |
4329
|
139 ComplexMatrix inverse (int& info, double& rcond, int force = 0, |
|
140 int calc_cond = 1) const; |
458
|
141 |
4384
|
142 ComplexMatrix pseudo_inverse (double tol = 0.0) const; |
740
|
143 |
458
|
144 ComplexMatrix fourier (void) const; |
|
145 ComplexMatrix ifourier (void) const; |
|
146 |
677
|
147 ComplexMatrix fourier2d (void) const; |
|
148 ComplexMatrix ifourier2d (void) const; |
|
149 |
458
|
150 ComplexDET determinant (void) const; |
|
151 ComplexDET determinant (int& info) const; |
4329
|
152 ComplexDET determinant (int& info, double& rcond, int calc_cond = 1) const; |
458
|
153 |
|
154 ComplexMatrix solve (const Matrix& b) const; |
|
155 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
156 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
3480
|
157 ComplexMatrix solve (const Matrix& b, int& info, double& rcond, |
|
158 solve_singularity_handler sing_handler) const; |
458
|
159 |
|
160 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
161 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
162 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
3480
|
163 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond, |
|
164 solve_singularity_handler sing_handler) const; |
458
|
165 |
3585
|
166 ComplexColumnVector solve (const ColumnVector& b) const; |
|
167 ComplexColumnVector solve (const ColumnVector& b, int& info) const; |
|
168 ComplexColumnVector solve (const ColumnVector& b, int& info, |
|
169 double& rcond) const; |
|
170 ComplexColumnVector solve (const ColumnVector& b, int& info, double& rcond, |
|
171 solve_singularity_handler sing_handler) const; |
|
172 |
458
|
173 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
174 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
175 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
176 double& rcond) const; |
3480
|
177 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
178 double& rcond, |
|
179 solve_singularity_handler sing_handler) const; |
458
|
180 |
3585
|
181 ComplexMatrix lssolve (const Matrix& b) const; |
|
182 ComplexMatrix lssolve (const Matrix& b, int& info) const; |
|
183 ComplexMatrix lssolve (const Matrix& b, int& info, int& rank) const; |
|
184 |
458
|
185 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
186 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
187 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
188 int& rank) const; |
|
189 |
3585
|
190 ComplexColumnVector lssolve (const ColumnVector& b) const; |
|
191 ComplexColumnVector lssolve (const ColumnVector& b, int& info) const; |
|
192 ComplexColumnVector lssolve (const ColumnVector& b, int& info, |
|
193 int& rank) const; |
|
194 |
458
|
195 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
196 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
197 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
198 int& rank) const; |
|
199 |
1819
|
200 ComplexMatrix expm (void) const; |
|
201 |
1359
|
202 // column vector by row vector -> matrix operations |
1205
|
203 |
|
204 friend ComplexMatrix operator * (const ColumnVector& a, |
|
205 const ComplexRowVector& b); |
|
206 |
|
207 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
208 const RowVector& b); |
|
209 |
|
210 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
211 const ComplexRowVector& b); |
|
212 |
1359
|
213 // matrix by diagonal matrix -> matrix operations |
458
|
214 |
|
215 ComplexMatrix& operator += (const DiagMatrix& a); |
|
216 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
217 |
|
218 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
219 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
220 |
1359
|
221 // matrix by matrix -> matrix operations |
458
|
222 |
|
223 ComplexMatrix& operator += (const Matrix& a); |
|
224 ComplexMatrix& operator -= (const Matrix& a); |
|
225 |
1359
|
226 // unary operations |
458
|
227 |
2964
|
228 boolMatrix operator ! (void) const; |
458
|
229 |
1359
|
230 // other operations |
458
|
231 |
2676
|
232 ComplexMatrix map (c_c_Mapper f) const; |
|
233 Matrix map (d_c_Mapper f) const; |
3248
|
234 boolMatrix map (b_c_Mapper f) const; |
2676
|
235 |
|
236 ComplexMatrix& apply (c_c_Mapper f); |
458
|
237 |
2384
|
238 bool any_element_is_inf_or_nan (void) const; |
2408
|
239 bool all_elements_are_real (void) const; |
2384
|
240 bool all_integers (double& max_val, double& min_val) const; |
|
241 bool too_large_for_float (void) const; |
1963
|
242 |
4017
|
243 boolMatrix all (int dim = -1) const; |
|
244 boolMatrix any (int dim = -1) const; |
458
|
245 |
4017
|
246 ComplexMatrix cumprod (int dim = -1) const; |
|
247 ComplexMatrix cumsum (int dim = -1) const; |
|
248 ComplexMatrix prod (int dim = -1) const; |
|
249 ComplexMatrix sum (int dim = -1) const; |
|
250 ComplexMatrix sumsq (int dim = -1) const; |
4329
|
251 Matrix abs (void) 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 */ |