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 { |
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) { } |
2349
|
57 ComplexMatrix (const RowVector& rv); |
|
58 ComplexMatrix (const ColumnVector& cv); |
458
|
59 ComplexMatrix (const DiagMatrix& a); |
1989
|
60 // ComplexMatrix (const MDiagArray2<Complex>& a) : MArray2<Complex> (a) { } |
2349
|
61 ComplexMatrix (const ComplexRowVector& rv); |
|
62 ComplexMatrix (const ComplexColumnVector& cv); |
458
|
63 ComplexMatrix (const ComplexDiagMatrix& a); |
|
64 |
2828
|
65 ComplexMatrix (const boolMatrix& a); |
1574
|
66 ComplexMatrix (const charMatrix& a); |
|
67 |
458
|
68 ComplexMatrix& operator = (const ComplexMatrix& a) |
|
69 { |
1214
|
70 MArray2<Complex>::operator = (a); |
458
|
71 return *this; |
|
72 } |
|
73 |
2384
|
74 bool operator == (const ComplexMatrix& a) const; |
|
75 bool operator != (const ComplexMatrix& a) const; |
458
|
76 |
2815
|
77 bool is_hermitian (void) const; |
|
78 |
1359
|
79 // destructive insert/delete/reorder operations |
458
|
80 |
|
81 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
82 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
83 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
84 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
85 |
|
86 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
87 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
88 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
89 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
90 |
|
91 ComplexMatrix& fill (double val); |
|
92 ComplexMatrix& fill (const Complex& val); |
|
93 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
|
94 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
|
95 |
|
96 ComplexMatrix append (const Matrix& a) const; |
|
97 ComplexMatrix append (const RowVector& a) const; |
|
98 ComplexMatrix append (const ColumnVector& a) const; |
|
99 ComplexMatrix append (const DiagMatrix& a) const; |
|
100 |
|
101 ComplexMatrix append (const ComplexMatrix& a) const; |
|
102 ComplexMatrix append (const ComplexRowVector& a) const; |
|
103 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
104 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
105 |
|
106 ComplexMatrix stack (const Matrix& a) const; |
|
107 ComplexMatrix stack (const RowVector& a) const; |
|
108 ComplexMatrix stack (const ColumnVector& a) const; |
|
109 ComplexMatrix stack (const DiagMatrix& a) const; |
|
110 |
|
111 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
112 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
113 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
114 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
115 |
|
116 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
3225
|
117 ComplexMatrix transpose (void) const |
|
118 { return MArray2<Complex>::transpose (); } |
458
|
119 |
|
120 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
121 |
1359
|
122 // resize is the destructive equivalent for this one |
458
|
123 |
|
124 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
125 |
1359
|
126 // extract row or column i. |
458
|
127 |
|
128 ComplexRowVector row (int i) const; |
|
129 ComplexRowVector row (char *s) const; |
|
130 |
|
131 ComplexColumnVector column (int i) const; |
|
132 ComplexColumnVector column (char *s) const; |
|
133 |
|
134 ComplexMatrix inverse (void) const; |
|
135 ComplexMatrix inverse (int& info) const; |
1656
|
136 ComplexMatrix inverse (int& info, double& rcond, int force = 0) const; |
458
|
137 |
740
|
138 ComplexMatrix pseudo_inverse (double tol = 0.0); |
|
139 |
458
|
140 ComplexMatrix fourier (void) const; |
|
141 ComplexMatrix ifourier (void) const; |
|
142 |
677
|
143 ComplexMatrix fourier2d (void) const; |
|
144 ComplexMatrix ifourier2d (void) const; |
|
145 |
458
|
146 ComplexDET determinant (void) const; |
|
147 ComplexDET determinant (int& info) const; |
|
148 ComplexDET determinant (int& info, double& rcond) const; |
|
149 |
|
150 ComplexMatrix solve (const Matrix& b) const; |
|
151 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
152 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
153 |
|
154 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
155 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
156 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
157 |
|
158 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
159 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
160 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
161 double& rcond) const; |
|
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; |
|
210 |
|
211 ComplexMatrix& apply (c_c_Mapper f); |
458
|
212 |
2384
|
213 bool any_element_is_inf_or_nan (void) const; |
2408
|
214 bool all_elements_are_real (void) const; |
2384
|
215 bool all_integers (double& max_val, double& min_val) const; |
|
216 bool too_large_for_float (void) const; |
1963
|
217 |
2832
|
218 boolMatrix all (void) const; |
|
219 boolMatrix any (void) const; |
458
|
220 |
|
221 ComplexMatrix cumprod (void) const; |
|
222 ComplexMatrix cumsum (void) const; |
|
223 ComplexMatrix prod (void) const; |
|
224 ComplexMatrix sum (void) const; |
|
225 ComplexMatrix sumsq (void) const; |
|
226 |
|
227 ComplexColumnVector diag (void) const; |
|
228 ComplexColumnVector diag (int k) const; |
|
229 |
2354
|
230 bool row_is_real_only (int) const; |
|
231 bool column_is_real_only (int) const; |
458
|
232 |
2354
|
233 ComplexColumnVector row_min (void) const; |
458
|
234 ComplexColumnVector row_max (void) const; |
2354
|
235 |
|
236 ComplexColumnVector row_min (Array<int>& index) const; |
|
237 ComplexColumnVector row_max (Array<int>& index) const; |
458
|
238 |
|
239 ComplexRowVector column_min (void) const; |
2354
|
240 ComplexRowVector column_max (void) const; |
458
|
241 |
2354
|
242 ComplexRowVector column_min (Array<int>& index) const; |
|
243 ComplexRowVector column_max (Array<int>& index) const; |
458
|
244 |
1359
|
245 // i/o |
458
|
246 |
|
247 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
248 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
249 |
|
250 private: |
|
251 |
1214
|
252 ComplexMatrix (Complex *d, int r, int c) : MArray2<Complex> (d, r, c) { } |
458
|
253 }; |
|
254 |
1819
|
255 ComplexMatrix Givens (const Complex&, const Complex&); |
|
256 |
|
257 ComplexMatrix Sylvester (const ComplexMatrix&, const ComplexMatrix&, |
|
258 const ComplexMatrix&); |
|
259 |
2828
|
260 extern ComplexMatrix operator * (const Matrix&, const ComplexMatrix&); |
|
261 extern ComplexMatrix operator * (const ComplexMatrix&, const Matrix&); |
|
262 extern ComplexMatrix operator * (const ComplexMatrix&, const ComplexMatrix&); |
|
263 |
2870
|
264 MS_CMP_OP_DECLS (ComplexMatrix, Complex) |
|
265 MS_BOOL_OP_DECLS (ComplexMatrix, Complex) |
|
266 |
|
267 SM_CMP_OP_DECLS (Complex, ComplexMatrix) |
|
268 SM_BOOL_OP_DECLS (Complex, ComplexMatrix) |
|
269 |
|
270 MM_CMP_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
271 MM_BOOL_OP_DECLS (ComplexMatrix, ComplexMatrix) |
|
272 |
458
|
273 #endif |
|
274 |
|
275 /* |
|
276 ;;; Local Variables: *** |
|
277 ;;; mode: C++ *** |
|
278 ;;; End: *** |
|
279 */ |