GNU Octave 11.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-2026 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
35
36template <typename T>
38{
39public:
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 GEJSV
55 };
56
57 svd ()
58 : m_type (), m_driver (), m_left_sm (), m_sigma (), m_right_sm ()
59 { }
60
61 svd (const T& a, svd::Type type = svd::Type::std,
63
64 svd (const svd& a)
65 : m_type (a.m_type), m_driver (a.m_driver), m_left_sm (a.m_left_sm),
66 m_sigma (a.m_sigma), m_right_sm (a.m_right_sm)
67 { }
68
69 svd& operator = (const svd& a)
70 {
71 if (this != &a)
72 {
73 m_type = a.m_type;
74 m_left_sm = a.m_left_sm;
75 m_sigma = a.m_sigma;
76 m_right_sm = a.m_right_sm;
77 m_driver = a.m_driver;
78 }
79
80 return *this;
81 }
82
83 ~svd () = default;
84
85 T left_singular_matrix () const;
86
87 DM_T singular_values () const { return m_sigma; }
88
89 T right_singular_matrix () const;
90
91private:
92
93 typedef typename T::element_type P;
94 typedef typename DM_T::element_type DM_P;
95
96 svd::Type m_type;
97 svd::Driver m_driver;
98
99 T m_left_sm;
100 DM_T m_sigma;
101 T m_right_sm;
102
103 void gesvd (char& jobu, char& jobv, octave_f77_int_type m,
104 octave_f77_int_type n, P *tmp_data, octave_f77_int_type m1,
105 DM_P *s_vec, P *u, P *vt, octave_f77_int_type nrow_vt1,
106 std::vector<P>& work, octave_f77_int_type& lwork,
107 octave_f77_int_type& info);
108
109 void gesdd (char& jobz, octave_f77_int_type m, octave_f77_int_type n,
110 P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u,
111 P *vt, octave_f77_int_type nrow_vt1, std::vector<P>& work,
112 octave_f77_int_type& lwork, octave_f77_int_type *iwork,
113 octave_f77_int_type& info);
114
115 void gejsv (char& joba, char& jobu, char& jobv, char& jobr, char& jobt,
116 char& jobp, octave_f77_int_type m, octave_f77_int_type n,
117 P *tmp_data, octave_f77_int_type m1, DM_P *s_vec, P *u,
118 P *v, octave_f77_int_type nrow_v1, std::vector<P>& work,
119 octave_f77_int_type& lwork,
120 std::vector<octave_f77_int_type>& iwork,
121 octave_f77_int_type& info);
122};
123
124OCTAVE_END_NAMESPACE(math)
125OCTAVE_END_NAMESPACE(octave)
126
127#endif
Definition svd.h:38
~svd()=default
T::real_diag_matrix_type DM_T
Definition svd.h:41
svd(const svd &a)
Definition svd.h:64
Type
Definition svd.h:44
DM_T singular_values() const
Definition svd.h:87
Driver
Definition svd.h:51
svd()
Definition svd.h:57
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition main.in.cc:55