GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
svd.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1994-2025 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
34
36
37template <typename T>
39{
40public:
41
42 typedef typename T::real_diag_matrix_type DM_T;
43
44 enum class Type
45 {
46 std,
47 economy,
48 sigma_only
49 };
50
51 enum class Driver
52 {
53 GESVD,
54 GESDD,
55 GEJSV
56 };
57
58 svd ()
59 : m_type (), m_driver (), m_left_sm (), m_sigma (), m_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), m_left_sm (a.m_left_sm),
67 m_sigma (a.m_sigma), m_right_sm (a.m_right_sm)
68 { }
69
70 svd& operator = (const svd& a)
71 {
72 if (this != &a)
73 {
74 m_type = a.m_type;
75 m_left_sm = a.m_left_sm;
76 m_sigma = a.m_sigma;
77 m_right_sm = a.m_right_sm;
78 m_driver = a.m_driver;
79 }
80
81 return *this;
82 }
83
84 ~svd () = default;
85
86 T left_singular_matrix () const;
87
88 DM_T singular_values () const { return m_sigma; }
89
90 T right_singular_matrix () const;
91
92private:
93
94 typedef typename T::element_type P;
95 typedef typename DM_T::element_type DM_P;
96
97 svd::Type m_type;
98 svd::Driver m_driver;
99
100 T m_left_sm;
101 DM_T m_sigma;
102 T m_right_sm;
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 void gejsv (char& joba, char& jobu, char& jobv, char& jobr, char& jobt,
117 char& jobp, octave_f77_int_type m, octave_f77_int_type n,
118 P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u,
119 P *v, octave_f77_int_type nrow_v1, std::vector<P>& work,
120 octave_f77_int_type& lwork,
121 std::vector<octave_f77_int_type>& iwork,
122 octave_f77_int_type& info);
123};
124
125OCTAVE_END_NAMESPACE(math)
126OCTAVE_END_NAMESPACE(octave)
127
128#endif
Definition svd.h:39
~svd()=default
T::real_diag_matrix_type DM_T
Definition svd.h:42
svd(const svd &a)
Definition svd.h:65
Type
Definition svd.h:45
DM_T singular_values() const
Definition svd.h:88
Driver
Definition svd.h:52
svd()
Definition svd.h:58
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition main.in.cc:55