457
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
457
|
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_SVD_h) |
|
25 #define octave_SVD_h 1 |
|
26 |
|
27 class ostream; |
|
28 |
|
29 #include "dDiagMatrix.h" |
|
30 #include "dMatrix.h" |
|
31 |
|
32 extern "C++" { |
|
33 |
|
34 class SVD |
|
35 { |
|
36 friend class Matrix; |
|
37 |
|
38 public: |
|
39 |
537
|
40 enum type |
|
41 { |
|
42 std, |
|
43 economy, |
|
44 }; |
|
45 |
457
|
46 SVD (void) {} |
|
47 |
537
|
48 SVD (const Matrix& a, SVD::type svd_type = SVD::std); |
|
49 SVD (const Matrix& a, int& info, SVD::type svd_type = SVD::std); |
457
|
50 |
|
51 SVD (const SVD& a); |
|
52 |
|
53 SVD& operator = (const SVD& a); |
|
54 |
|
55 DiagMatrix singular_values (void) const; |
|
56 Matrix left_singular_matrix (void) const; |
|
57 Matrix right_singular_matrix (void) const; |
|
58 |
|
59 friend ostream& operator << (ostream& os, const SVD& a); |
|
60 |
|
61 private: |
|
62 |
537
|
63 int init (const Matrix& a, SVD::type svd_type = SVD::std); |
457
|
64 |
|
65 DiagMatrix sigma; |
|
66 Matrix left_sm; |
|
67 Matrix right_sm; |
|
68 }; |
|
69 |
537
|
70 inline SVD::SVD (const Matrix& a, SVD::type svd_type) |
457
|
71 { |
537
|
72 init (a, svd_type); |
457
|
73 } |
|
74 |
537
|
75 inline SVD::SVD (const Matrix& a, int& info, SVD::type svd_type) |
457
|
76 { |
537
|
77 info = init (a, svd_type); |
457
|
78 } |
|
79 |
|
80 inline SVD::SVD (const SVD& a) |
|
81 { |
|
82 sigma = a.sigma; |
|
83 left_sm = a.left_sm; |
|
84 right_sm = a.right_sm; |
|
85 } |
|
86 |
|
87 inline SVD& |
|
88 SVD::operator = (const SVD& a) |
|
89 { |
|
90 sigma = a.sigma; |
|
91 left_sm = a.left_sm; |
|
92 right_sm = a.right_sm; |
|
93 |
|
94 return *this; |
|
95 } |
|
96 |
|
97 inline DiagMatrix SVD::singular_values (void) const |
|
98 { |
|
99 return sigma; |
|
100 } |
|
101 |
|
102 inline Matrix SVD::left_singular_matrix (void) const |
|
103 { |
|
104 return left_sm; |
|
105 } |
|
106 |
|
107 inline Matrix SVD::right_singular_matrix (void) const |
|
108 { |
|
109 return right_sm; |
|
110 } |
|
111 |
|
112 } // extern "C++" |
|
113 |
|
114 #endif |
|
115 |
|
116 /* |
|
117 ;;; Local Variables: *** |
|
118 ;;; mode: C++ *** |
|
119 ;;; page-delimiter: "^/\\*" *** |
|
120 ;;; End: *** |
|
121 */ |