458
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
458
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
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 |
|
35 DiagMatrix : public MDiagArray2<double> |
458
|
36 { |
|
37 friend class SVD; |
|
38 friend class ComplexSVD; |
|
39 |
|
40 public: |
|
41 |
1989
|
42 DiagMatrix (void) : MDiagArray2<double> () { } |
3585
|
43 |
5275
|
44 DiagMatrix (octave_idx_type r, octave_idx_type c) : MDiagArray2<double> (r, c) { } |
3585
|
45 |
5275
|
46 DiagMatrix (octave_idx_type r, octave_idx_type c, double val) : MDiagArray2<double> (r, c, val) { } |
3585
|
47 |
|
48 DiagMatrix (const DiagMatrix& a) : MDiagArray2<double> (a) { } |
|
49 |
1989
|
50 DiagMatrix (const MDiagArray2<double>& a) : MDiagArray2<double> (a) { } |
3585
|
51 |
|
52 explicit DiagMatrix (const RowVector& a) : MDiagArray2<double> (a) { } |
|
53 |
|
54 explicit DiagMatrix (const ColumnVector& a) : MDiagArray2<double> (a) { } |
458
|
55 |
|
56 DiagMatrix& operator = (const DiagMatrix& a) |
|
57 { |
1989
|
58 MDiagArray2<double>::operator = (a); |
458
|
59 return *this; |
|
60 } |
|
61 |
2385
|
62 bool operator == (const DiagMatrix& a) const; |
|
63 bool operator != (const DiagMatrix& a) const; |
458
|
64 |
|
65 DiagMatrix& fill (double val); |
5275
|
66 DiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end); |
458
|
67 DiagMatrix& fill (const ColumnVector& a); |
|
68 DiagMatrix& fill (const RowVector& a); |
5275
|
69 DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg); |
|
70 DiagMatrix& fill (const RowVector& a, octave_idx_type beg); |
458
|
71 |
|
72 DiagMatrix transpose (void) const; |
|
73 |
1205
|
74 friend DiagMatrix real (const ComplexDiagMatrix& a); |
|
75 friend DiagMatrix imag (const ComplexDiagMatrix& a); |
|
76 |
1359
|
77 // resize is the destructive analog for this one |
458
|
78 |
5275
|
79 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458
|
80 |
1359
|
81 // extract row or column i. |
458
|
82 |
5275
|
83 RowVector row (octave_idx_type i) const; |
458
|
84 RowVector row (char *s) const; |
|
85 |
5275
|
86 ColumnVector column (octave_idx_type i) const; |
458
|
87 ColumnVector column (char *s) const; |
|
88 |
|
89 DiagMatrix inverse (void) const; |
|
90 DiagMatrix inverse (int& info) const; |
|
91 |
1359
|
92 // other operations |
458
|
93 |
|
94 ColumnVector diag (void) const; |
5275
|
95 ColumnVector diag (octave_idx_type k) const; |
458
|
96 |
1359
|
97 // i/o |
458
|
98 |
3504
|
99 friend std::ostream& operator << (std::ostream& os, const DiagMatrix& a); |
458
|
100 |
|
101 private: |
|
102 |
5275
|
103 DiagMatrix (double *d, octave_idx_type nr, octave_idx_type nc) : MDiagArray2<double> (d, nr, nc) { } |
458
|
104 }; |
|
105 |
3504
|
106 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
107 |
|
108 DiagMatrix |
|
109 operator * (const DiagMatrix& a, const DiagMatrix& b); |
|
110 |
3580
|
111 MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, DiagMatrix, double) |
|
112 |
458
|
113 #endif |
|
114 |
|
115 /* |
|
116 ;;; Local Variables: *** |
|
117 ;;; mode: C++ *** |
|
118 ;;; End: *** |
|
119 */ |