GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
svd.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_svd_h)
27 #define octave_svd_h 1
28 
29 #include "octave-config.h"
30 
31 #include <vector>
32 
33 namespace octave
34 {
35  namespace math
36  {
37  template <typename T>
38  class
39  svd
40  {
41  public:
42 
43  typedef typename T::real_diag_matrix_type DM_T;
44 
45  enum class Type
46  {
47  std,
48  economy,
49  sigma_only
50  };
51 
52  enum class Driver
53  {
54  GESVD,
55  GESDD
56  };
57 
58  svd (void)
59  : m_type (), m_driver (), left_sm (), sigma (), right_sm ()
60  { }
61 
62  svd (const T& a, svd::Type type = svd::Type::std,
64 
65  svd (const svd& a)
66  : m_type (a.m_type), m_driver (a.m_driver), left_sm (a.left_sm),
67  sigma (a.sigma), right_sm (a.right_sm)
68  { }
69 
70  svd& operator = (const svd& a)
71  {
72  if (this != &a)
73  {
74  m_type = a.m_type;
75  left_sm = a.left_sm;
76  sigma = a.sigma;
77  right_sm = a.right_sm;
78  m_driver = a.m_driver;
79  }
80 
81  return *this;
82  }
83 
84  ~svd (void) = default;
85 
86  T left_singular_matrix (void) const;
87 
88  DM_T singular_values (void) const { return sigma; }
89 
90  T right_singular_matrix (void) const;
91 
92  private:
93 
94  typedef typename T::element_type P;
95  typedef typename DM_T::element_type DM_P;
96 
99 
103 
104  void gesvd (char& jobu, char& jobv, octave_f77_int_type m,
105  octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1,
106  DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1,
107  std::vector<P>& work, octave_f77_int_type& lwork,
108  octave_f77_int_type& info);
109 
110  void gesdd (char& jobz, octave_f77_int_type m, octave_f77_int_type n,
111  P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u,
112  P *vt, octave_f77_int_type nrow_vt1, std::vector<P>& work,
113  octave_f77_int_type& lwork, octave_f77_int_type *iwork,
114  octave_f77_int_type& info);
115  };
116  }
117 }
118 
119 #endif
void gesdd(char &jobz, octave_f77_int_type m, octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1, std::vector< P > &work, octave_f77_int_type &lwork, octave_f77_int_type *iwork, octave_f77_int_type &info)
T::real_diag_matrix_type DM_T
Definition: svd.h:43
svd(const svd &a)
Definition: svd.h:65
svd::Driver m_driver
Definition: svd.h:98
DM_T sigma
Definition: svd.h:101
~svd(void)=default
svd(void)
Definition: svd.h:58
DM_T singular_values(void) const
Definition: svd.h:88
svd::Type m_type
Definition: svd.h:97
DM_T::element_type DM_P
Definition: svd.h:95
T::element_type P
Definition: svd.h:94
void gesvd(char &jobu, char &jobv, octave_f77_int_type m, octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1, std::vector< P > &work, octave_f77_int_type &lwork, octave_f77_int_type &info)
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753