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