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 |
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" |
2870
|
34 #include "mx-op-defs.h" |
1650
|
35 #include "oct-cmplx.h" |
458
|
36 |
1214
|
37 class ComplexMatrix : public MArray2<Complex> |
458
|
38 { |
|
39 public: |
|
40 |
3480
|
41 typedef void (*solve_singularity_handler) (double rcond); |
|
42 |
1214
|
43 ComplexMatrix (void) : MArray2<Complex> () { } |
|
44 ComplexMatrix (int r, int c) : MArray2<Complex> (r, c) { } |
458
|
45 ComplexMatrix (int r, int c, const Complex& val) |
1214
|
46 : MArray2<Complex> (r, c, val) { } |
458
|
47 ComplexMatrix (const Matrix& a); |
1214
|
48 ComplexMatrix (const MArray2<Complex>& a) : MArray2<Complex> (a) { } |
|
49 ComplexMatrix (const ComplexMatrix& a) : MArray2<Complex> (a) { } |
2349
|
50 ComplexMatrix (const RowVector& rv); |
|
51 ComplexMatrix (const ColumnVector& cv); |
458
|
52 ComplexMatrix (const DiagMatrix& a); |
1989
|
53 // ComplexMatrix (const MDiagArray2<Complex>& a) : MArray2<Complex> (a) { } |
2349
|
54 ComplexMatrix (const ComplexRowVector& rv); |
|
55 ComplexMatrix (const ComplexColumnVector& cv); |
458
|
56 ComplexMatrix (const ComplexDiagMatrix& a); |
|
57 |
2828
|
58 ComplexMatrix (const boolMatrix& a); |
1574
|
59 ComplexMatrix (const charMatrix& a); |
|
60 |
458
|
61 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
62 { |
1214
|
63 MArray2<Complex>::operator = (a); |
458
|
64 return *this; |
|
65 } |
|
66 |
2384
|
67 bool operator == (const ComplexMatrix& a) const; |
|
68 bool operator != (const ComplexMatrix& a) const; |
458
|
69 |
2815
|
70 bool is_hermitian (void) 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 |
3225
|
110 ComplexMatrix transpose (void) const |
|
111 { return MArray2<Complex>::transpose (); } |
458
|
112 |
|
113 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
114 |
1359
|
115 // resize is the destructive equivalent for this one |
458
|
116 |
|
117 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
118 |
1359
|
119 // extract row or column i. |
458
|
120 |
|
121 ComplexRowVector row (int i) const; |
|
122 ComplexRowVector row (char *s) const; |
|
123 |
|
124 ComplexColumnVector column (int i) const; |
|
125 ComplexColumnVector column (char *s) const; |
|
126 |
|
127 ComplexMatrix inverse (void) const; |
|
128 ComplexMatrix inverse (int& info) const; |
1656
|
129 ComplexMatrix inverse (int& info, double& rcond, int force = 0) const; |
458
|
130 |
740
|
131 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
132 |
458
|
133 ComplexMatrix fourier (void) const; |
|
134 ComplexMatrix ifourier (void) const; |
|
135 |
677
|
136 ComplexMatrix fourier2d (void) const; |
|
137 ComplexMatrix ifourier2d (void) const; |
|
138 |
458
|
139 ComplexDET determinant (void) const; |
|
140 ComplexDET determinant (int& info) const; |
|
141 ComplexDET determinant (int& info, double& rcond) const; |
|
142 |
|
143 ComplexMatrix solve (const Matrix& b) const; |
|
144 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
145 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
3480
|
146 ComplexMatrix solve (const Matrix& b, int& info, double& rcond, |
|
147 solve_singularity_handler sing_handler) const; |
458
|
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; |
3480
|
152 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond, |
|
153 solve_singularity_handler sing_handler) const; |
458
|
154 |
|
155 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
156 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
157 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
158 double& rcond) const; |
3480
|
159 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
160 double& rcond, |
|
161 solve_singularity_handler sing_handler) const; |
458
|
162 |
|
163 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
164 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
165 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
166 int& rank) const; |
|
167 |
|
168 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
169 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
170 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
171 int& rank) const; |
|
172 |
1819
|
173 ComplexMatrix expm (void) const; |
|
174 |
1359
|
175 // column vector by row vector -> matrix operations |
1205
|
176 |
|
177 friend ComplexMatrix operator * (const ColumnVector& a, |
|
178 const ComplexRowVector& b); |
|
179 |
|
180 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
181 const RowVector& b); |
|
182 |
|
183 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
184 const ComplexRowVector& b); |
|
185 |
1359
|
186 // matrix by diagonal matrix -> matrix operations |
458
|
187 |
|
188 ComplexMatrix& operator += (const DiagMatrix& a); |
|
189 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
190 |
|
191 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
192 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
193 |
1359
|
194 // matrix by matrix -> matrix operations |
458
|
195 |
|
196 ComplexMatrix& operator += (const Matrix& a); |
|
197 ComplexMatrix& operator -= (const Matrix& a); |
|
198 |
|
199 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
200 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
201 |
1359
|
202 // unary operations |
458
|
203 |
2964
|
204 boolMatrix operator ! (void) const; |
458
|
205 |
1359
|
206 // other operations |
458
|
207 |
2676
|
208 ComplexMatrix map (c_c_Mapper f) const; |
|
209 Matrix map (d_c_Mapper f) const; |
3248
|
210 boolMatrix map (b_c_Mapper f) const; |
2676
|
211 |
|
212 ComplexMatrix& apply (c_c_Mapper f); |
458
|
213 |
2384
|
214 bool any_element_is_inf_or_nan (void) const; |
2408
|
215 bool all_elements_are_real (void) const; |
2384
|
216 bool all_integers (double& max_val, double& min_val) const; |
|
217 bool too_large_for_float (void) const; |
1963
|
218 |
2832
|
219 boolMatrix all (void) const; |
|
220 boolMatrix any (void) const; |
458
|
221 |
|
222 ComplexMatrix cumprod (void) const; |
|
223 ComplexMatrix cumsum (void) const; |
|
224 ComplexMatrix prod (void) const; |
|
225 ComplexMatrix sum (void) const; |
|
226 ComplexMatrix sumsq (void) const; |
|
227 |
|
228 ComplexColumnVector diag (void) const; |
|
229 ComplexColumnVector diag (int k) const; |
|
230 |
2354
|
231 bool row_is_real_only (int) const; |
|
232 bool column_is_real_only (int) const; |
458
|
233 |
2354
|
234 ComplexColumnVector row_min (void) const; |
458
|
235 ComplexColumnVector row_max (void) const; |
2354
|
236 |
|
237 ComplexColumnVector row_min (Array<int>& index) const; |
|
238 ComplexColumnVector row_max (Array<int>& index) const; |
458
|
239 |
|
240 ComplexRowVector column_min (void) const; |
2354
|
241 ComplexRowVector column_max (void) const; |
458
|
242 |
2354
|
243 ComplexRowVector column_min (Array<int>& index) const; |
|
244 ComplexRowVector column_max (Array<int>& index) const; |
458
|
245 |
1359
|
246 // i/o |
458
|
247 |
3504
|
248 friend std::ostream& operator << (std::ostream& os, const ComplexMatrix& a); |
|
249 friend std::istream& operator >> (std::istream& is, ComplexMatrix& a); |
458
|
250 |
|
251 private: |
|
252 |
1214
|
253 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
254 }; |
|
255 |
1819
|
256 ComplexMatrix Givens (const Complex&, const Complex&); |
|
257 |
|
258 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&, |
|
259 const ComplexMatrix&); |
|
260 |
2828
|
261 extern ComplexMatrix operator * (const Matrix&, const ComplexMatrix&); |
|
262 extern ComplexMatrix operator * (const ComplexMatrix&, const Matrix&); |
|
263 extern ComplexMatrix operator * (const ComplexMatrix&, const ComplexMatrix&); |
|
264 |
2870
|
265 MS_CMP_OP_DECLS (ComplexMatrix, Complex) |
|
266 MS_BOOL_OP_DECLS (ComplexMatrix, Complex) |
|
267 |
|
268 SM_CMP_OP_DECLS (Complex, ComplexMatrix) |
|
269 SM_BOOL_OP_DECLS (Complex, ComplexMatrix) |
|
270 |
|
271 MM_CMP_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
272 MM_BOOL_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
273 |
3573
|
274 MARRAY_FORWARD_DEFS (MArray2, ComplexMatrix, Complex) |
|
275 |
458
|
276 #endif |
|
277 |
|
278 /* |
|
279 ;;; Local Variables: *** |
|
280 ;;; mode: C++ *** |
|
281 ;;; End: *** |
|
282 */ |