GNU Octave  4.2.1
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
svd.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2016-2017 CarnĂ« Draug
4 Copyright (C) 1994-2016 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 3 of the License, or (at your
11 option) any 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, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_svd_h)
25 #define octave_svd_h 1
26 
27 #include "octave-config.h"
28 
29 #include <vector>
30 
31 namespace octave
32 {
33  namespace math
34  {
35  template <typename T>
36  class
37  svd
38  {
39  public:
40 
41  typedef typename T::real_diag_matrix_type DM_T;
42 
43  enum class Type
44  {
45  std,
46  economy,
47  sigma_only
48  };
49 
50  enum class Driver
51  {
52  GESVD,
53  GESDD
54  };
55 
56  svd (void)
57  : m_type (), m_driver (), left_sm (), sigma (), right_sm ()
58  { }
59 
60  svd (const T& a, svd::Type type = svd::Type::std,
62 
63  svd (const svd& a)
64  : m_type (a.m_type), m_driver (a.m_driver), left_sm (a.left_sm),
65  sigma (a.sigma), right_sm (a.right_sm)
66  { }
67 
68  svd& operator = (const svd& a)
69  {
70  if (this != &a)
71  {
72  m_type = a.m_type;
73  left_sm = a.left_sm;
74  sigma = a.sigma;
75  right_sm = a.right_sm;
76  m_driver = a.m_driver;
77  }
78 
79  return *this;
80  }
81 
82  ~svd (void) { }
83 
84  T left_singular_matrix (void) const;
85 
86  DM_T singular_values (void) const { return sigma; }
87 
88  T right_singular_matrix (void) const;
89 
90  private:
91 
92  typedef typename T::element_type P;
93  typedef typename DM_T::element_type DM_P;
94 
97 
99  DM_T sigma;
101 
102  void gesvd (char& jobu, char& jobv, octave_idx_type m, octave_idx_type n,
103  P* tmp_data, octave_idx_type m1, DM_P* s_vec, P* u, P* vt,
104  octave_idx_type nrow_vt1, std::vector<P>& work,
105  octave_idx_type& lwork, octave_idx_type& info);
106 
107  void gesdd (char& jobz, octave_idx_type m, octave_idx_type n,
108  P* tmp_data, octave_idx_type m1, DM_P* s_vec, P* u, P* vt,
109  octave_idx_type nrow_vt1, std::vector<P>& work,
110  octave_idx_type& lwork,
111  octave_idx_type* iwork, octave_idx_type& info);
112  };
113  }
114 }
115 
116 #endif
svd(const svd &a)
Definition: svd.h:63
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
~svd(void)
Definition: svd.h:82
DM_T sigma
Definition: svd.h:99
STL namespace.
svd::Type m_type
Definition: svd.h:95
T::element_type P
Definition: svd.h:92
u
Definition: lu.cc:138
svd(void)
Definition: svd.h:56
DM_T::element_type DM_P
Definition: svd.h:93
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
T::real_diag_matrix_type DM_T
Definition: svd.h:41
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
DM_T singular_values(void) const
Definition: svd.h:86
idx type
Definition: ov.cc:3129
svd::Driver m_driver
Definition: svd.h:96