458
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
458
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_DiagMatrix_h) |
|
25 #define octave_DiagMatrix_h 1 |
|
26 |
1296
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
1214
|
31 #include "MArray.h" |
458
|
32 |
|
33 #include "dRowVector.h" |
|
34 #include "dColVector.h" |
|
35 |
|
36 #include "mx-defs.h" |
|
37 |
1214
|
38 class DiagMatrix : public MDiagArray<double> |
458
|
39 { |
|
40 friend class SVD; |
|
41 friend class ComplexSVD; |
|
42 |
|
43 public: |
|
44 |
1214
|
45 DiagMatrix (void) : MDiagArray<double> () { } |
|
46 DiagMatrix (int n) : MDiagArray<double> (n) { } |
1574
|
47 DiagMatrix (int n, double val) : MDiagArray<double> (n, n, val) { } |
1214
|
48 DiagMatrix (int r, int c) : MDiagArray<double> (r, c) { } |
|
49 DiagMatrix (int r, int c, double val) : MDiagArray<double> (r, c, val) { } |
|
50 DiagMatrix (const RowVector& a) : MDiagArray<double> (a) { } |
|
51 DiagMatrix (const ColumnVector& a) : MDiagArray<double> (a) { } |
|
52 DiagMatrix (const MDiagArray<double>& a) : MDiagArray<double> (a) { } |
|
53 DiagMatrix (const DiagMatrix& a) : MDiagArray<double> (a) { } |
|
54 // DiagMatrix (double a) : MDiagArray<double> (1, a) { } |
458
|
55 |
|
56 DiagMatrix& operator = (const DiagMatrix& a) |
|
57 { |
1214
|
58 MDiagArray<double>::operator = (a); |
458
|
59 return *this; |
|
60 } |
|
61 |
|
62 int operator == (const DiagMatrix& a) const; |
|
63 int operator != (const DiagMatrix& a) const; |
|
64 |
|
65 DiagMatrix& fill (double val); |
|
66 DiagMatrix& fill (double val, int beg, int end); |
|
67 DiagMatrix& fill (const ColumnVector& a); |
|
68 DiagMatrix& fill (const RowVector& a); |
|
69 DiagMatrix& fill (const ColumnVector& a, int beg); |
|
70 DiagMatrix& fill (const RowVector& a, int beg); |
|
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 |
|
79 Matrix extract (int r1, int c1, int r2, int c2) const; |
|
80 |
1359
|
81 // extract row or column i. |
458
|
82 |
|
83 RowVector row (int i) const; |
|
84 RowVector row (char *s) const; |
|
85 |
|
86 ColumnVector column (int i) const; |
|
87 ColumnVector column (char *s) const; |
|
88 |
|
89 DiagMatrix inverse (void) const; |
|
90 DiagMatrix inverse (int& info) const; |
|
91 |
1359
|
92 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
458
|
93 |
|
94 DiagMatrix& operator += (const DiagMatrix& a); |
|
95 DiagMatrix& operator -= (const DiagMatrix& a); |
|
96 |
1359
|
97 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
458
|
98 |
|
99 friend DiagMatrix operator * (const DiagMatrix& a, |
|
100 const DiagMatrix& b); |
|
101 |
1359
|
102 // other operations |
458
|
103 |
|
104 ColumnVector diag (void) const; |
|
105 ColumnVector diag (int k) const; |
|
106 |
1359
|
107 // i/o |
458
|
108 |
|
109 friend ostream& operator << (ostream& os, const DiagMatrix& a); |
|
110 |
|
111 private: |
|
112 |
1214
|
113 DiagMatrix (double *d, int nr, int nc) : MDiagArray<double> (d, nr, nc) { } |
458
|
114 }; |
|
115 |
|
116 #endif |
|
117 |
|
118 /* |
|
119 ;;; Local Variables: *** |
|
120 ;;; mode: C++ *** |
|
121 ;;; page-delimiter: "^/\\*" *** |
|
122 ;;; End: *** |
|
123 */ |