Mercurial > hg > octave-nkf
annotate liboctave/dDiagMatrix.h @ 11542:695141f1c05c ss-3-3-55
snapshot 3.3.55
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 15 Jan 2011 04:53:04 -0500 |
parents | fd0a3ac60b0e |
children | 12df7854fa7c |
rev | line source |
---|---|
458 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1994-2011 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
458 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
458 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_DiagMatrix_h) | |
24 #define octave_DiagMatrix_h 1 | |
25 | |
1989 | 26 #include "MDiagArray2.h" |
458 | 27 |
28 #include "dRowVector.h" | |
29 #include "dColVector.h" | |
8371
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
30 #include "DET.h" |
458 | 31 |
32 #include "mx-defs.h" | |
33 | |
3585 | 34 class |
6108 | 35 OCTAVE_API |
3585 | 36 DiagMatrix : public MDiagArray2<double> |
458 | 37 { |
38 friend class SVD; | |
39 friend class ComplexSVD; | |
40 | |
41 public: | |
42 | |
1989 | 43 DiagMatrix (void) : MDiagArray2<double> () { } |
3585 | 44 |
5275 | 45 DiagMatrix (octave_idx_type r, octave_idx_type c) : MDiagArray2<double> (r, c) { } |
3585 | 46 |
5275 | 47 DiagMatrix (octave_idx_type r, octave_idx_type c, double val) : MDiagArray2<double> (r, c, val) { } |
3585 | 48 |
49 DiagMatrix (const DiagMatrix& a) : MDiagArray2<double> (a) { } | |
50 | |
1989 | 51 DiagMatrix (const MDiagArray2<double>& a) : MDiagArray2<double> (a) { } |
3585 | 52 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
53 template <class U> |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
54 DiagMatrix (const DiagArray2<U>& a) : MDiagArray2<double> (a) { } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
55 |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
56 explicit DiagMatrix (const Array<double>& a) : MDiagArray2<double> (a) { } |
3585 | 57 |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
58 DiagMatrix (const Array<double>& a, octave_idx_type r, octave_idx_type c) |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
59 : MDiagArray2<double> (a, r, c) { } |
458 | 60 |
61 DiagMatrix& operator = (const DiagMatrix& a) | |
62 { | |
1989 | 63 MDiagArray2<double>::operator = (a); |
458 | 64 return *this; |
65 } | |
66 | |
2385 | 67 bool operator == (const DiagMatrix& a) const; |
68 bool operator != (const DiagMatrix& a) const; | |
458 | 69 |
70 DiagMatrix& fill (double val); | |
5275 | 71 DiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end); |
458 | 72 DiagMatrix& fill (const ColumnVector& a); |
73 DiagMatrix& fill (const RowVector& a); | |
5275 | 74 DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg); |
75 DiagMatrix& fill (const RowVector& a, octave_idx_type beg); | |
458 | 76 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
77 DiagMatrix transpose (void) const { return MDiagArray2<double>::transpose(); } |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
78 DiagMatrix abs (void) const; |
458 | 79 |
6153 | 80 friend OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a); |
81 friend OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a); | |
1205 | 82 |
1359 | 83 // resize is the destructive analog for this one |
458 | 84 |
5275 | 85 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458 | 86 |
1359 | 87 // extract row or column i. |
458 | 88 |
5275 | 89 RowVector row (octave_idx_type i) const; |
458 | 90 RowVector row (char *s) const; |
91 | |
5275 | 92 ColumnVector column (octave_idx_type i) const; |
458 | 93 ColumnVector column (char *s) const; |
94 | |
95 DiagMatrix inverse (void) const; | |
8811 | 96 DiagMatrix inverse (octave_idx_type& info) const; |
8840
c690e3772583
support diagonal matrices in pinv
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
97 DiagMatrix pseudo_inverse (void) const; |
458 | 98 |
1359 | 99 // other operations |
458 | 100 |
8375
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8371
diff
changeset
|
101 ColumnVector diag (octave_idx_type k = 0) const |
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8371
diff
changeset
|
102 { return MDiagArray2<double>::diag (k); } |
458 | 103 |
8371
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
104 DET determinant (void) const; |
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
105 double rcond (void) const; |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
106 |
1359 | 107 // i/o |
458 | 108 |
6153 | 109 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const DiagMatrix& a); |
458 | 110 |
111 }; | |
112 | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
113 OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
114 OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
115 |
3504 | 116 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
117 | |
9237
3c1762c7e787
Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
118 OCTAVE_API DiagMatrix |
3504 | 119 operator * (const DiagMatrix& a, const DiagMatrix& b); |
120 | |
3580 | 121 MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, DiagMatrix, double) |
122 | |
458 | 123 #endif |