GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dbleSVD.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2013 John W. Eaton
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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_dbleSVD_h)
24 #define octave_dbleSVD_h 1
25 
26 #include <iosfwd>
27 
28 #include "dDiagMatrix.h"
29 #include "dMatrix.h"
30 
31 class
32 OCTAVE_API
33 SVD
34 {
35 public:
36 
37  enum type
38  {
39  std,
41  sigma_only
42  };
43 
44  enum driver
45  {
47  GESDD
48  };
49 
50  SVD (void) : type_computed (), sigma (), left_sm (), right_sm () { }
51 
52  SVD (const Matrix& a,
53  type svd_type = SVD::std, driver svd_driver = SVD::GESVD)
54  : type_computed (), sigma (), left_sm (), right_sm ()
55  {
56  init (a, svd_type, svd_driver);
57  }
58 
59  SVD (const Matrix& a, octave_idx_type& info,
60  type svd_type = SVD::std, driver svd_driver = SVD::GESVD)
61  : type_computed (), sigma (), left_sm (), right_sm ()
62  {
63  info = init (a, svd_type, svd_driver);
64  }
65 
66  SVD (const SVD& a)
67  : type_computed (a.type_computed), sigma (a.sigma),
68  left_sm (a.left_sm), right_sm (a.right_sm)
69  { }
70 
71  SVD& operator = (const SVD& a)
72  {
73  if (this != &a)
74  {
75  type_computed = a.type_computed;
76  sigma = a.sigma;
77  left_sm = a.left_sm;
78  right_sm = a.right_sm;
79  }
80 
81  return *this;
82  }
83 
84  ~SVD (void) { }
85 
86  DiagMatrix singular_values (void) const { return sigma; }
87 
88  Matrix left_singular_matrix (void) const;
89 
90  Matrix right_singular_matrix (void) const;
91 
92  friend std::ostream& operator << (std::ostream& os, const SVD& a);
93 
94 private:
95 
97 
101 
102  octave_idx_type init (const Matrix& a,
103  type svd_type = std, driver svd_driver = GESVD);
104 };
105 
106 #endif