457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
457
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_SVD_h) |
|
25 #define octave_SVD_h 1 |
|
26 |
3503
|
27 #include <iostream> |
457
|
28 |
|
29 #include "dDiagMatrix.h" |
|
30 #include "dMatrix.h" |
|
31 |
1880
|
32 class |
|
33 SVD |
457
|
34 { |
|
35 public: |
|
36 |
537
|
37 enum type |
|
38 { |
|
39 std, |
|
40 economy, |
2802
|
41 sigma_only |
537
|
42 }; |
|
43 |
1881
|
44 SVD (void) : sigma (), left_sm (), right_sm () { } |
1528
|
45 |
1529
|
46 SVD (const Matrix& a, type svd_type = SVD::std) { init (a, svd_type); } |
457
|
47 |
5275
|
48 SVD (const Matrix& a, octave_idx_type& info, type svd_type = SVD::std) |
1528
|
49 { |
|
50 info = init (a, svd_type); |
|
51 } |
457
|
52 |
1528
|
53 SVD (const SVD& a) |
4374
|
54 : type_computed (a.type_computed), |
|
55 sigma (a.sigma), left_sm (a.left_sm), right_sm (a.right_sm) { } |
457
|
56 |
1528
|
57 SVD& operator = (const SVD& a) |
|
58 { |
1880
|
59 if (this != &a) |
|
60 { |
4374
|
61 type_computed = a.type_computed; |
1880
|
62 sigma = a.sigma; |
|
63 left_sm = a.left_sm; |
|
64 right_sm = a.right_sm; |
|
65 } |
1528
|
66 |
|
67 return *this; |
|
68 } |
|
69 |
1930
|
70 ~SVD (void) { } |
|
71 |
1528
|
72 DiagMatrix singular_values (void) const { return sigma; } |
|
73 |
1544
|
74 Matrix left_singular_matrix (void) const; |
1528
|
75 |
1544
|
76 Matrix right_singular_matrix (void) const; |
457
|
77 |
3504
|
78 friend std::ostream& operator << (std::ostream& os, const SVD& a); |
457
|
79 |
|
80 private: |
|
81 |
1544
|
82 SVD::type type_computed; |
|
83 |
457
|
84 DiagMatrix sigma; |
|
85 Matrix left_sm; |
|
86 Matrix right_sm; |
1880
|
87 |
5275
|
88 octave_idx_type init (const Matrix& a, type svd_type = std); |
457
|
89 }; |
|
90 |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |