3
|
1 // Matrix manipulations. -*- C++ -*- |
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
3
|
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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 /* |
|
25 |
|
26 Should probably say something here about why these classes are not |
|
27 represented by some sort of inheritance tree... |
|
28 |
|
29 */ |
|
30 |
382
|
31 #if !defined (octave_Matrix_h) |
|
32 #define octave_Matrix_h 1 |
|
33 |
3
|
34 #include <stdlib.h> |
|
35 #include <stddef.h> |
|
36 #include <math.h> |
|
37 #include <assert.h> |
|
38 #include <iostream.h> |
443
|
39 #include <stdio.h> |
3
|
40 // #include <iomanip.h> // We don\'t use this yet. |
|
41 #include <Complex.h> |
|
42 |
384
|
43 extern "C++" { |
|
44 |
238
|
45 class ostream; |
|
46 class istream; |
|
47 |
3
|
48 #ifndef MAPPER_FCN_TYPEDEFS |
|
49 #define MAPPER_FCN_TYPEDEFS 1 |
|
50 |
|
51 typedef double (*d_d_Mapper)(double); |
|
52 typedef double (*d_c_Mapper)(const Complex&); |
|
53 typedef Complex (*c_c_Mapper)(const Complex&); |
|
54 |
|
55 #endif |
|
56 |
238
|
57 #include "Array.h" |
|
58 |
3
|
59 // Classes we declare. |
|
60 |
|
61 class Matrix; |
|
62 class ColumnVector; |
|
63 class RowVector; |
|
64 class DiagMatrix; |
|
65 class ComplexMatrix; |
|
66 class ComplexColumnVector; |
|
67 class ComplexRowVector; |
|
68 class ComplexDiagMatrix; |
21
|
69 class AEPBALANCE; |
|
70 class ComplexAEPBALANCE; |
|
71 class GEPBALANCE; |
182
|
72 class CHOL; |
|
73 class ComplexCHOL; |
3
|
74 class DET; |
|
75 class ComplexDET; |
|
76 class EIG; |
|
77 class HESS; |
|
78 class ComplexHESS; |
|
79 class SCHUR; |
|
80 class ComplexSCHUR; |
|
81 class SVD; |
|
82 class ComplexSVD; |
|
83 class LU; |
|
84 class ComplexLU; |
|
85 class QR; |
|
86 class ComplexQR; |
|
87 |
|
88 /* |
|
89 * Matrix class |
|
90 */ |
|
91 |
238
|
92 class Matrix : public Array2<double> |
3
|
93 { |
238
|
94 friend class LU; |
3
|
95 friend class SVD; |
|
96 |
|
97 public: |
238
|
98 |
|
99 Matrix (void) : Array2<double> () { } |
|
100 Matrix (int r, int c) : Array2<double> (r, c) { } |
|
101 Matrix (int r, int c, double val) : Array2<double> (r, c, val) { } |
|
102 Matrix (const Array2<double>& a) : Array2<double> (a) { } |
|
103 Matrix (const Matrix& a) : Array2<double> (a) { } |
|
104 Matrix (const DiagArray<double>& a) : Array2<double> (a) { } |
3
|
105 Matrix (const DiagMatrix& a); |
238
|
106 // Matrix (double a) : Array2<double> (1, 1, a) { } |
|
107 |
|
108 Matrix& operator = (const Matrix& a) |
291
|
109 { |
|
110 Array2<double>::operator = (a); |
|
111 return *this; |
|
112 } |
3
|
113 |
|
114 int operator == (const Matrix& a) const; |
|
115 int operator != (const Matrix& a) const; |
|
116 |
|
117 // destructive insert/delete/reorder operations |
|
118 |
|
119 Matrix& insert (const Matrix& a, int r, int c); |
|
120 Matrix& insert (const RowVector& a, int r, int c); |
|
121 Matrix& insert (const ColumnVector& a, int r, int c); |
|
122 Matrix& insert (const DiagMatrix& a, int r, int c); |
|
123 |
|
124 Matrix& fill (double val); |
|
125 Matrix& fill (double val, int r1, int c1, int r2, int c2); |
|
126 |
|
127 Matrix append (const Matrix& a) const; |
|
128 Matrix append (const RowVector& a) const; |
|
129 Matrix append (const ColumnVector& a) const; |
|
130 Matrix append (const DiagMatrix& a) const; |
|
131 |
|
132 Matrix stack (const Matrix& a) const; |
|
133 Matrix stack (const RowVector& a) const; |
|
134 Matrix stack (const ColumnVector& a) const; |
|
135 Matrix stack (const DiagMatrix& a) const; |
|
136 |
|
137 Matrix transpose (void) const; |
|
138 |
|
139 // resize is the destructive equivalent for this one |
|
140 |
|
141 Matrix extract (int r1, int c1, int r2, int c2) const; |
|
142 |
|
143 // extract row or column i. |
|
144 |
|
145 RowVector row (int i) const; |
|
146 RowVector row (char *s) const; |
|
147 |
|
148 ColumnVector column (int i) const; |
|
149 ColumnVector column (char *s) const; |
|
150 |
238
|
151 Matrix inverse (void) const; |
3
|
152 Matrix inverse (int& info) const; |
238
|
153 Matrix inverse (int& info, double& rcond) const; |
3
|
154 |
|
155 ComplexMatrix fourier (void) const; |
|
156 ComplexMatrix ifourier (void) const; |
|
157 |
|
158 DET determinant (void) const; |
|
159 DET determinant (int& info) const; |
|
160 DET determinant (int& info, double& rcond) const; |
|
161 |
|
162 Matrix solve (const Matrix& b) const; |
|
163 Matrix solve (const Matrix& b, int& info) const; |
|
164 Matrix solve (const Matrix& b, int& info, double& rcond) const; |
|
165 |
|
166 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
167 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
168 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
169 |
|
170 ColumnVector solve (const ColumnVector& b) const; |
|
171 ColumnVector solve (const ColumnVector& b, int& info) const; |
|
172 ColumnVector solve (const ColumnVector& b, int& info, double& rcond) const; |
|
173 |
|
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; |
|
178 |
|
179 Matrix lssolve (const Matrix& b) const; |
|
180 Matrix lssolve (const Matrix& b, int& info) const; |
|
181 Matrix lssolve (const Matrix& b, int& info, int& rank) const; |
|
182 |
|
183 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
184 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
185 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
186 int& rank) const; |
|
187 |
|
188 ColumnVector lssolve (const ColumnVector& b) const; |
|
189 ColumnVector lssolve (const ColumnVector& b, int& info) const; |
|
190 ColumnVector lssolve (const ColumnVector& b, int& info, int& rank) const; |
|
191 |
|
192 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
193 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
194 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
195 int& rank) const; |
|
196 |
238
|
197 Matrix& operator += (const Matrix& a); |
|
198 Matrix& operator -= (const Matrix& a); |
3
|
199 |
|
200 Matrix& operator += (const DiagMatrix& a); |
|
201 Matrix& operator -= (const DiagMatrix& a); |
|
202 |
238
|
203 // unary operations |
|
204 |
|
205 Matrix operator ! (void) const; |
|
206 |
|
207 // matrix by scalar -> matrix operations |
|
208 |
|
209 friend ComplexMatrix operator + (const Matrix& a, const Complex& s); |
|
210 friend ComplexMatrix operator - (const Matrix& a, const Complex& s); |
|
211 friend ComplexMatrix operator * (const Matrix& a, const Complex& s); |
|
212 friend ComplexMatrix operator / (const Matrix& a, const Complex& s); |
|
213 |
|
214 // scalar by matrix -> matrix operations |
|
215 |
|
216 friend ComplexMatrix operator + (const Complex& s, const Matrix& a); |
|
217 friend ComplexMatrix operator - (const Complex& s, const Matrix& a); |
|
218 friend ComplexMatrix operator * (const Complex& s, const Matrix& a); |
|
219 friend ComplexMatrix operator / (const Complex& s, const Matrix& a); |
|
220 |
|
221 // matrix by column vector -> column vector operations |
|
222 |
|
223 friend ColumnVector operator * (const Matrix& a, const ColumnVector& b); |
|
224 friend ComplexColumnVector operator * (const Matrix& a, |
|
225 const ComplexColumnVector& b); |
|
226 |
|
227 // matrix by diagonal matrix -> matrix operations |
|
228 |
|
229 friend Matrix operator + (const Matrix& a, const DiagMatrix& b); |
|
230 friend Matrix operator - (const Matrix& a, const DiagMatrix& b); |
|
231 friend Matrix operator * (const Matrix& a, const DiagMatrix& b); |
|
232 |
|
233 friend ComplexMatrix operator + (const Matrix& a, |
|
234 const ComplexDiagMatrix& b); |
|
235 friend ComplexMatrix operator - (const Matrix& a, |
|
236 const ComplexDiagMatrix& b); |
|
237 friend ComplexMatrix operator * (const Matrix& a, |
|
238 const ComplexDiagMatrix& b); |
|
239 |
3
|
240 // matrix by matrix -> matrix operations |
|
241 |
238
|
242 friend Matrix operator * (const Matrix& a, const Matrix& b); |
|
243 friend ComplexMatrix operator * (const Matrix& a, const ComplexMatrix& b); |
|
244 |
|
245 friend ComplexMatrix operator + (const Matrix& a, const ComplexMatrix& b); |
|
246 friend ComplexMatrix operator - (const Matrix& a, const ComplexMatrix& b); |
|
247 |
|
248 friend ComplexMatrix product (const Matrix& a, const ComplexMatrix& b); |
|
249 friend ComplexMatrix quotient (const Matrix& a, const ComplexMatrix& b); |
3
|
250 |
|
251 // other operations |
|
252 |
|
253 friend Matrix map (d_d_Mapper f, const Matrix& a); |
|
254 void map (d_d_Mapper f); |
|
255 |
|
256 Matrix all (void) const; |
|
257 Matrix any (void) const; |
|
258 |
|
259 Matrix cumprod (void) const; |
|
260 Matrix cumsum (void) const; |
|
261 Matrix prod (void) const; |
|
262 Matrix sum (void) const; |
|
263 Matrix sumsq (void) const; |
|
264 |
|
265 ColumnVector diag (void) const; |
|
266 ColumnVector diag (int k) const; |
|
267 |
|
268 ColumnVector row_min (void) const; |
210
|
269 ColumnVector row_min_loc (void) const; |
|
270 |
3
|
271 ColumnVector row_max (void) const; |
210
|
272 ColumnVector row_max_loc (void) const; |
3
|
273 |
|
274 RowVector column_min (void) const; |
210
|
275 RowVector column_min_loc (void) const; |
|
276 |
3
|
277 RowVector column_max (void) const; |
210
|
278 RowVector column_max_loc (void) const; |
3
|
279 |
|
280 // i/o |
|
281 |
|
282 friend ostream& operator << (ostream& os, const Matrix& a); |
|
283 friend istream& operator >> (istream& is, Matrix& a); |
|
284 |
443
|
285 enum conversion |
|
286 { |
|
287 CNV_UNKNOWN, |
|
288 CNV_UCHAR, |
|
289 CNV_CHAR, |
|
290 CNV_SCHAR, |
|
291 CNV_SHORT, |
|
292 CNV_USHORT, |
|
293 CNV_INT, |
|
294 CNV_UINT, |
|
295 CNV_LONG, |
|
296 CNV_ULONG, |
|
297 CNV_FLOAT, |
|
298 CNV_DOUBLE, |
|
299 }; |
|
300 |
|
301 |
|
302 int read (FILE *fptr, int size, Matrix::conversion); |
|
303 int write (FILE *fptr, int size, Matrix::conversion); |
|
304 |
238
|
305 // Until templates really work with g++: |
|
306 |
|
307 #define KLUDGE_MATRICES |
|
308 #define TYPE double |
|
309 #define KL_MAT_TYPE Matrix |
|
310 #include "mx-kludge.h" |
|
311 #undef KLUDGE_MATRICES |
|
312 #undef TYPE |
|
313 #undef KL_MAT_TYPE |
3
|
314 |
|
315 private: |
238
|
316 |
|
317 Matrix (double *d, int r, int c) : Array2<double> (d, r, c) { } |
3
|
318 }; |
|
319 |
|
320 /* |
|
321 * Column Vector class |
|
322 */ |
|
323 |
238
|
324 class ColumnVector : public Array<double> |
3
|
325 { |
291
|
326 friend class RowVector; |
|
327 |
3
|
328 public: |
238
|
329 |
|
330 ColumnVector (void) : Array<double> () { } |
|
331 ColumnVector (int n) : Array<double> (n) { } |
|
332 ColumnVector (int n, double val) : Array<double> (n, val) { } |
|
333 ColumnVector (const Array<double>& a) : Array<double> (a) { } |
|
334 ColumnVector (const ColumnVector& a) : Array<double> (a) { } |
|
335 // ColumnVector (double a) : Array<double> (1, a) { } |
|
336 |
|
337 ColumnVector& operator = (const ColumnVector& a) |
291
|
338 { |
|
339 Array<double>::operator = (a); |
|
340 return *this; |
|
341 } |
238
|
342 |
|
343 // operator Array<double>& () const { return *this; } |
3
|
344 |
|
345 int operator == (const ColumnVector& a) const; |
|
346 int operator != (const ColumnVector& a) const; |
|
347 |
|
348 // destructive insert/delete/reorder operations |
|
349 |
|
350 ColumnVector& insert (const ColumnVector& a, int r); |
|
351 |
|
352 ColumnVector& fill (double val); |
|
353 ColumnVector& fill (double val, int r1, int r2); |
|
354 |
|
355 ColumnVector stack (const ColumnVector& a) const; |
|
356 |
|
357 RowVector transpose (void) const; |
|
358 |
|
359 // resize is the destructive equivalent for this one |
|
360 |
|
361 ColumnVector extract (int r1, int r2) const; |
|
362 |
|
363 // column vector by column vector -> column vector operations |
|
364 |
|
365 ColumnVector& operator += (const ColumnVector& a); |
|
366 ColumnVector& operator -= (const ColumnVector& a); |
|
367 |
238
|
368 // column vector by scalar -> column vector operations |
|
369 |
|
370 friend ComplexColumnVector operator + (const ColumnVector& a, |
|
371 const Complex& s); |
|
372 friend ComplexColumnVector operator - (const ColumnVector& a, |
|
373 const Complex& s); |
|
374 friend ComplexColumnVector operator * (const ColumnVector& a, |
|
375 const Complex& s); |
|
376 friend ComplexColumnVector operator / (const ColumnVector& a, |
|
377 const Complex& s); |
|
378 |
|
379 // scalar by column vector -> column vector operations |
|
380 |
|
381 friend ComplexColumnVector operator + (const Complex& s, |
|
382 const ColumnVector& a); |
|
383 friend ComplexColumnVector operator - (const Complex& s, |
|
384 const ColumnVector& a); |
|
385 friend ComplexColumnVector operator * (const Complex& s, |
|
386 const ColumnVector& a); |
|
387 friend ComplexColumnVector operator / (const Complex& s, |
|
388 const ColumnVector& a); |
|
389 |
|
390 // column vector by row vector -> matrix operations |
|
391 |
|
392 friend Matrix operator * (const ColumnVector& a, const RowVector& a); |
|
393 |
|
394 friend ComplexMatrix operator * (const ColumnVector& a, |
|
395 const ComplexRowVector& b); |
|
396 |
|
397 // column vector by column vector -> column vector operations |
|
398 |
|
399 friend ComplexColumnVector operator + (const ComplexColumnVector& a, |
|
400 const ComplexColumnVector& b); |
|
401 |
|
402 friend ComplexColumnVector operator - (const ComplexColumnVector& a, |
|
403 const ComplexColumnVector& b); |
|
404 |
|
405 friend ComplexColumnVector product (const ComplexColumnVector& a, |
|
406 const ComplexColumnVector& b); |
|
407 |
|
408 friend ComplexColumnVector quotient (const ComplexColumnVector& a, |
|
409 const ComplexColumnVector& b); |
|
410 |
|
411 // other operations |
3
|
412 |
|
413 friend ColumnVector map (d_d_Mapper f, const ColumnVector& a); |
|
414 void map (d_d_Mapper f); |
|
415 |
|
416 double min (void) const; |
|
417 double max (void) const; |
|
418 |
|
419 // i/o |
|
420 |
|
421 friend ostream& operator << (ostream& os, const ColumnVector& a); |
378
|
422 friend ostream& operator >> (ostream& is, ColumnVector& a); |
3
|
423 |
238
|
424 #define KLUDGE_VECTORS |
|
425 #define TYPE double |
|
426 #define KL_VEC_TYPE ColumnVector |
|
427 #include "mx-kludge.h" |
|
428 #undef KLUDGE_VECTORS |
|
429 #undef TYPE |
|
430 #undef KL_VEC_TYPE |
3
|
431 |
|
432 private: |
238
|
433 |
|
434 ColumnVector (double *d, int l) : Array<double> (d, l) { } |
3
|
435 }; |
|
436 |
|
437 /* |
|
438 * Row Vector class |
|
439 */ |
|
440 |
238
|
441 class RowVector : public Array<double> |
3
|
442 { |
291
|
443 friend class ColumnVector; |
|
444 |
3
|
445 public: |
238
|
446 |
|
447 RowVector (void) : Array<double> () { } |
|
448 RowVector (int n) : Array<double> (n) { } |
|
449 RowVector (int n, double val) : Array<double> (n, val) { } |
|
450 RowVector (const Array<double>& a) : Array<double> (a) { } |
|
451 RowVector (const RowVector& a) : Array<double> (a) { } |
|
452 // RowVector (double a) : Array<double> (1, a) { } |
|
453 |
|
454 RowVector& operator = (const RowVector& a) |
291
|
455 { |
|
456 Array<double>::operator = (a); |
|
457 return *this; |
|
458 } |
238
|
459 |
|
460 // operator Array<double>& () const { return *this; } |
3
|
461 |
|
462 int operator == (const RowVector& a) const; |
|
463 int operator != (const RowVector& a) const; |
|
464 |
|
465 // destructive insert/delete/reorder operations |
|
466 |
|
467 RowVector& insert (const RowVector& a, int c); |
|
468 |
|
469 RowVector& fill (double val); |
|
470 RowVector& fill (double val, int c1, int c2); |
|
471 |
|
472 RowVector append (const RowVector& a) const; |
|
473 |
|
474 ColumnVector transpose (void) const; |
|
475 |
|
476 // resize is the destructive equivalent for this one |
|
477 |
|
478 RowVector extract (int c1, int c2) const; |
|
479 |
|
480 // row vector by row vector -> row vector operations |
|
481 |
|
482 RowVector& operator += (const RowVector& a); |
|
483 RowVector& operator -= (const RowVector& a); |
|
484 |
238
|
485 // row vector by scalar -> row vector operations |
|
486 |
|
487 friend ComplexRowVector operator + (const RowVector& a, const Complex& s); |
|
488 friend ComplexRowVector operator - (const RowVector& a, const Complex& s); |
|
489 friend ComplexRowVector operator * (const RowVector& a, const Complex& s); |
|
490 friend ComplexRowVector operator / (const RowVector& a, const Complex& s); |
|
491 |
|
492 // scalar by row vector -> row vector operations |
|
493 |
|
494 friend ComplexRowVector operator + (const Complex& s, const RowVector& a); |
|
495 friend ComplexRowVector operator - (const Complex& s, const RowVector& a); |
|
496 friend ComplexRowVector operator * (const Complex& s, const RowVector& a); |
|
497 friend ComplexRowVector operator / (const Complex& s, const RowVector& a); |
|
498 |
|
499 // row vector by column vector -> scalar |
|
500 |
343
|
501 friend double operator * (const RowVector& a, const ColumnVector& b); |
238
|
502 |
|
503 friend Complex operator * (const RowVector& a, const ComplexColumnVector& b); |
|
504 |
|
505 // row vector by matrix -> row vector |
|
506 |
|
507 friend RowVector operator * (const RowVector& a, const Matrix& b); |
|
508 |
|
509 friend ComplexRowVector operator * (const RowVector& a, |
|
510 const ComplexMatrix& b); |
|
511 |
|
512 // row vector by row vector -> row vector operations |
|
513 |
|
514 friend ComplexRowVector operator + (const RowVector& a, |
|
515 const ComplexRowVector& b); |
|
516 friend ComplexRowVector operator - (const RowVector& a, |
|
517 const ComplexRowVector& b); |
|
518 |
|
519 friend ComplexRowVector product (const RowVector& a, |
|
520 const ComplexRowVector& b); |
|
521 friend ComplexRowVector quotient (const RowVector& a, |
|
522 const ComplexRowVector& b); |
|
523 |
|
524 // other operations |
3
|
525 |
|
526 friend RowVector map (d_d_Mapper f, const RowVector& a); |
|
527 void map (d_d_Mapper f); |
|
528 |
|
529 double min (void) const; |
|
530 double max (void) const; |
|
531 |
|
532 // i/o |
|
533 |
|
534 friend ostream& operator << (ostream& os, const RowVector& a); |
378
|
535 friend ostream& operator >> (ostream& is, RowVector& a); |
3
|
536 |
238
|
537 #define KLUDGE_VECTORS |
|
538 #define TYPE double |
|
539 #define KL_VEC_TYPE RowVector |
|
540 #include "mx-kludge.h" |
|
541 #undef KLUDGE_VECTORS |
|
542 #undef TYPE |
|
543 #undef KL_VEC_TYPE |
3
|
544 |
|
545 private: |
238
|
546 |
|
547 RowVector (double *d, int l) : Array<double> (d, l) { } |
3
|
548 }; |
|
549 |
|
550 /* |
|
551 * Diagonal Matrix class |
|
552 */ |
|
553 |
238
|
554 class DiagMatrix : public DiagArray<double> |
3
|
555 { |
238
|
556 friend class SVD; |
|
557 friend class ComplexSVD; |
3
|
558 |
|
559 public: |
238
|
560 |
|
561 DiagMatrix (void) : DiagArray<double> () { } |
|
562 DiagMatrix (int n) : DiagArray<double> (n) { } |
|
563 DiagMatrix (int n, double val) : DiagArray<double> (n, val) { } |
|
564 DiagMatrix (int r, int c) : DiagArray<double> (r, c) { } |
|
565 DiagMatrix (int r, int c, double val) : DiagArray<double> (r, c, val) { } |
|
566 DiagMatrix (const RowVector& a) : DiagArray<double> (a) { } |
|
567 DiagMatrix (const ColumnVector& a) : DiagArray<double> (a) { } |
|
568 DiagMatrix (const DiagArray<double>& a) : DiagArray<double> (a) { } |
|
569 DiagMatrix (const DiagMatrix& a) : DiagArray<double> (a) { } |
|
570 // DiagMatrix (double a) : DiagArray<double> (1, a) { } |
|
571 |
|
572 DiagMatrix& operator = (const DiagMatrix& a) |
291
|
573 { |
|
574 DiagArray<double>::operator = (a); |
|
575 return *this; |
|
576 } |
238
|
577 |
|
578 // operator DiagArray<double>& () const { return *this; } |
3
|
579 |
|
580 int operator == (const DiagMatrix& a) const; |
|
581 int operator != (const DiagMatrix& a) const; |
|
582 |
|
583 DiagMatrix& fill (double val); |
|
584 DiagMatrix& fill (double val, int beg, int end); |
|
585 DiagMatrix& fill (const ColumnVector& a); |
|
586 DiagMatrix& fill (const RowVector& a); |
|
587 DiagMatrix& fill (const ColumnVector& a, int beg); |
|
588 DiagMatrix& fill (const RowVector& a, int beg); |
|
589 |
|
590 DiagMatrix transpose (void) const; |
|
591 |
|
592 // resize is the destructive analog for this one |
|
593 |
|
594 Matrix extract (int r1, int c1, int r2, int c2) const; |
|
595 |
|
596 // extract row or column i. |
|
597 |
|
598 RowVector row (int i) const; |
|
599 RowVector row (char *s) const; |
|
600 |
|
601 ColumnVector column (int i) const; |
|
602 ColumnVector column (char *s) const; |
|
603 |
238
|
604 DiagMatrix inverse (void) const; |
3
|
605 DiagMatrix inverse (int& info) const; |
238
|
606 |
|
607 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
608 |
|
609 DiagMatrix& operator += (const DiagMatrix& a); |
|
610 DiagMatrix& operator -= (const DiagMatrix& a); |
3
|
611 |
|
612 // diagonal matrix by scalar -> matrix operations |
|
613 |
238
|
614 friend Matrix operator + (const DiagMatrix& a, double s); |
|
615 friend Matrix operator - (const DiagMatrix& a, double s); |
|
616 |
|
617 friend ComplexMatrix operator + (const DiagMatrix& a, const Complex& s); |
|
618 friend ComplexMatrix operator - (const DiagMatrix& a, const Complex& s); |
3
|
619 |
|
620 // diagonal matrix by scalar -> diagonal matrix operations |
|
621 |
238
|
622 friend ComplexDiagMatrix operator * (const DiagMatrix& a, const Complex& s); |
|
623 friend ComplexDiagMatrix operator / (const DiagMatrix& a, const Complex& s); |
3
|
624 |
|
625 // scalar by diagonal matrix -> matrix operations |
|
626 |
|
627 friend Matrix operator + (double s, const DiagMatrix& a); |
|
628 friend Matrix operator - (double s, const DiagMatrix& a); |
|
629 |
238
|
630 friend ComplexMatrix operator + (const Complex& s, const DiagMatrix& a); |
|
631 friend ComplexMatrix operator - (const Complex& s, const DiagMatrix& a); |
|
632 |
3
|
633 // scalar by diagonal matrix -> diagonal matrix operations |
|
634 |
238
|
635 friend ComplexDiagMatrix operator * (const Complex& s, const DiagMatrix& a); |
3
|
636 |
|
637 // diagonal matrix by column vector -> column vector operations |
|
638 |
238
|
639 friend ColumnVector operator * (const DiagMatrix& a, const ColumnVector& b); |
|
640 |
343
|
641 friend ComplexColumnVector operator * (const DiagMatrix& a, |
|
642 const ComplexColumnVector& b); |
3
|
643 |
|
644 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
645 |
378
|
646 friend DiagMatrix operator * (const DiagMatrix& a, |
|
647 const DiagMatrix& b); |
|
648 |
238
|
649 friend ComplexDiagMatrix operator + (const DiagMatrix& a, |
|
650 const ComplexDiagMatrix& b); |
|
651 friend ComplexDiagMatrix operator - (const DiagMatrix& a, |
|
652 const ComplexDiagMatrix& b); |
378
|
653 friend ComplexDiagMatrix operator * (const DiagMatrix& a, |
|
654 const ComplexDiagMatrix& b); |
238
|
655 |
|
656 friend ComplexDiagMatrix product (const DiagMatrix& a, |
|
657 const ComplexDiagMatrix& b); |
3
|
658 |
|
659 // diagonal matrix by matrix -> matrix operations |
|
660 |
238
|
661 friend Matrix operator + (const DiagMatrix& a, const Matrix& b); |
|
662 friend Matrix operator - (const DiagMatrix& a, const Matrix& b); |
|
663 friend Matrix operator * (const DiagMatrix& a, const Matrix& b); |
|
664 |
|
665 friend ComplexMatrix operator + (const DiagMatrix& a, |
|
666 const ComplexMatrix& b); |
|
667 friend ComplexMatrix operator - (const DiagMatrix& a, |
|
668 const ComplexMatrix& b); |
|
669 friend ComplexMatrix operator * (const DiagMatrix& a, |
|
670 const ComplexMatrix& b); |
|
671 |
|
672 // other operations |
3
|
673 |
|
674 ColumnVector diag (void) const; |
|
675 ColumnVector diag (int k) const; |
|
676 |
|
677 // i/o |
|
678 |
|
679 friend ostream& operator << (ostream& os, const DiagMatrix& a); |
|
680 |
238
|
681 #define KLUDGE_DIAG_MATRICES |
|
682 #define TYPE double |
|
683 #define KL_DMAT_TYPE DiagMatrix |
|
684 #include "mx-kludge.h" |
|
685 #undef KLUDGE_DIAG_MATRICES |
|
686 #undef TYPE |
|
687 #undef KL_DMAT_TYPE |
|
688 |
3
|
689 private: |
238
|
690 |
|
691 DiagMatrix (double *d, int nr, int nc) : DiagArray<double> (d, nr, nc) { } |
3
|
692 }; |
|
693 |
|
694 /* |
|
695 * Complex Matrix class |
|
696 */ |
|
697 |
238
|
698 class ComplexMatrix : public Array2<Complex> |
3
|
699 { |
238
|
700 friend class ComplexLU; |
3
|
701 friend class ComplexSVD; |
|
702 |
|
703 public: |
238
|
704 |
|
705 ComplexMatrix (void) : Array2<Complex> () { } |
|
706 ComplexMatrix (int r, int c) : Array2<Complex> (r, c) { } |
|
707 ComplexMatrix (int r, int c, const Complex& val) |
|
708 : Array2<Complex> (r, c, val) { } |
3
|
709 ComplexMatrix (const Matrix& a); |
238
|
710 ComplexMatrix (const Array2<Complex>& a) : Array2<Complex> (a) { } |
|
711 ComplexMatrix (const ComplexMatrix& a) : Array2<Complex> (a) { } |
3
|
712 ComplexMatrix (const DiagMatrix& a); |
238
|
713 ComplexMatrix (const DiagArray<Complex>& a) : Array2<Complex> (a) { } |
3
|
714 ComplexMatrix (const ComplexDiagMatrix& a); |
238
|
715 // ComplexMatrix (double a) : Array2<Complex> (1, 1, a) { } |
|
716 // ComplexMatrix (const Complex& a) : Array2<Complex> (1, 1, a) { } |
|
717 |
|
718 ComplexMatrix& operator = (const ComplexMatrix& a) |
291
|
719 { |
|
720 Array2<Complex>::operator = (a); |
|
721 return *this; |
|
722 } |
238
|
723 |
|
724 // operator Array2<Complex>& () const { return *this; } |
3
|
725 |
|
726 int operator == (const ComplexMatrix& a) const; |
|
727 int operator != (const ComplexMatrix& a) const; |
|
728 |
|
729 // destructive insert/delete/reorder operations |
|
730 |
|
731 ComplexMatrix& insert (const Matrix& a, int r, int c); |
|
732 ComplexMatrix& insert (const RowVector& a, int r, int c); |
|
733 ComplexMatrix& insert (const ColumnVector& a, int r, int c); |
|
734 ComplexMatrix& insert (const DiagMatrix& a, int r, int c); |
|
735 |
|
736 ComplexMatrix& insert (const ComplexMatrix& a, int r, int c); |
|
737 ComplexMatrix& insert (const ComplexRowVector& a, int r, int c); |
|
738 ComplexMatrix& insert (const ComplexColumnVector& a, int r, int c); |
|
739 ComplexMatrix& insert (const ComplexDiagMatrix& a, int r, int c); |
|
740 |
|
741 ComplexMatrix& fill (double val); |
161
|
742 ComplexMatrix& fill (const Complex& val); |
3
|
743 ComplexMatrix& fill (double val, int r1, int c1, int r2, int c2); |
161
|
744 ComplexMatrix& fill (const Complex& val, int r1, int c1, int r2, int c2); |
3
|
745 |
|
746 ComplexMatrix append (const Matrix& a) const; |
|
747 ComplexMatrix append (const RowVector& a) const; |
|
748 ComplexMatrix append (const ColumnVector& a) const; |
|
749 ComplexMatrix append (const DiagMatrix& a) const; |
|
750 |
|
751 ComplexMatrix append (const ComplexMatrix& a) const; |
|
752 ComplexMatrix append (const ComplexRowVector& a) const; |
|
753 ComplexMatrix append (const ComplexColumnVector& a) const; |
|
754 ComplexMatrix append (const ComplexDiagMatrix& a) const; |
|
755 |
|
756 ComplexMatrix stack (const Matrix& a) const; |
|
757 ComplexMatrix stack (const RowVector& a) const; |
|
758 ComplexMatrix stack (const ColumnVector& a) const; |
|
759 ComplexMatrix stack (const DiagMatrix& a) const; |
|
760 |
|
761 ComplexMatrix stack (const ComplexMatrix& a) const; |
|
762 ComplexMatrix stack (const ComplexRowVector& a) const; |
|
763 ComplexMatrix stack (const ComplexColumnVector& a) const; |
|
764 ComplexMatrix stack (const ComplexDiagMatrix& a) const; |
|
765 |
|
766 ComplexMatrix hermitian (void) const; // complex conjugate transpose |
|
767 ComplexMatrix transpose (void) const; |
|
768 |
|
769 friend Matrix real (const ComplexMatrix& a); |
|
770 friend Matrix imag (const ComplexMatrix& a); |
|
771 friend ComplexMatrix conj (const ComplexMatrix& a); |
|
772 |
|
773 // resize is the destructive equivalent for this one |
|
774 |
|
775 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
776 |
|
777 // extract row or column i. |
|
778 |
|
779 ComplexRowVector row (int i) const; |
|
780 ComplexRowVector row (char *s) const; |
|
781 |
|
782 ComplexColumnVector column (int i) const; |
|
783 ComplexColumnVector column (char *s) const; |
|
784 |
238
|
785 ComplexMatrix inverse (void) const; |
3
|
786 ComplexMatrix inverse (int& info) const; |
238
|
787 ComplexMatrix inverse (int& info, double& rcond) const; |
3
|
788 |
|
789 ComplexMatrix fourier (void) const; |
|
790 ComplexMatrix ifourier (void) const; |
|
791 |
|
792 ComplexDET determinant (void) const; |
|
793 ComplexDET determinant (int& info) const; |
|
794 ComplexDET determinant (int& info, double& rcond) const; |
|
795 |
|
796 ComplexMatrix solve (const Matrix& b) const; |
|
797 ComplexMatrix solve (const Matrix& b, int& info) const; |
|
798 ComplexMatrix solve (const Matrix& b, int& info, double& rcond) const; |
|
799 |
|
800 ComplexMatrix solve (const ComplexMatrix& b) const; |
|
801 ComplexMatrix solve (const ComplexMatrix& b, int& info) const; |
|
802 ComplexMatrix solve (const ComplexMatrix& b, int& info, double& rcond) const; |
|
803 |
|
804 ComplexColumnVector solve (const ComplexColumnVector& b) const; |
|
805 ComplexColumnVector solve (const ComplexColumnVector& b, int& info) const; |
|
806 ComplexColumnVector solve (const ComplexColumnVector& b, int& info, |
|
807 double& rcond) const; |
|
808 |
|
809 ComplexMatrix lssolve (const ComplexMatrix& b) const; |
|
810 ComplexMatrix lssolve (const ComplexMatrix& b, int& info) const; |
|
811 ComplexMatrix lssolve (const ComplexMatrix& b, int& info, |
|
812 int& rank) const; |
|
813 |
|
814 ComplexColumnVector lssolve (const ComplexColumnVector& b) const; |
|
815 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info) const; |
|
816 ComplexColumnVector lssolve (const ComplexColumnVector& b, int& info, |
|
817 int& rank) const; |
|
818 |
|
819 // matrix by diagonal matrix -> matrix operations |
|
820 |
|
821 ComplexMatrix& operator += (const DiagMatrix& a); |
|
822 ComplexMatrix& operator -= (const DiagMatrix& a); |
|
823 |
|
824 ComplexMatrix& operator += (const ComplexDiagMatrix& a); |
|
825 ComplexMatrix& operator -= (const ComplexDiagMatrix& a); |
|
826 |
|
827 // matrix by matrix -> matrix operations |
|
828 |
|
829 ComplexMatrix& operator += (const Matrix& a); |
|
830 ComplexMatrix& operator -= (const Matrix& a); |
|
831 |
|
832 ComplexMatrix& operator += (const ComplexMatrix& a); |
|
833 ComplexMatrix& operator -= (const ComplexMatrix& a); |
|
834 |
|
835 // unary operations |
|
836 |
|
837 Matrix operator ! (void) const; |
|
838 |
238
|
839 // matrix by scalar -> matrix operations |
|
840 |
|
841 friend ComplexMatrix operator + (const ComplexMatrix& a, double s); |
|
842 friend ComplexMatrix operator - (const ComplexMatrix& a, double s); |
|
843 friend ComplexMatrix operator * (const ComplexMatrix& a, double s); |
|
844 friend ComplexMatrix operator / (const ComplexMatrix& a, double s); |
|
845 |
|
846 // scalar by matrix -> matrix operations |
|
847 |
|
848 friend ComplexMatrix operator + (double s, const ComplexMatrix& a); |
|
849 friend ComplexMatrix operator - (double s, const ComplexMatrix& a); |
|
850 friend ComplexMatrix operator * (double s, const ComplexMatrix& a); |
|
851 friend ComplexMatrix operator / (double s, const ComplexMatrix& a); |
|
852 |
|
853 // matrix by column vector -> column vector operations |
|
854 |
|
855 friend ComplexColumnVector operator * (const ComplexMatrix& a, |
|
856 const ColumnVector& b); |
|
857 |
|
858 friend ComplexColumnVector operator * (const ComplexMatrix& a, |
|
859 const ComplexColumnVector& b); |
|
860 |
|
861 // matrix by diagonal matrix -> matrix operations |
|
862 |
|
863 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
864 const DiagMatrix& b); |
|
865 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
866 const DiagMatrix& b); |
|
867 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
868 const DiagMatrix& b); |
|
869 |
|
870 friend ComplexMatrix operator + (const ComplexMatrix& a, |
|
871 const ComplexDiagMatrix& b); |
|
872 friend ComplexMatrix operator - (const ComplexMatrix& a, |
|
873 const ComplexDiagMatrix& b); |
|
874 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
875 const ComplexDiagMatrix& b); |
|
876 |
|
877 // matrix by matrix -> matrix operations |
|
878 |
|
879 friend ComplexMatrix operator + (const ComplexMatrix& a, const Matrix& b); |
|
880 friend ComplexMatrix operator - (const ComplexMatrix& a, const Matrix& b); |
|
881 |
|
882 friend ComplexMatrix operator * (const ComplexMatrix& a, const Matrix& b); |
|
883 friend ComplexMatrix operator * (const ComplexMatrix& a, |
|
884 const ComplexMatrix& b); |
|
885 |
|
886 friend ComplexMatrix product (const ComplexMatrix& a, const Matrix& b); |
|
887 friend ComplexMatrix quotient (const ComplexMatrix& a, const Matrix& b); |
|
888 |
3
|
889 // other operations |
|
890 |
|
891 friend ComplexMatrix map (c_c_Mapper f, const ComplexMatrix& a); |
|
892 friend Matrix map (d_c_Mapper f, const ComplexMatrix& a); |
|
893 void map (c_c_Mapper f); |
|
894 |
|
895 Matrix all (void) const; |
|
896 Matrix any (void) const; |
|
897 |
|
898 ComplexMatrix cumprod (void) const; |
|
899 ComplexMatrix cumsum (void) const; |
|
900 ComplexMatrix prod (void) const; |
|
901 ComplexMatrix sum (void) const; |
|
902 ComplexMatrix sumsq (void) const; |
|
903 |
|
904 ComplexColumnVector diag (void) const; |
|
905 ComplexColumnVector diag (int k) const; |
|
906 |
|
907 ComplexColumnVector row_min (void) const; |
210
|
908 ComplexColumnVector row_min_loc (void) const; |
|
909 |
3
|
910 ComplexColumnVector row_max (void) const; |
210
|
911 ComplexColumnVector row_max_loc (void) const; |
3
|
912 |
|
913 ComplexRowVector column_min (void) const; |
210
|
914 ComplexRowVector column_min_loc (void) const; |
|
915 |
3
|
916 ComplexRowVector column_max (void) const; |
210
|
917 ComplexRowVector column_max_loc (void) const; |
3
|
918 |
|
919 // i/o |
|
920 |
|
921 friend ostream& operator << (ostream& os, const ComplexMatrix& a); |
|
922 friend istream& operator >> (istream& is, ComplexMatrix& a); |
|
923 |
238
|
924 #define KLUDGE_MATRICES |
|
925 #define TYPE Complex |
|
926 #define KL_MAT_TYPE ComplexMatrix |
|
927 #include "mx-kludge.h" |
|
928 #undef KLUDGE_MATRICES |
|
929 #undef TYPE |
|
930 #undef KL_MAT_TYPE |
3
|
931 |
|
932 private: |
238
|
933 |
|
934 ComplexMatrix (Complex *d, int r, int c) : Array2<Complex> (d, r, c) { } |
3
|
935 }; |
|
936 |
|
937 /* |
|
938 * Complex Column Vector class |
|
939 */ |
|
940 |
238
|
941 class ComplexColumnVector : public Array<Complex> |
3
|
942 { |
291
|
943 friend class ComplexRowVector; |
|
944 |
3
|
945 public: |
238
|
946 |
|
947 ComplexColumnVector (void) : Array<Complex> () { } |
|
948 ComplexColumnVector (int n) : Array<Complex> (n) { } |
|
949 ComplexColumnVector (int n, const Complex& val) |
|
950 : Array<Complex> (n, val) { } |
3
|
951 ComplexColumnVector (const ColumnVector& a); |
238
|
952 ComplexColumnVector (const Array<Complex>& a) : Array<Complex> (a) { } |
|
953 ComplexColumnVector (const ComplexColumnVector& a) : Array<Complex> (a) { } |
|
954 // ComplexColumnVector (double a) : Array<Complex> (1, a) { } |
|
955 // ComplexColumnVector (const Complex& a) : Array<Complex> (1, a) { } |
|
956 |
|
957 ComplexColumnVector& operator = (const ComplexColumnVector& a) |
291
|
958 { |
|
959 Array<Complex>::operator = (a); |
|
960 return *this; |
|
961 } |
238
|
962 |
|
963 // operator Array<Complex>& () const { return *this; } |
3
|
964 |
|
965 int operator == (const ComplexColumnVector& a) const; |
|
966 int operator != (const ComplexColumnVector& a) const; |
|
967 |
|
968 // destructive insert/delete/reorder operations |
|
969 |
|
970 ComplexColumnVector& insert (const ColumnVector& a, int r); |
|
971 ComplexColumnVector& insert (const ComplexColumnVector& a, int r); |
|
972 |
|
973 ComplexColumnVector& fill (double val); |
161
|
974 ComplexColumnVector& fill (const Complex& val); |
3
|
975 ComplexColumnVector& fill (double val, int r1, int r2); |
161
|
976 ComplexColumnVector& fill (const Complex& val, int r1, int r2); |
3
|
977 |
|
978 ComplexColumnVector stack (const ColumnVector& a) const; |
|
979 ComplexColumnVector stack (const ComplexColumnVector& a) const; |
|
980 |
|
981 ComplexRowVector hermitian (void) const; // complex conjugate transpose. |
|
982 ComplexRowVector transpose (void) const; |
|
983 |
|
984 friend ColumnVector real (const ComplexColumnVector& a); |
|
985 friend ColumnVector imag (const ComplexColumnVector& a); |
|
986 friend ComplexColumnVector conj (const ComplexColumnVector& a); |
|
987 |
|
988 // resize is the destructive equivalent for this one |
|
989 |
|
990 ComplexColumnVector extract (int r1, int r2) const; |
|
991 |
238
|
992 // column vector by column vector -> column vector operations |
|
993 |
|
994 ComplexColumnVector& operator += (const ColumnVector& a); |
|
995 ComplexColumnVector& operator -= (const ColumnVector& a); |
|
996 |
|
997 ComplexColumnVector& operator += (const ComplexColumnVector& a); |
|
998 ComplexColumnVector& operator -= (const ComplexColumnVector& a); |
|
999 |
3
|
1000 // column vector by scalar -> column vector operations |
|
1001 |
238
|
1002 friend ComplexColumnVector operator + (const ComplexColumnVector& a, |
|
1003 double s); |
|
1004 friend ComplexColumnVector operator - (const ComplexColumnVector& a, |
|
1005 double s); |
|
1006 friend ComplexColumnVector operator * (const ComplexColumnVector& a, |
|
1007 double s); |
|
1008 friend ComplexColumnVector operator / (const ComplexColumnVector& a, |
|
1009 double s); |
3
|
1010 |
|
1011 // scalar by column vector -> column vector operations |
|
1012 |
|
1013 friend ComplexColumnVector operator + (double s, |
|
1014 const ComplexColumnVector& a); |
|
1015 friend ComplexColumnVector operator - (double s, |
|
1016 const ComplexColumnVector& a); |
|
1017 friend ComplexColumnVector operator * (double s, |
|
1018 const ComplexColumnVector& a); |
|
1019 friend ComplexColumnVector operator / (double s, |
|
1020 const ComplexColumnVector& a); |
|
1021 |
|
1022 // column vector by row vector -> matrix operations |
|
1023 |
238
|
1024 friend ComplexMatrix operator * (const ComplexColumnVector& a, |
|
1025 const ComplexRowVector& b); |
3
|
1026 |
|
1027 // column vector by column vector -> column vector operations |
|
1028 |
238
|
1029 friend ComplexColumnVector operator + (const ComplexColumnVector& a, |
|
1030 const ColumnVector& b); |
|
1031 friend ComplexColumnVector operator - (const ComplexColumnVector& a, |
|
1032 const ColumnVector& b); |
|
1033 |
|
1034 friend ComplexColumnVector product (const ComplexColumnVector& a, |
|
1035 const ColumnVector& b); |
|
1036 friend ComplexColumnVector quotient (const ComplexColumnVector& a, |
|
1037 const ColumnVector& b); |
|
1038 |
|
1039 // other operations |
3
|
1040 |
|
1041 friend ComplexColumnVector map (c_c_Mapper f, const ComplexColumnVector& a); |
|
1042 friend ColumnVector map (d_c_Mapper f, const ComplexColumnVector& a); |
|
1043 void map (c_c_Mapper f); |
|
1044 |
|
1045 Complex min (void) const; |
|
1046 Complex max (void) const; |
|
1047 |
|
1048 // i/o |
|
1049 |
|
1050 friend ostream& operator << (ostream& os, const ComplexColumnVector& a); |
378
|
1051 friend ostream& operator >> (ostream& is, ComplexColumnVector& a); |
3
|
1052 |
238
|
1053 #define KLUDGE_VECTORS |
|
1054 #define TYPE Complex |
|
1055 #define KL_VEC_TYPE ComplexColumnVector |
|
1056 #include "mx-kludge.h" |
|
1057 #undef KLUDGE_VECTORS |
|
1058 #undef TYPE |
|
1059 #undef KL_VEC_TYPE |
3
|
1060 |
|
1061 private: |
238
|
1062 |
|
1063 ComplexColumnVector (Complex *d, int l) : Array<Complex> (d, l) { } |
3
|
1064 }; |
|
1065 |
|
1066 /* |
|
1067 * Complex Row Vector class |
|
1068 */ |
|
1069 |
238
|
1070 class ComplexRowVector : public Array<Complex> |
3
|
1071 { |
291
|
1072 friend class ComplexColumnVector; |
|
1073 |
3
|
1074 public: |
238
|
1075 |
|
1076 ComplexRowVector (void) : Array<Complex> () { } |
|
1077 ComplexRowVector (int n) : Array<Complex> (n) { } |
|
1078 ComplexRowVector (int n, const Complex& val) : Array<Complex> (n, val) { } |
3
|
1079 ComplexRowVector (const RowVector& a); |
238
|
1080 ComplexRowVector (const Array<Complex>& a) : Array<Complex> (a) { } |
|
1081 ComplexRowVector (const ComplexRowVector& a) : Array<Complex> (a) { } |
|
1082 // ComplexRowVector (double a) : Array<Complex> (1, a) { } |
|
1083 // ComplexRowVector (const Complex& a) : Array<Complex> (1, a) { } |
|
1084 |
|
1085 ComplexRowVector& operator = (const ComplexRowVector& a) |
291
|
1086 { |
|
1087 Array<Complex>::operator = (a); |
|
1088 return *this; |
|
1089 } |
238
|
1090 |
|
1091 // operator Array<Complex>& () const { return *this; } |
3
|
1092 |
|
1093 int operator == (const ComplexRowVector& a) const; |
|
1094 int operator != (const ComplexRowVector& a) const; |
|
1095 |
|
1096 // destructive insert/delete/reorder operations |
|
1097 |
|
1098 ComplexRowVector& insert (const RowVector& a, int c); |
|
1099 ComplexRowVector& insert (const ComplexRowVector& a, int c); |
|
1100 |
|
1101 ComplexRowVector& fill (double val); |
161
|
1102 ComplexRowVector& fill (const Complex& val); |
3
|
1103 ComplexRowVector& fill (double val, int c1, int c2); |
161
|
1104 ComplexRowVector& fill (const Complex& val, int c1, int c2); |
3
|
1105 |
|
1106 ComplexRowVector append (const RowVector& a) const; |
|
1107 ComplexRowVector append (const ComplexRowVector& a) const; |
|
1108 |
|
1109 ComplexColumnVector hermitian (void) const; // complex conjugate transpose. |
|
1110 ComplexColumnVector transpose (void) const; |
|
1111 |
|
1112 friend RowVector real (const ComplexRowVector& a); |
|
1113 friend RowVector imag (const ComplexRowVector& a); |
|
1114 friend ComplexRowVector conj (const ComplexRowVector& a); |
|
1115 |
|
1116 // resize is the destructive equivalent for this one |
|
1117 |
|
1118 ComplexRowVector extract (int c1, int c2) const; |
|
1119 |
238
|
1120 // row vector by row vector -> row vector operations |
|
1121 |
|
1122 ComplexRowVector& operator += (const RowVector& a); |
|
1123 ComplexRowVector& operator -= (const RowVector& a); |
|
1124 |
|
1125 ComplexRowVector& operator += (const ComplexRowVector& a); |
|
1126 ComplexRowVector& operator -= (const ComplexRowVector& a); |
|
1127 |
3
|
1128 // row vector by scalar -> row vector operations |
|
1129 |
238
|
1130 friend ComplexRowVector operator + (const ComplexRowVector& a, double s); |
|
1131 friend ComplexRowVector operator - (const ComplexRowVector& a, double s); |
|
1132 friend ComplexRowVector operator * (const ComplexRowVector& a, double s); |
|
1133 friend ComplexRowVector operator / (const ComplexRowVector& a, double s); |
3
|
1134 |
|
1135 // scalar by row vector -> row vector operations |
|
1136 |
|
1137 friend ComplexRowVector operator + (double s, const ComplexRowVector& a); |
|
1138 friend ComplexRowVector operator - (double s, const ComplexRowVector& a); |
|
1139 friend ComplexRowVector operator * (double s, const ComplexRowVector& a); |
|
1140 friend ComplexRowVector operator / (double s, const ComplexRowVector& a); |
|
1141 |
|
1142 // row vector by column vector -> scalar |
|
1143 |
238
|
1144 friend Complex operator * (const ComplexRowVector& a, const ColumnVector& b); |
|
1145 |
|
1146 friend Complex operator * (const ComplexRowVector& a, |
|
1147 const ComplexColumnVector& b); |
3
|
1148 |
|
1149 // row vector by matrix -> row vector |
|
1150 |
238
|
1151 friend ComplexRowVector operator * (const ComplexRowVector& a, |
|
1152 const ComplexMatrix& b); |
3
|
1153 |
|
1154 // row vector by row vector -> row vector operations |
|
1155 |
238
|
1156 friend ComplexRowVector operator + (const ComplexRowVector& a, |
|
1157 const RowVector& b); |
|
1158 friend ComplexRowVector operator - (const ComplexRowVector& a, |
|
1159 const RowVector& b); |
|
1160 |
|
1161 friend ComplexRowVector product (const ComplexRowVector& a, |
|
1162 const RowVector& b); |
|
1163 friend ComplexRowVector quotient (const ComplexRowVector& a, |
|
1164 const RowVector& b); |
|
1165 |
|
1166 // other operations |
3
|
1167 |
|
1168 friend ComplexRowVector map (c_c_Mapper f, const ComplexRowVector& a); |
|
1169 friend RowVector map (d_c_Mapper f, const ComplexRowVector& a); |
|
1170 void map (c_c_Mapper f); |
|
1171 |
|
1172 Complex min (void) const; |
|
1173 Complex max (void) const; |
|
1174 |
|
1175 // i/o |
|
1176 |
|
1177 friend ostream& operator << (ostream& os, const ComplexRowVector& a); |
378
|
1178 friend ostream& operator >> (ostream& is, ComplexRowVector& a); |
3
|
1179 |
238
|
1180 #define KLUDGE_VECTORS |
|
1181 #define TYPE Complex |
|
1182 #define KL_VEC_TYPE ComplexRowVector |
|
1183 #include "mx-kludge.h" |
|
1184 #undef KLUDGE_VECTORS |
|
1185 #undef TYPE |
|
1186 #undef KL_VEC_TYPE |
3
|
1187 |
|
1188 private: |
238
|
1189 |
|
1190 ComplexRowVector (Complex *d, int l) : Array<Complex> (d, l) { } |
3
|
1191 }; |
|
1192 |
|
1193 /* |
|
1194 * Complex Diagonal Matrix class |
|
1195 */ |
|
1196 |
238
|
1197 class ComplexDiagMatrix : public DiagArray<Complex> |
3
|
1198 { |
|
1199 public: |
238
|
1200 |
|
1201 ComplexDiagMatrix (void) : DiagArray<Complex> () { } |
|
1202 ComplexDiagMatrix (int n) : DiagArray<Complex> (n) { } |
|
1203 ComplexDiagMatrix (int n, const Complex& val) |
|
1204 : DiagArray<Complex> (n, val) { } |
|
1205 ComplexDiagMatrix (int r, int c) : DiagArray<Complex> (r, c) { } |
|
1206 ComplexDiagMatrix (int r, int c, const Complex& val) |
|
1207 : DiagArray<Complex> (r, c, val) { } |
3
|
1208 ComplexDiagMatrix (const RowVector& a); |
238
|
1209 ComplexDiagMatrix (const ComplexRowVector& a) : DiagArray<Complex> (a) { } |
3
|
1210 ComplexDiagMatrix (const ColumnVector& a); |
238
|
1211 ComplexDiagMatrix (const ComplexColumnVector& a) |
|
1212 : DiagArray<Complex> (a) { } |
3
|
1213 ComplexDiagMatrix (const DiagMatrix& a); |
238
|
1214 ComplexDiagMatrix (const DiagArray<Complex>& a) |
|
1215 : DiagArray<Complex> (a) { } |
|
1216 ComplexDiagMatrix (const ComplexDiagMatrix& a) : DiagArray<Complex> (a) { } |
|
1217 // ComplexDiagMatrix (const Complex& a) : DiagArray<Complex> (1, a) { } |
|
1218 |
|
1219 ComplexDiagMatrix& operator = (const ComplexDiagMatrix& a) |
291
|
1220 { |
|
1221 DiagArray<Complex>::operator = (a); |
|
1222 return *this; |
|
1223 } |
238
|
1224 |
|
1225 // operator DiagArray<Complex>& () const { return *this; } |
3
|
1226 |
|
1227 int operator == (const ComplexDiagMatrix& a) const; |
|
1228 int operator != (const ComplexDiagMatrix& a) const; |
|
1229 |
|
1230 ComplexDiagMatrix& fill (double val); |
161
|
1231 ComplexDiagMatrix& fill (const Complex& val); |
3
|
1232 ComplexDiagMatrix& fill (double val, int beg, int end); |
161
|
1233 ComplexDiagMatrix& fill (const Complex& val, int beg, int end); |
3
|
1234 ComplexDiagMatrix& fill (const ColumnVector& a); |
|
1235 ComplexDiagMatrix& fill (const ComplexColumnVector& a); |
|
1236 ComplexDiagMatrix& fill (const RowVector& a); |
|
1237 ComplexDiagMatrix& fill (const ComplexRowVector& a); |
|
1238 ComplexDiagMatrix& fill (const ColumnVector& a, int beg); |
|
1239 ComplexDiagMatrix& fill (const ComplexColumnVector& a, int beg); |
|
1240 ComplexDiagMatrix& fill (const RowVector& a, int beg); |
|
1241 ComplexDiagMatrix& fill (const ComplexRowVector& a, int beg); |
|
1242 |
|
1243 ComplexDiagMatrix hermitian (void) const; // complex conjugate transpose |
|
1244 ComplexDiagMatrix transpose (void) const; |
|
1245 |
|
1246 friend DiagMatrix real (const ComplexDiagMatrix& a); |
|
1247 friend DiagMatrix imag (const ComplexDiagMatrix& a); |
|
1248 friend ComplexDiagMatrix conj (const ComplexDiagMatrix& a); |
|
1249 |
|
1250 // resize is the destructive analog for this one |
|
1251 |
|
1252 ComplexMatrix extract (int r1, int c1, int r2, int c2) const; |
|
1253 |
|
1254 // extract row or column i. |
|
1255 |
|
1256 ComplexRowVector row (int i) const; |
|
1257 ComplexRowVector row (char *s) const; |
|
1258 |
|
1259 ComplexColumnVector column (int i) const; |
|
1260 ComplexColumnVector column (char *s) const; |
|
1261 |
|
1262 ComplexDiagMatrix inverse (int& info) const; |
|
1263 ComplexDiagMatrix inverse (void) const; |
|
1264 |
|
1265 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
1266 |
|
1267 ComplexDiagMatrix& operator += (const DiagMatrix& a); |
|
1268 ComplexDiagMatrix& operator -= (const DiagMatrix& a); |
|
1269 |
|
1270 ComplexDiagMatrix& operator += (const ComplexDiagMatrix& a); |
|
1271 ComplexDiagMatrix& operator -= (const ComplexDiagMatrix& a); |
|
1272 |
238
|
1273 // diagonal matrix by scalar -> matrix operations |
|
1274 |
|
1275 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, double s); |
|
1276 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, double s); |
|
1277 |
|
1278 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
1279 const Complex& s); |
|
1280 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
1281 const Complex& s); |
|
1282 |
|
1283 // diagonal matrix by scalar -> diagonal matrix operations |
|
1284 |
|
1285 friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, double s); |
|
1286 friend ComplexDiagMatrix operator / (const ComplexDiagMatrix& a, double s); |
|
1287 |
|
1288 // scalar by diagonal matrix -> matrix operations |
|
1289 |
|
1290 friend ComplexMatrix operator + (double s, const ComplexDiagMatrix& a); |
|
1291 friend ComplexMatrix operator - (double s, const ComplexDiagMatrix& a); |
|
1292 |
|
1293 friend ComplexMatrix operator + (const Complex& s, |
|
1294 const ComplexDiagMatrix& a); |
|
1295 friend ComplexMatrix operator - (const Complex& s, |
|
1296 const ComplexDiagMatrix& a); |
|
1297 |
|
1298 // scalar by diagonal matrix -> diagonal matrix operations |
|
1299 |
|
1300 friend ComplexDiagMatrix operator * (double s, const ComplexDiagMatrix& a); |
|
1301 |
|
1302 // diagonal matrix by column vector -> column vector operations |
|
1303 |
|
1304 friend ComplexColumnVector operator * (const ComplexDiagMatrix& a, |
|
1305 const ColumnVector& b); |
|
1306 |
|
1307 friend ComplexColumnVector operator * (const ComplexDiagMatrix& a, |
|
1308 const ComplexColumnVector& b); |
|
1309 |
|
1310 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
1311 |
378
|
1312 friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, |
|
1313 const ComplexDiagMatrix& b); |
|
1314 |
238
|
1315 friend ComplexDiagMatrix operator + (const ComplexDiagMatrix& a, |
|
1316 const DiagMatrix& b); |
|
1317 friend ComplexDiagMatrix operator - (const ComplexDiagMatrix& a, |
|
1318 const DiagMatrix& b); |
378
|
1319 friend ComplexDiagMatrix operator * (const ComplexDiagMatrix& a, |
|
1320 const DiagMatrix& b); |
238
|
1321 |
|
1322 friend ComplexDiagMatrix product (const ComplexDiagMatrix& a, |
|
1323 const DiagMatrix& b); |
|
1324 |
3
|
1325 // diagonal matrix by matrix -> matrix operations |
|
1326 |
238
|
1327 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
1328 const Matrix& b); |
|
1329 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
1330 const Matrix& b); |
|
1331 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
1332 const Matrix& b); |
|
1333 |
|
1334 friend ComplexMatrix operator + (const ComplexDiagMatrix& a, |
|
1335 const ComplexMatrix& b); |
|
1336 friend ComplexMatrix operator - (const ComplexDiagMatrix& a, |
|
1337 const ComplexMatrix& b); |
|
1338 friend ComplexMatrix operator * (const ComplexDiagMatrix& a, |
|
1339 const ComplexMatrix& b); |
|
1340 |
|
1341 // other operations |
3
|
1342 |
|
1343 ComplexColumnVector diag (void) const; |
|
1344 ComplexColumnVector diag (int k) const; |
|
1345 |
|
1346 // i/o |
|
1347 |
|
1348 friend ostream& operator << (ostream& os, const ComplexDiagMatrix& a); |
|
1349 |
238
|
1350 #define KLUDGE_DIAG_MATRICES |
|
1351 #define TYPE Complex |
|
1352 #define KL_DMAT_TYPE ComplexDiagMatrix |
|
1353 #include "mx-kludge.h" |
|
1354 #undef KLUDGE_DIAG_MATRICES |
|
1355 #undef TYPE |
|
1356 #undef KL_DMAT_TYPE |
|
1357 |
3
|
1358 private: |
238
|
1359 |
|
1360 ComplexDiagMatrix (Complex *d, int nr, int nc) |
|
1361 : DiagArray<Complex> (d, nr, nc) { } |
3
|
1362 }; |
|
1363 |
|
1364 /* |
21
|
1365 * Result of a AEP Balance operation |
|
1366 */ |
|
1367 |
|
1368 class AEPBALANCE |
|
1369 { |
|
1370 friend class Matrix; |
|
1371 |
|
1372 public: |
238
|
1373 |
21
|
1374 AEPBALANCE (void) {} |
|
1375 |
|
1376 AEPBALANCE (const Matrix& a, const char *balance_job); |
|
1377 |
|
1378 AEPBALANCE (const AEPBALANCE& a); |
|
1379 |
|
1380 AEPBALANCE& operator = (const AEPBALANCE& a); |
|
1381 Matrix balanced_matrix (void) const; |
|
1382 Matrix balancing_matrix (void) const; |
|
1383 friend ostream& operator << (ostream& os, const AEPBALANCE& a); |
|
1384 |
|
1385 private: |
238
|
1386 |
21
|
1387 int init (const Matrix& a, const char * balance_job); |
|
1388 |
|
1389 Matrix balanced_mat; |
|
1390 Matrix balancing_mat; |
|
1391 }; |
|
1392 |
|
1393 inline AEPBALANCE::AEPBALANCE (const Matrix& a,const char * balance_job) |
|
1394 { |
227
|
1395 init (a, balance_job); |
21
|
1396 } |
|
1397 |
|
1398 inline AEPBALANCE::AEPBALANCE (const AEPBALANCE& a) |
|
1399 { |
|
1400 balanced_mat = a.balanced_mat; |
|
1401 balancing_mat = a.balancing_mat; |
|
1402 } |
|
1403 |
|
1404 inline AEPBALANCE& |
|
1405 AEPBALANCE::operator = (const AEPBALANCE& a) |
|
1406 { |
|
1407 balanced_mat = a.balanced_mat; |
|
1408 balancing_mat = a.balancing_mat; |
|
1409 |
|
1410 return *this; |
|
1411 } |
291
|
1412 |
21
|
1413 inline Matrix AEPBALANCE::balanced_matrix (void) const |
291
|
1414 { |
|
1415 return balanced_mat; |
|
1416 } |
21
|
1417 |
|
1418 inline Matrix AEPBALANCE::balancing_matrix (void) const |
291
|
1419 { |
|
1420 return balancing_mat; |
|
1421 } |
21
|
1422 |
|
1423 /* |
|
1424 * Result of a Complex balancing operation |
|
1425 */ |
|
1426 |
|
1427 class ComplexAEPBALANCE |
|
1428 { |
|
1429 friend class ComplexMatrix; |
|
1430 |
|
1431 public: |
238
|
1432 |
21
|
1433 ComplexAEPBALANCE (void) {} |
|
1434 ComplexAEPBALANCE (const ComplexMatrix& a, const char *balance_job); |
|
1435 ComplexAEPBALANCE (const ComplexAEPBALANCE& a); |
|
1436 ComplexAEPBALANCE& operator = (const ComplexAEPBALANCE& a); |
|
1437 ComplexMatrix balanced_matrix (void) const; |
|
1438 ComplexMatrix balancing_matrix (void) const; |
|
1439 |
|
1440 friend ostream& operator << (ostream& os, const ComplexAEPBALANCE& a); |
|
1441 |
|
1442 private: |
238
|
1443 |
21
|
1444 int init (const ComplexMatrix& a, const char * balance_job); |
|
1445 |
|
1446 ComplexMatrix balanced_mat; |
|
1447 ComplexMatrix balancing_mat; |
|
1448 }; |
|
1449 |
161
|
1450 inline ComplexAEPBALANCE::ComplexAEPBALANCE (const ComplexMatrix& a, |
|
1451 const char * balance_job) |
21
|
1452 { |
291
|
1453 init (a, balance_job); |
21
|
1454 } |
|
1455 |
|
1456 inline ComplexAEPBALANCE::ComplexAEPBALANCE (const ComplexAEPBALANCE& a) |
|
1457 { |
|
1458 balanced_mat = a.balanced_mat; |
|
1459 balancing_mat = a.balancing_mat; |
|
1460 } |
|
1461 |
|
1462 inline ComplexAEPBALANCE& |
|
1463 ComplexAEPBALANCE::operator = (const ComplexAEPBALANCE& a) |
|
1464 { |
|
1465 balanced_mat = a.balanced_mat; |
|
1466 balancing_mat = a.balancing_mat; |
|
1467 |
|
1468 return *this; |
|
1469 } |
|
1470 |
|
1471 inline ComplexMatrix ComplexAEPBALANCE::balanced_matrix (void) const |
291
|
1472 { |
|
1473 return balanced_mat; |
|
1474 } |
21
|
1475 |
|
1476 inline ComplexMatrix ComplexAEPBALANCE::balancing_matrix (void) const |
291
|
1477 { |
|
1478 return balancing_mat; |
|
1479 } |
21
|
1480 |
|
1481 /* |
3
|
1482 * Result of a Determinant calculation. |
|
1483 */ |
|
1484 |
|
1485 class DET |
|
1486 { |
|
1487 public: |
238
|
1488 |
3
|
1489 DET (void) {} |
|
1490 |
|
1491 DET (const DET& a); |
|
1492 |
|
1493 DET& operator = (const DET& a); |
|
1494 |
|
1495 int value_will_overflow (void) const; |
|
1496 int value_will_underflow (void) const; |
|
1497 double coefficient (void) const; |
|
1498 int exponent (void) const; |
|
1499 double value (void) const; |
|
1500 |
|
1501 friend ostream& operator << (ostream& os, const DET& a); |
|
1502 |
|
1503 private: |
238
|
1504 |
3
|
1505 DET (const double *d); |
|
1506 |
|
1507 double det [2]; |
|
1508 }; |
|
1509 |
291
|
1510 inline DET::DET (const DET& a) |
|
1511 { |
|
1512 det[0] = a.det[0]; |
|
1513 det[1] = a.det[1]; |
|
1514 } |
3
|
1515 |
|
1516 inline DET& DET::operator = (const DET& a) |
291
|
1517 { |
|
1518 det[0] = a.det[0]; |
|
1519 det[1] = a.det[1]; |
|
1520 return *this; |
|
1521 } |
|
1522 |
|
1523 inline DET::DET (const double *d) |
|
1524 { |
|
1525 det[0] = d[0]; |
|
1526 det[1] = d[1]; |
|
1527 } |
3
|
1528 |
|
1529 /* |
|
1530 * Result of a Determinant calculation. |
|
1531 */ |
|
1532 |
|
1533 class ComplexDET |
|
1534 { |
|
1535 public: |
238
|
1536 |
3
|
1537 ComplexDET (void) {} |
|
1538 |
|
1539 ComplexDET (const ComplexDET& a); |
|
1540 |
|
1541 ComplexDET& operator = (const ComplexDET& a); |
|
1542 |
|
1543 int value_will_overflow (void) const; |
|
1544 int value_will_underflow (void) const; |
|
1545 Complex coefficient (void) const; |
|
1546 int exponent (void) const; |
|
1547 Complex value (void) const; |
|
1548 |
|
1549 friend ostream& operator << (ostream& os, const ComplexDET& a); |
|
1550 |
|
1551 private: |
238
|
1552 |
3
|
1553 ComplexDET (const Complex *d); |
|
1554 |
|
1555 Complex det [2]; |
|
1556 }; |
|
1557 |
|
1558 inline ComplexDET::ComplexDET (const ComplexDET& a) |
291
|
1559 { |
|
1560 det[0] = a.det[0]; |
|
1561 det[1] = a.det[1]; |
|
1562 } |
3
|
1563 |
|
1564 inline ComplexDET& ComplexDET::operator = (const ComplexDET& a) |
291
|
1565 { |
|
1566 det[0] = a.det[0]; |
|
1567 det[1] = a.det[1]; |
|
1568 return *this; |
|
1569 } |
3
|
1570 |
|
1571 inline ComplexDET::ComplexDET (const Complex *d) |
291
|
1572 { |
|
1573 det[0] = d[0]; |
|
1574 det[1] = d[1]; |
|
1575 } |
3
|
1576 |
|
1577 /* |
21
|
1578 * Result of a GEP Balance operation |
|
1579 * Note: currenlty only do balancing on real data. Complex balancing |
|
1580 * done on magnitudes of complex data. |
|
1581 */ |
|
1582 |
|
1583 class GEPBALANCE |
|
1584 { |
|
1585 friend class Matrix; |
|
1586 |
|
1587 public: |
238
|
1588 |
21
|
1589 GEPBALANCE (void) {} |
|
1590 |
|
1591 GEPBALANCE (const Matrix& a, const Matrix &, const char *balance_job); |
|
1592 |
|
1593 GEPBALANCE (const GEPBALANCE& a); |
|
1594 |
|
1595 GEPBALANCE& operator = (const GEPBALANCE& a); |
|
1596 Matrix balanced_a_matrix (void) const; |
|
1597 Matrix balanced_b_matrix (void) const; |
|
1598 Matrix left_balancing_matrix (void) const; |
|
1599 Matrix right_balancing_matrix (void) const; |
|
1600 friend ostream& operator << (ostream& os, const GEPBALANCE& a); |
|
1601 |
|
1602 private: |
238
|
1603 |
21
|
1604 int init (const Matrix& a, const Matrix& b, const char * balance_job); |
|
1605 |
|
1606 Matrix balanced_a_mat; |
|
1607 Matrix balanced_b_mat; |
|
1608 Matrix left_balancing_mat; |
|
1609 Matrix right_balancing_mat; |
|
1610 }; |
|
1611 |
|
1612 inline GEPBALANCE::GEPBALANCE (const Matrix& a, const Matrix& b, |
291
|
1613 const char * balance_job) |
21
|
1614 { |
227
|
1615 init (a, b, balance_job); |
21
|
1616 } |
|
1617 |
|
1618 inline GEPBALANCE::GEPBALANCE (const GEPBALANCE& a) |
|
1619 { |
|
1620 balanced_a_mat = a.balanced_a_mat; |
|
1621 balanced_b_mat = a.balanced_b_mat; |
|
1622 left_balancing_mat = a.left_balancing_mat; |
|
1623 right_balancing_mat = a.right_balancing_mat; |
|
1624 } |
|
1625 |
|
1626 inline GEPBALANCE& |
|
1627 GEPBALANCE::operator = (const GEPBALANCE& a) |
|
1628 { |
|
1629 balanced_a_mat = a.balanced_a_mat; |
|
1630 balanced_b_mat = a.balanced_b_mat; |
|
1631 left_balancing_mat = a.left_balancing_mat; |
|
1632 right_balancing_mat = a.right_balancing_mat; |
|
1633 |
|
1634 return *this; |
|
1635 } |
|
1636 |
|
1637 inline Matrix GEPBALANCE::balanced_a_matrix (void) const |
291
|
1638 { |
|
1639 return balanced_a_mat; |
|
1640 } |
21
|
1641 |
|
1642 inline Matrix GEPBALANCE::balanced_b_matrix (void) const |
291
|
1643 { |
|
1644 return balanced_b_mat; |
|
1645 } |
21
|
1646 |
|
1647 inline Matrix GEPBALANCE::left_balancing_matrix (void) const |
291
|
1648 { |
|
1649 return left_balancing_mat; |
|
1650 } |
21
|
1651 |
|
1652 inline Matrix GEPBALANCE::right_balancing_matrix (void) const |
291
|
1653 { |
|
1654 return right_balancing_mat; |
|
1655 } |
21
|
1656 |
|
1657 /* |
182
|
1658 * Result of a Cholesky Factorization |
|
1659 */ |
|
1660 |
|
1661 class CHOL |
|
1662 { |
|
1663 friend class Matrix; |
|
1664 |
|
1665 public: |
238
|
1666 |
182
|
1667 CHOL (void) {} |
|
1668 |
|
1669 CHOL (const Matrix& a); |
|
1670 CHOL (const Matrix& a, int& info); |
|
1671 |
|
1672 CHOL (const CHOL& a); |
|
1673 |
|
1674 CHOL& operator = (const CHOL& a); |
|
1675 Matrix chol_matrix (void) const; |
|
1676 friend ostream& operator << (ostream& os, const CHOL& a); |
|
1677 |
|
1678 private: |
238
|
1679 |
182
|
1680 int init (const Matrix& a); |
|
1681 |
|
1682 Matrix chol_mat; |
|
1683 }; |
|
1684 |
291
|
1685 inline CHOL::CHOL (const Matrix& a) |
|
1686 { |
|
1687 init (a); |
|
1688 } |
|
1689 |
|
1690 inline CHOL::CHOL (const Matrix& a, int& info) |
|
1691 { |
|
1692 info = init (a); |
|
1693 } |
|
1694 |
|
1695 inline CHOL::CHOL (const CHOL& a) |
|
1696 { |
|
1697 chol_mat = a.chol_mat; |
|
1698 } |
182
|
1699 |
|
1700 inline CHOL& |
|
1701 CHOL::operator = (const CHOL& a) |
|
1702 { |
|
1703 chol_mat = a.chol_mat; |
|
1704 |
|
1705 return *this; |
|
1706 } |
|
1707 |
|
1708 inline Matrix CHOL::chol_matrix (void) const { return chol_mat; } |
|
1709 |
|
1710 /* |
|
1711 * Result of a Cholesky Factorization |
|
1712 */ |
|
1713 |
|
1714 class ComplexCHOL |
|
1715 { |
|
1716 friend class ComplexMatrix; |
|
1717 |
|
1718 public: |
238
|
1719 |
182
|
1720 ComplexCHOL (void) {} |
|
1721 ComplexCHOL (const ComplexMatrix& a); |
|
1722 ComplexCHOL (const ComplexMatrix& a, int& info); |
|
1723 ComplexCHOL (const ComplexCHOL& a); |
|
1724 ComplexCHOL& operator = (const ComplexCHOL& a); |
|
1725 ComplexMatrix chol_matrix (void) const; |
|
1726 |
|
1727 friend ostream& operator << (ostream& os, const ComplexCHOL& a); |
|
1728 |
|
1729 private: |
238
|
1730 |
182
|
1731 int init (const ComplexMatrix& a); |
|
1732 |
|
1733 ComplexMatrix chol_mat; |
|
1734 }; |
|
1735 |
291
|
1736 inline ComplexCHOL::ComplexCHOL (const ComplexMatrix& a) |
|
1737 { |
|
1738 init (a); |
|
1739 } |
|
1740 |
182
|
1741 inline ComplexCHOL::ComplexCHOL (const ComplexMatrix& a, int& info) |
291
|
1742 { |
|
1743 info = init (a); |
|
1744 } |
182
|
1745 |
|
1746 inline ComplexCHOL::ComplexCHOL (const ComplexCHOL& a) |
291
|
1747 { |
|
1748 chol_mat = a.chol_mat; |
|
1749 } |
182
|
1750 |
|
1751 inline ComplexCHOL& |
|
1752 ComplexCHOL::operator = (const ComplexCHOL& a) |
|
1753 { |
|
1754 chol_mat = a.chol_mat; |
|
1755 |
|
1756 return *this; |
|
1757 } |
|
1758 |
|
1759 inline ComplexMatrix ComplexCHOL::chol_matrix (void) const |
291
|
1760 { |
|
1761 return chol_mat; |
|
1762 } |
182
|
1763 |
|
1764 |
|
1765 /* |
|
1766 * Result of a Hessenberg Decomposition |
3
|
1767 */ |
|
1768 |
|
1769 class HESS |
|
1770 { |
|
1771 friend class Matrix; |
|
1772 |
|
1773 public: |
238
|
1774 |
3
|
1775 HESS (void) {} |
|
1776 |
|
1777 HESS (const Matrix& a); |
|
1778 HESS (const Matrix&a, int& info); |
|
1779 |
|
1780 HESS (const HESS& a); |
|
1781 |
|
1782 HESS& operator = (const HESS& a); |
|
1783 Matrix hess_matrix (void) const; |
|
1784 Matrix unitary_hess_matrix (void) const; |
|
1785 friend ostream& operator << (ostream& os, const HESS& a); |
|
1786 |
|
1787 private: |
238
|
1788 |
3
|
1789 int init (const Matrix& a); |
|
1790 |
|
1791 Matrix hess_mat; |
|
1792 Matrix unitary_hess_mat; |
|
1793 }; |
|
1794 |
291
|
1795 inline HESS::HESS (const Matrix& a) |
|
1796 { |
|
1797 init (a); |
|
1798 } |
|
1799 |
|
1800 inline HESS::HESS (const Matrix& a, int& info) |
|
1801 { |
|
1802 info = init (a); |
|
1803 } |
182
|
1804 |
3
|
1805 inline HESS::HESS (const HESS& a) |
|
1806 { |
|
1807 hess_mat = a.hess_mat; |
|
1808 unitary_hess_mat = a.unitary_hess_mat; |
|
1809 } |
182
|
1810 |
3
|
1811 inline HESS& |
|
1812 HESS::operator = (const HESS& a) |
|
1813 { |
|
1814 hess_mat = a.hess_mat; |
|
1815 unitary_hess_mat = a.unitary_hess_mat; |
|
1816 |
|
1817 return *this; |
|
1818 } |
182
|
1819 |
291
|
1820 inline Matrix HESS::hess_matrix (void) const |
|
1821 { |
|
1822 return hess_mat; |
|
1823 } |
|
1824 |
|
1825 inline Matrix HESS::unitary_hess_matrix (void) const |
|
1826 { |
|
1827 return unitary_hess_mat; |
|
1828 } |
3
|
1829 |
|
1830 /* |
182
|
1831 * Result of a Hessenberg Decomposition |
3
|
1832 */ |
|
1833 |
|
1834 class ComplexHESS |
|
1835 { |
|
1836 friend class ComplexMatrix; |
|
1837 |
|
1838 public: |
238
|
1839 |
3
|
1840 ComplexHESS (void) {} |
|
1841 ComplexHESS (const ComplexMatrix& a); |
|
1842 ComplexHESS (const ComplexMatrix& a, int& info); |
|
1843 ComplexHESS (const ComplexHESS& a); |
|
1844 ComplexHESS& operator = (const ComplexHESS& a); |
|
1845 ComplexMatrix hess_matrix (void) const; |
|
1846 ComplexMatrix unitary_hess_matrix (void) const; |
|
1847 |
|
1848 friend ostream& operator << (ostream& os, const ComplexHESS& a); |
|
1849 |
|
1850 private: |
238
|
1851 |
3
|
1852 int init (const ComplexMatrix& a); |
|
1853 |
|
1854 ComplexMatrix hess_mat; |
|
1855 ComplexMatrix unitary_hess_mat; |
|
1856 }; |
|
1857 |
291
|
1858 inline ComplexHESS::ComplexHESS (const ComplexMatrix& a) |
|
1859 { |
|
1860 init (a); |
|
1861 } |
|
1862 |
3
|
1863 inline ComplexHESS::ComplexHESS (const ComplexMatrix& a, int& info) |
291
|
1864 { |
|
1865 info = init (a); |
|
1866 } |
3
|
1867 |
|
1868 inline ComplexHESS::ComplexHESS (const ComplexHESS& a) |
|
1869 { |
|
1870 hess_mat = a.hess_mat; |
|
1871 unitary_hess_mat = a.unitary_hess_mat; |
|
1872 } |
|
1873 |
|
1874 inline ComplexHESS& |
|
1875 ComplexHESS::operator = (const ComplexHESS& a) |
|
1876 { |
|
1877 hess_mat = a.hess_mat; |
|
1878 unitary_hess_mat = a.unitary_hess_mat; |
|
1879 |
|
1880 return *this; |
|
1881 } |
|
1882 |
|
1883 inline ComplexMatrix ComplexHESS::hess_matrix (void) const |
291
|
1884 { |
|
1885 return hess_mat; |
|
1886 } |
3
|
1887 |
|
1888 inline ComplexMatrix ComplexHESS::unitary_hess_matrix (void) const |
291
|
1889 { |
|
1890 return unitary_hess_mat; |
|
1891 } |
3
|
1892 |
|
1893 /* |
|
1894 * Result of a Schur Decomposition |
|
1895 */ |
|
1896 |
|
1897 class SCHUR |
|
1898 { |
|
1899 friend class Matrix; |
|
1900 |
|
1901 public: |
238
|
1902 |
3
|
1903 SCHUR (void) {} |
|
1904 |
|
1905 SCHUR (const Matrix& a, const char *ord); |
|
1906 SCHUR (const Matrix& a, const char *ord, int& info); |
|
1907 |
|
1908 SCHUR (const SCHUR& a, const char *ord); |
|
1909 |
238
|
1910 SCHUR& operator = (const SCHUR& a); |
3
|
1911 |
|
1912 Matrix schur_matrix (void) const; |
|
1913 Matrix unitary_matrix (void) const; |
|
1914 |
|
1915 friend ostream& operator << (ostream& os, const SCHUR& a); |
|
1916 |
|
1917 private: |
238
|
1918 |
3
|
1919 int init (const Matrix& a, const char *ord); |
|
1920 |
|
1921 Matrix schur_mat; |
|
1922 Matrix unitary_mat; |
|
1923 }; |
|
1924 |
291
|
1925 inline SCHUR::SCHUR (const Matrix& a, const char *ord) |
|
1926 { |
|
1927 init (a, ord); |
|
1928 } |
|
1929 |
3
|
1930 inline SCHUR::SCHUR (const Matrix& a, const char *ord, int& info) |
291
|
1931 { |
|
1932 info = init (a, ord); |
|
1933 } |
3
|
1934 |
|
1935 inline SCHUR::SCHUR (const SCHUR& a, const char *ord) |
|
1936 { |
|
1937 schur_mat = a.schur_mat; |
|
1938 unitary_mat = a.unitary_mat; |
|
1939 } |
|
1940 |
|
1941 inline SCHUR& |
238
|
1942 SCHUR::operator = (const SCHUR& a) |
3
|
1943 { |
|
1944 schur_mat = a.schur_mat; |
|
1945 unitary_mat = a.unitary_mat; |
|
1946 |
|
1947 return *this; |
|
1948 } |
|
1949 |
291
|
1950 inline Matrix SCHUR::schur_matrix (void) const |
|
1951 { |
|
1952 return schur_mat; |
|
1953 } |
|
1954 |
|
1955 inline Matrix SCHUR::unitary_matrix (void) const |
|
1956 { |
|
1957 return unitary_mat; |
|
1958 } |
3
|
1959 |
|
1960 /* |
|
1961 * Result of a Schur Decomposition |
|
1962 */ |
|
1963 |
|
1964 class ComplexSCHUR |
|
1965 { |
|
1966 friend class ComplexMatrix; |
|
1967 |
|
1968 public: |
238
|
1969 |
3
|
1970 ComplexSCHUR (void) {} |
|
1971 |
|
1972 ComplexSCHUR (const ComplexMatrix& a, const char *ord); |
|
1973 ComplexSCHUR (const ComplexMatrix& a, const char *ord, int& info); |
|
1974 |
|
1975 ComplexSCHUR (const ComplexSCHUR& a, const char *ord); |
|
1976 |
238
|
1977 ComplexSCHUR& operator = (const ComplexSCHUR& a); |
3
|
1978 |
|
1979 ComplexMatrix schur_matrix (void) const; |
|
1980 ComplexMatrix unitary_matrix (void) const; |
|
1981 |
|
1982 friend ostream& operator << (ostream& os, const ComplexSCHUR& a); |
|
1983 |
|
1984 private: |
238
|
1985 |
3
|
1986 int init (const ComplexMatrix& a, const char *ord); |
|
1987 |
|
1988 ComplexMatrix schur_mat; |
|
1989 ComplexMatrix unitary_mat; |
|
1990 }; |
|
1991 |
|
1992 inline ComplexSCHUR::ComplexSCHUR (const ComplexMatrix& a, const char *ord) |
291
|
1993 { |
|
1994 init (a,ord); |
|
1995 } |
3
|
1996 |
|
1997 inline ComplexSCHUR::ComplexSCHUR (const ComplexMatrix& a, const char *ord, |
|
1998 int& info) |
291
|
1999 { |
|
2000 info = init (a,ord); |
|
2001 } |
3
|
2002 |
|
2003 inline ComplexSCHUR::ComplexSCHUR (const ComplexSCHUR& a, const char *ord) |
|
2004 { |
|
2005 schur_mat = a.schur_mat; |
|
2006 unitary_mat = a.unitary_mat; |
|
2007 } |
|
2008 |
|
2009 inline ComplexSCHUR& |
238
|
2010 ComplexSCHUR::operator = (const ComplexSCHUR& a) |
3
|
2011 { |
|
2012 schur_mat = a.schur_mat; |
|
2013 unitary_mat = a.unitary_mat; |
|
2014 |
|
2015 return *this; |
|
2016 } |
182
|
2017 |
3
|
2018 inline ComplexMatrix ComplexSCHUR::schur_matrix (void) const |
291
|
2019 { |
|
2020 return schur_mat; |
|
2021 } |
3
|
2022 |
|
2023 inline ComplexMatrix ComplexSCHUR::unitary_matrix (void) const |
291
|
2024 { |
|
2025 return unitary_mat; |
|
2026 } |
3
|
2027 |
|
2028 |
|
2029 /* |
|
2030 * Result of a Singular Value Decomposition. |
|
2031 */ |
|
2032 |
|
2033 class SVD |
|
2034 { |
|
2035 friend class Matrix; |
|
2036 |
|
2037 public: |
238
|
2038 |
3
|
2039 SVD (void) {} |
|
2040 |
|
2041 SVD (const Matrix& a); |
|
2042 SVD (const Matrix& a, int& info); |
|
2043 |
|
2044 SVD (const SVD& a); |
|
2045 |
|
2046 SVD& operator = (const SVD& a); |
|
2047 |
|
2048 DiagMatrix singular_values (void) const; |
|
2049 Matrix left_singular_matrix (void) const; |
|
2050 Matrix right_singular_matrix (void) const; |
|
2051 |
|
2052 friend ostream& operator << (ostream& os, const SVD& a); |
|
2053 |
|
2054 private: |
238
|
2055 |
3
|
2056 int init (const Matrix& a); |
|
2057 |
|
2058 DiagMatrix sigma; |
|
2059 Matrix left_sm; |
|
2060 Matrix right_sm; |
|
2061 }; |
|
2062 |
291
|
2063 inline SVD::SVD (const Matrix& a) |
|
2064 { |
|
2065 init (a); |
|
2066 } |
|
2067 |
|
2068 inline SVD::SVD (const Matrix& a, int& info) |
|
2069 { |
|
2070 info = init (a); |
|
2071 } |
3
|
2072 |
|
2073 inline SVD::SVD (const SVD& a) |
|
2074 { |
|
2075 sigma = a.sigma; |
|
2076 left_sm = a.left_sm; |
|
2077 right_sm = a.right_sm; |
|
2078 } |
|
2079 |
|
2080 inline SVD& |
|
2081 SVD::operator = (const SVD& a) |
|
2082 { |
|
2083 sigma = a.sigma; |
|
2084 left_sm = a.left_sm; |
|
2085 right_sm = a.right_sm; |
|
2086 |
|
2087 return *this; |
|
2088 } |
|
2089 |
291
|
2090 inline DiagMatrix SVD::singular_values (void) const |
|
2091 { |
|
2092 return sigma; |
|
2093 } |
|
2094 |
|
2095 inline Matrix SVD::left_singular_matrix (void) const |
|
2096 { |
|
2097 return left_sm; |
|
2098 } |
|
2099 |
|
2100 inline Matrix SVD::right_singular_matrix (void) const |
|
2101 { |
|
2102 return right_sm; |
|
2103 } |
3
|
2104 |
|
2105 /* |
|
2106 * Result of a Singular Value Decomposition. |
|
2107 */ |
|
2108 |
|
2109 class ComplexSVD |
|
2110 { |
|
2111 friend class ComplexMatrix; |
|
2112 |
|
2113 public: |
238
|
2114 |
3
|
2115 ComplexSVD (void) {} |
|
2116 |
|
2117 ComplexSVD (const ComplexMatrix& a); |
|
2118 ComplexSVD (const ComplexMatrix& a, int& info); |
|
2119 |
|
2120 ComplexSVD (const ComplexSVD& a); |
|
2121 |
|
2122 ComplexSVD& operator = (const ComplexSVD& a); |
|
2123 |
|
2124 DiagMatrix singular_values (void) const; |
|
2125 ComplexMatrix left_singular_matrix (void) const; |
|
2126 ComplexMatrix right_singular_matrix (void) const; |
|
2127 |
|
2128 friend ostream& operator << (ostream& os, const ComplexSVD& a); |
|
2129 |
|
2130 private: |
238
|
2131 |
3
|
2132 int init (const ComplexMatrix& a); |
|
2133 |
|
2134 DiagMatrix sigma; |
|
2135 ComplexMatrix left_sm; |
|
2136 ComplexMatrix right_sm; |
|
2137 }; |
|
2138 |
291
|
2139 inline ComplexSVD::ComplexSVD (const ComplexMatrix& a) |
|
2140 { |
|
2141 init (a); |
|
2142 } |
|
2143 |
3
|
2144 inline ComplexSVD::ComplexSVD (const ComplexMatrix& a, int& info) |
291
|
2145 { |
|
2146 info = init (a); |
|
2147 } |
3
|
2148 |
|
2149 inline ComplexSVD::ComplexSVD (const ComplexSVD& a) |
|
2150 { |
|
2151 sigma = a.sigma; |
|
2152 left_sm = a.left_sm; |
|
2153 right_sm = a.right_sm; |
|
2154 } |
|
2155 |
|
2156 inline ComplexSVD& |
|
2157 ComplexSVD::operator = (const ComplexSVD& a) |
|
2158 { |
|
2159 sigma = a.sigma; |
|
2160 left_sm = a.left_sm; |
|
2161 right_sm = a.right_sm; |
|
2162 |
|
2163 return *this; |
|
2164 } |
|
2165 |
|
2166 inline DiagMatrix ComplexSVD::singular_values (void) const |
291
|
2167 { |
|
2168 return sigma; |
|
2169 } |
3
|
2170 |
|
2171 inline ComplexMatrix ComplexSVD::left_singular_matrix (void) const |
291
|
2172 { |
|
2173 return left_sm; |
|
2174 } |
3
|
2175 |
|
2176 inline ComplexMatrix ComplexSVD::right_singular_matrix (void) const |
291
|
2177 { |
|
2178 return right_sm; |
|
2179 } |
3
|
2180 |
|
2181 /* |
|
2182 * Result of an Eigenvalue computation. |
|
2183 */ |
|
2184 |
|
2185 class EIG |
|
2186 { |
|
2187 friend class Matrix; |
|
2188 friend class ComplexMatrix; |
|
2189 |
|
2190 public: |
238
|
2191 |
3
|
2192 EIG (void) {} |
|
2193 |
|
2194 EIG (const Matrix& a); |
|
2195 EIG (const Matrix& a, int& info); |
|
2196 |
|
2197 EIG (const ComplexMatrix& a); |
|
2198 EIG (const ComplexMatrix& a, int& info); |
|
2199 |
|
2200 EIG (const EIG& a); |
|
2201 |
|
2202 EIG& operator = (const EIG& a); |
|
2203 |
|
2204 ComplexColumnVector eigenvalues (void) const; |
|
2205 ComplexMatrix eigenvectors (void) const; |
|
2206 |
|
2207 friend ostream& operator << (ostream& os, const EIG& a); |
|
2208 |
|
2209 private: |
238
|
2210 |
3
|
2211 int init (const Matrix& a); |
|
2212 int init (const ComplexMatrix& a); |
|
2213 |
|
2214 ComplexColumnVector lambda; |
|
2215 ComplexMatrix v; |
|
2216 }; |
|
2217 |
291
|
2218 inline EIG::EIG (const Matrix& a) |
|
2219 { |
|
2220 init (a); |
|
2221 } |
|
2222 |
|
2223 inline EIG::EIG (const Matrix& a, int& info) |
|
2224 { |
|
2225 info = init (a); |
|
2226 } |
|
2227 |
|
2228 inline EIG::EIG (const ComplexMatrix& a) |
|
2229 { |
|
2230 init (a); |
|
2231 } |
|
2232 |
|
2233 inline EIG::EIG (const ComplexMatrix& a, int& info) |
|
2234 { |
|
2235 info = init (a); |
|
2236 } |
|
2237 |
|
2238 inline EIG::EIG (const EIG& a) |
|
2239 { |
|
2240 lambda = a.lambda; |
|
2241 v = a.v; |
|
2242 } |
3
|
2243 |
|
2244 inline EIG& EIG::operator = (const EIG& a) |
291
|
2245 { |
|
2246 lambda = a.lambda; |
|
2247 v = a.v; |
|
2248 return *this; |
|
2249 } |
|
2250 |
|
2251 inline ComplexColumnVector EIG::eigenvalues (void) const |
|
2252 { |
|
2253 return lambda; |
|
2254 } |
|
2255 |
|
2256 inline ComplexMatrix EIG::eigenvectors (void) const |
|
2257 { |
|
2258 return v; |
|
2259 } |
3
|
2260 |
|
2261 /* |
|
2262 * Result of an LU decomposition. |
|
2263 */ |
|
2264 |
|
2265 class LU |
|
2266 { |
|
2267 friend class Matrix; |
|
2268 |
|
2269 public: |
238
|
2270 |
3
|
2271 LU (void) {} |
|
2272 |
|
2273 LU (const Matrix& a); |
|
2274 |
|
2275 LU (const LU& a); |
|
2276 |
|
2277 LU& operator = (const LU& a); |
|
2278 |
|
2279 Matrix L (void) const; |
|
2280 Matrix U (void) const; |
|
2281 Matrix P (void) const; |
|
2282 |
|
2283 friend ostream& operator << (ostream& os, const LU& a); |
|
2284 |
|
2285 private: |
|
2286 |
|
2287 Matrix l; |
|
2288 Matrix u; |
|
2289 Matrix p; |
|
2290 }; |
|
2291 |
291
|
2292 inline LU::LU (const LU& a) |
|
2293 { |
|
2294 l = a.l; |
|
2295 u = a.u; |
|
2296 p = a.p; |
|
2297 } |
3
|
2298 |
|
2299 inline LU& LU::operator = (const LU& a) |
291
|
2300 { |
|
2301 l = a.l; |
|
2302 u = a.u; |
|
2303 p = a.p; |
|
2304 return *this; |
|
2305 } |
|
2306 |
|
2307 inline Matrix LU::L (void) const |
|
2308 { |
|
2309 return l; |
|
2310 } |
|
2311 |
|
2312 inline Matrix LU::U (void) const |
|
2313 { |
|
2314 return u; |
|
2315 } |
|
2316 |
|
2317 inline Matrix LU::P (void) const |
|
2318 { |
|
2319 return p; |
|
2320 } |
3
|
2321 |
|
2322 class ComplexLU |
|
2323 { |
|
2324 friend class ComplexMatrix; |
|
2325 |
|
2326 public: |
238
|
2327 |
3
|
2328 ComplexLU (void) {} |
|
2329 |
|
2330 ComplexLU (const ComplexMatrix& a); |
|
2331 |
|
2332 ComplexLU (const ComplexLU& a); |
|
2333 |
|
2334 ComplexLU& operator = (const ComplexLU& a); |
|
2335 |
|
2336 ComplexMatrix L (void) const; |
|
2337 ComplexMatrix U (void) const; |
|
2338 Matrix P (void) const; |
|
2339 |
|
2340 friend ostream& operator << (ostream& os, const ComplexLU& a); |
|
2341 |
|
2342 private: |
|
2343 |
|
2344 ComplexMatrix l; |
|
2345 ComplexMatrix u; |
|
2346 Matrix p; |
|
2347 }; |
|
2348 |
291
|
2349 inline ComplexLU::ComplexLU (const ComplexLU& a) |
|
2350 { |
|
2351 l = a.l; |
|
2352 u = a.u; |
|
2353 p = a.p; |
|
2354 } |
3
|
2355 |
|
2356 inline ComplexLU& ComplexLU::operator = (const ComplexLU& a) |
291
|
2357 { |
|
2358 l = a.l; |
|
2359 u = a.u; |
|
2360 p = a.p; |
|
2361 return *this; |
|
2362 } |
|
2363 |
|
2364 inline ComplexMatrix ComplexLU::L (void) const |
|
2365 { |
|
2366 return l; |
|
2367 } |
|
2368 |
|
2369 inline ComplexMatrix ComplexLU::U (void) const |
|
2370 { |
|
2371 return u; |
|
2372 } |
|
2373 |
|
2374 inline Matrix ComplexLU::P (void) const |
|
2375 { |
|
2376 return p; |
|
2377 } |
3
|
2378 |
|
2379 /* |
|
2380 * Result of a QR decomposition. |
|
2381 */ |
|
2382 |
|
2383 class QR |
|
2384 { |
|
2385 public: |
238
|
2386 |
3
|
2387 QR (void) {} |
|
2388 |
|
2389 QR (const Matrix& A); |
|
2390 |
|
2391 QR (const QR& a); |
|
2392 |
|
2393 QR& operator = (const QR& a); |
|
2394 |
|
2395 Matrix Q (void) const; |
|
2396 Matrix R (void) const; |
|
2397 |
|
2398 friend ostream& operator << (ostream& os, const QR& a); |
|
2399 |
|
2400 private: |
238
|
2401 |
3
|
2402 Matrix q; |
|
2403 Matrix r; |
|
2404 }; |
|
2405 |
291
|
2406 inline QR::QR (const QR& a) |
|
2407 { |
|
2408 q = a.q; |
|
2409 r = a.r; |
|
2410 } |
|
2411 |
|
2412 inline QR& QR::operator = (const QR& a) |
|
2413 { |
|
2414 q = a.q; |
|
2415 r = a.r; |
|
2416 return *this; |
|
2417 } |
|
2418 |
|
2419 inline Matrix QR::Q (void) const |
|
2420 { |
|
2421 return q; |
|
2422 } |
|
2423 |
|
2424 inline Matrix QR::R (void) const |
|
2425 { |
|
2426 return r; |
|
2427 } |
3
|
2428 |
|
2429 class ComplexQR |
|
2430 { |
|
2431 public: |
238
|
2432 |
3
|
2433 ComplexQR (void) {} |
|
2434 |
|
2435 ComplexQR (const ComplexMatrix& A); |
|
2436 |
|
2437 ComplexQR (const ComplexQR& a); |
|
2438 |
|
2439 ComplexQR& operator = (const ComplexQR& a); |
|
2440 |
|
2441 ComplexMatrix Q (void) const; |
|
2442 ComplexMatrix R (void) const; |
|
2443 |
|
2444 friend ostream& operator << (ostream& os, const ComplexQR& a); |
|
2445 |
|
2446 private: |
238
|
2447 |
3
|
2448 ComplexMatrix q; |
|
2449 ComplexMatrix r; |
|
2450 }; |
|
2451 |
291
|
2452 inline ComplexQR::ComplexQR (const ComplexQR& a) |
|
2453 { |
|
2454 q = a.q; |
|
2455 r = a.r; |
|
2456 } |
3
|
2457 |
|
2458 inline ComplexQR& ComplexQR::operator = (const ComplexQR& a) |
291
|
2459 { |
|
2460 q = a.q; |
|
2461 r = a.r; |
|
2462 return *this; |
|
2463 } |
|
2464 |
|
2465 inline ComplexMatrix ComplexQR::Q (void) const |
|
2466 { |
|
2467 return q; |
|
2468 } |
|
2469 |
|
2470 inline ComplexMatrix ComplexQR::R (void) const |
|
2471 { |
|
2472 return r; |
|
2473 } |
3
|
2474 |
382
|
2475 } // extern "C++" |
|
2476 |
3
|
2477 #endif |
|
2478 |
|
2479 /* |
|
2480 ;;; Local Variables: *** |
|
2481 ;;; mode: C++ *** |
|
2482 ;;; page-delimiter: "^/\\*" *** |
|
2483 ;;; End: *** |
|
2484 */ |