Mercurial > hg > octave-lyh
annotate liboctave/dDiagMatrix.h @ 8367:445d27d79f4e
support permutation matrix objects
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 08:31:56 +0100 |
parents | 8b1a2555c4e2 |
children | c3f7e2549abb |
rev | line source |
---|---|
458 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, 2006, |
4 2007 John W. Eaton | |
458 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
458 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
458 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_DiagMatrix_h) | |
25 #define octave_DiagMatrix_h 1 | |
26 | |
1989 | 27 #include "MDiagArray2.h" |
458 | 28 |
29 #include "dRowVector.h" | |
30 #include "dColVector.h" | |
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 |
3585 | 56 explicit DiagMatrix (const RowVector& a) : MDiagArray2<double> (a) { } |
57 | |
58 explicit DiagMatrix (const ColumnVector& a) : MDiagArray2<double> (a) { } | |
458 | 59 |
60 DiagMatrix& operator = (const DiagMatrix& a) | |
61 { | |
1989 | 62 MDiagArray2<double>::operator = (a); |
458 | 63 return *this; |
64 } | |
65 | |
2385 | 66 bool operator == (const DiagMatrix& a) const; |
67 bool operator != (const DiagMatrix& a) const; | |
458 | 68 |
69 DiagMatrix& fill (double val); | |
5275 | 70 DiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end); |
458 | 71 DiagMatrix& fill (const ColumnVector& a); |
72 DiagMatrix& fill (const RowVector& a); | |
5275 | 73 DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg); |
74 DiagMatrix& fill (const RowVector& a, octave_idx_type beg); | |
458 | 75 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7620
diff
changeset
|
76 DiagMatrix transpose (void) const { return MDiagArray2<double>::transpose(); } |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
77 DiagMatrix abs (void) const; |
458 | 78 |
6153 | 79 friend OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a); |
80 friend OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a); | |
1205 | 81 |
1359 | 82 // resize is the destructive analog for this one |
458 | 83 |
5275 | 84 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458 | 85 |
1359 | 86 // extract row or column i. |
458 | 87 |
5275 | 88 RowVector row (octave_idx_type i) const; |
458 | 89 RowVector row (char *s) const; |
90 | |
5275 | 91 ColumnVector column (octave_idx_type i) const; |
458 | 92 ColumnVector column (char *s) const; |
93 | |
94 DiagMatrix inverse (void) const; | |
95 DiagMatrix inverse (int& info) const; | |
96 | |
1359 | 97 // other operations |
458 | 98 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
99 ColumnVector diag (octave_idx_type k = 0) const; |
458 | 100 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
101 bool is_identity (void) const; |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
102 |
1359 | 103 // i/o |
458 | 104 |
6153 | 105 friend OCTAVE_API std::ostream& operator << (std::ostream& os, const DiagMatrix& a); |
458 | 106 |
107 private: | |
108 | |
5275 | 109 DiagMatrix (double *d, octave_idx_type nr, octave_idx_type nc) : MDiagArray2<double> (d, nr, nc) { } |
458 | 110 }; |
111 | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
112 OCTAVE_API DiagMatrix real (const ComplexDiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
113 OCTAVE_API DiagMatrix imag (const ComplexDiagMatrix& a); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
114 |
3504 | 115 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
116 | |
117 DiagMatrix | |
118 operator * (const DiagMatrix& a, const DiagMatrix& b); | |
119 | |
3580 | 120 MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, DiagMatrix, double) |
121 | |
458 | 122 #endif |
123 | |
124 /* | |
125 ;;; Local Variables: *** | |
126 ;;; mode: C++ *** | |
127 ;;; End: *** | |
128 */ |