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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
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" |
|
30 |
|
31 #include "mx-defs.h" |
|
32 |
3585
|
33 class |
|
34 DiagMatrix : public MDiagArray2<double> |
458
|
35 { |
|
36 friend class SVD; |
|
37 friend class ComplexSVD; |
|
38 |
|
39 public: |
|
40 |
1989
|
41 DiagMatrix (void) : MDiagArray2<double> () { } |
3585
|
42 |
5275
|
43 DiagMatrix (octave_idx_type r, octave_idx_type c) : MDiagArray2<double> (r, c) { } |
3585
|
44 |
5275
|
45 DiagMatrix (octave_idx_type r, octave_idx_type c, double val) : MDiagArray2<double> (r, c, val) { } |
3585
|
46 |
|
47 DiagMatrix (const DiagMatrix& a) : MDiagArray2<double> (a) { } |
|
48 |
1989
|
49 DiagMatrix (const MDiagArray2<double>& a) : MDiagArray2<double> (a) { } |
3585
|
50 |
|
51 explicit DiagMatrix (const RowVector& a) : MDiagArray2<double> (a) { } |
|
52 |
|
53 explicit DiagMatrix (const ColumnVector& a) : MDiagArray2<double> (a) { } |
458
|
54 |
|
55 DiagMatrix& operator = (const DiagMatrix& a) |
|
56 { |
1989
|
57 MDiagArray2<double>::operator = (a); |
458
|
58 return *this; |
|
59 } |
|
60 |
2385
|
61 bool operator == (const DiagMatrix& a) const; |
|
62 bool operator != (const DiagMatrix& a) const; |
458
|
63 |
|
64 DiagMatrix& fill (double val); |
5275
|
65 DiagMatrix& fill (double val, octave_idx_type beg, octave_idx_type end); |
458
|
66 DiagMatrix& fill (const ColumnVector& a); |
|
67 DiagMatrix& fill (const RowVector& a); |
5275
|
68 DiagMatrix& fill (const ColumnVector& a, octave_idx_type beg); |
|
69 DiagMatrix& fill (const RowVector& a, octave_idx_type beg); |
458
|
70 |
|
71 DiagMatrix transpose (void) const; |
|
72 |
1205
|
73 friend DiagMatrix real (const ComplexDiagMatrix& a); |
|
74 friend DiagMatrix imag (const ComplexDiagMatrix& a); |
|
75 |
1359
|
76 // resize is the destructive analog for this one |
458
|
77 |
5275
|
78 Matrix extract (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const; |
458
|
79 |
1359
|
80 // extract row or column i. |
458
|
81 |
5275
|
82 RowVector row (octave_idx_type i) const; |
458
|
83 RowVector row (char *s) const; |
|
84 |
5275
|
85 ColumnVector column (octave_idx_type i) const; |
458
|
86 ColumnVector column (char *s) const; |
|
87 |
|
88 DiagMatrix inverse (void) const; |
|
89 DiagMatrix inverse (int& info) const; |
|
90 |
1359
|
91 // other operations |
458
|
92 |
|
93 ColumnVector diag (void) const; |
5275
|
94 ColumnVector diag (octave_idx_type k) const; |
458
|
95 |
1359
|
96 // i/o |
458
|
97 |
3504
|
98 friend std::ostream& operator << (std::ostream& os, const DiagMatrix& a); |
458
|
99 |
|
100 private: |
|
101 |
5275
|
102 DiagMatrix (double *d, octave_idx_type nr, octave_idx_type nc) : MDiagArray2<double> (d, nr, nc) { } |
458
|
103 }; |
|
104 |
3504
|
105 // diagonal matrix by diagonal matrix -> diagonal matrix operations |
|
106 |
|
107 DiagMatrix |
|
108 operator * (const DiagMatrix& a, const DiagMatrix& b); |
|
109 |
3580
|
110 MDIAGARRAY2_FORWARD_DEFS (MDiagArray2, DiagMatrix, double) |
|
111 |
458
|
112 #endif |
|
113 |
|
114 /* |
|
115 ;;; Local Variables: *** |
|
116 ;;; mode: C++ *** |
|
117 ;;; End: *** |
|
118 */ |