GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
gsvd.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1997-2024 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_gsvd_h)
27 #define octave_gsvd_h 1
28 
29 #include "octave-config.h"
30 
32 
34 
35 template <typename T>
36 class
38 gsvd
39 {
40 public:
41 
42  enum class Type
43  {
44  std,
45  economy,
46  sigma_only
47  };
48 
49  gsvd () : m_sigmaA (), m_sigmaB (), m_left_smA (), m_left_smB (), m_right_sm ()
50  { }
51 
52  gsvd (const T& a, const T& b,
53  gsvd::Type gsvd_type = gsvd<T>::Type::std);
54 
55  gsvd (const gsvd& a)
56  : m_type (a.m_type),
57  m_sigmaA (a.m_sigmaA), m_sigmaB (a.m_sigmaB),
58  m_left_smA (a.m_left_smA), m_left_smB (a.m_left_smB), m_right_sm (a.m_right_sm)
59  { }
60 
61  gsvd& operator = (const gsvd& a)
62  {
63  if (this != &a)
64  {
65  m_type = a.m_type;
66  m_sigmaA = a.m_sigmaA;
67  m_sigmaB = a.m_sigmaB;
68  m_left_smA = a.m_left_smA;
69  m_left_smB = a.m_left_smB;
70  m_right_sm = a.m_right_sm;
71  }
72 
73  return *this;
74  }
75 
76  ~gsvd () = default;
77 
78  typename T::real_matrix_type
79  singular_values_A () const { return m_sigmaA; }
80 
81  typename T::real_matrix_type
82  singular_values_B () const { return m_sigmaB; }
83 
84  T left_singular_matrix_A () const;
85  T left_singular_matrix_B () const;
86 
87  T right_singular_matrix () const;
88 
89 private:
90  typedef typename T::value_type P;
91  typedef typename T::real_matrix_type real_matrix;
92 
93  void ggsvd (char& jobu, char& jobv, char& jobq, octave_f77_int_type m,
94  octave_f77_int_type n, octave_f77_int_type p,
95  octave_f77_int_type& k, octave_f77_int_type& l,
96  P *tmp_dataA, octave_f77_int_type m1,
97  P *tmp_dataB, octave_f77_int_type p1,
98  real_matrix& alpha, real_matrix& beta,
99  P *u, octave_f77_int_type nrow_u,
100  P *v, octave_f77_int_type nrow_v,
101  P *q, octave_f77_int_type nrow_q,
102  P *work, octave_f77_int_type lwork,
103  octave_f77_int_type *iwork,
104  octave_f77_int_type& info);
105 
106  //--------
107 
108  gsvd::Type m_type;
109  real_matrix m_sigmaA, m_sigmaB;
110  T m_left_smA, m_left_smB;
111  T m_right_sm;
112 };
113 
114 OCTAVE_END_NAMESPACE(math)
115 OCTAVE_END_NAMESPACE(octave)
116 
117 #endif
Definition: gsvd.h:39
T::real_matrix_type singular_values_A() const
Definition: gsvd.h:79
gsvd(const gsvd &a)
Definition: gsvd.h:55
~gsvd()=default
gsvd()
Definition: gsvd.h:49
T::real_matrix_type singular_values_B() const
Definition: gsvd.h:82
Type
Definition: gsvd.h:43
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.cc:55
T octave_idx_type m
Definition: mx-inlines.cc:781
octave_idx_type n
Definition: mx-inlines.cc:761