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