457
|
1 // -*- C++ -*- |
|
2 /* |
|
3 |
1881
|
4 Copyright (C) 1996 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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
457
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_SVD_h) |
|
25 #define octave_SVD_h 1 |
|
26 |
1296
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
457
|
31 class ostream; |
|
32 |
|
33 #include "dDiagMatrix.h" |
|
34 #include "dMatrix.h" |
|
35 |
1880
|
36 class |
|
37 SVD |
457
|
38 { |
|
39 public: |
|
40 |
537
|
41 enum type |
|
42 { |
|
43 std, |
|
44 economy, |
1542
|
45 sigma_only, |
537
|
46 }; |
|
47 |
1881
|
48 SVD (void) : sigma (), left_sm (), right_sm () { } |
1528
|
49 |
1529
|
50 SVD (const Matrix& a, type svd_type = SVD::std) { init (a, svd_type); } |
457
|
51 |
1529
|
52 SVD (const Matrix& a, int& info, type svd_type = SVD::std) |
1528
|
53 { |
|
54 info = init (a, svd_type); |
|
55 } |
457
|
56 |
1528
|
57 SVD (const SVD& a) |
1881
|
58 : sigma (a.sigma), left_sm (a.left_sm), right_sm (a.right_sm) { } |
457
|
59 |
1528
|
60 SVD& operator = (const SVD& a) |
|
61 { |
1880
|
62 if (this != &a) |
|
63 { |
|
64 sigma = a.sigma; |
|
65 left_sm = a.left_sm; |
|
66 right_sm = a.right_sm; |
|
67 } |
1528
|
68 |
|
69 return *this; |
|
70 } |
|
71 |
|
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 |
|
78 friend ostream& operator << (ostream& os, const SVD& a); |
|
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 |
|
88 int init (const Matrix& a, type svd_type = std); |
457
|
89 }; |
|
90 |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; page-delimiter: "^/\\*" *** |
|
97 ;;; End: *** |
|
98 */ |