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