yat  0.20.3pre
SVD.h
1 #ifndef _theplu_yat_utility_svd_
2 #define _theplu_yat_utility_svd_
3 
4 // $Id: SVD.h 4207 2022-08-26 04:36:28Z peter $
5 
6 /*
7  Copyright (C) 2003 Daniel Dalevi, Jari Häkkinen
8  Copyright (C) 2004 Jari Häkkinen
9  Copyright (C) 2005 Jari Häkkinen, Peter Johansson
10  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
11  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
12  Copyright (C) 2018, 2022 Peter Johansson
13 
14  This file is part of the yat library, http://dev.thep.lu.se/yat
15 
16  The yat library is free software; you can redistribute it and/or
17  modify it under the terms of the GNU General Public License as
18  published by the Free Software Foundation; either version 3 of the
19  License, or (at your option) any later version.
20 
21  The yat library is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with yat. If not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #include "config_public.h"
31 
32 #include "Matrix.h"
33 #include "Vector.h"
34 
35 #include <gsl/gsl_linalg.h>
36 
37 namespace theplu {
38 namespace yat {
39 namespace utility {
40 
41  class VectorBase;
42 
56  class SVD
57  {
58  public:
59 
66  enum SVDalgorithm {
67  GolubReinsch,
68  ModifiedGolubReinsch,
69  Jacobi
70  };
71 
79  explicit SVD(const MatrixBase& Ain);
80 
87  explicit SVD(MatrixMutable&& Ain);
88 
92  ~SVD(void);
93 
100  void decompose(SVDalgorithm algo=GolubReinsch);
101 
110  const Vector& s(void) const;
111 
121  void solve(const VectorBase& b, Vector& x);
122 
131  const Matrix& U(void) const;
132 
141  const Matrix& V(void) const;
142 
143  private:
149  int jacobi(void);
150 
156  int golub_reinsch(void);
157 
163  int modified_golub_reinsch(void);
164 
165  Matrix U_, V_;
166  Vector s_;
167  };
168 
169 }}} // of namespace utility, yat, and theplu
170 
171 #endif
Definition: MatrixBase.h:54
The Department of Theoretical Physics namespace as we define it.
This is the yat interface to GSL vector.
Definition: Vector.h:59
Singular Value Decomposition.
Definition: SVD.h:56
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
~SVD(void)
The destructor.
SVD(const MatrixBase &Ain)
Constructs an SVD object using the matrix Ain as only input. The input matrix is copied for further u...
void decompose(SVDalgorithm algo=GolubReinsch)
This function will perform SVD with the method specified by algo.
const Matrix & V(void) const
Access to the V matrix.
Interface to GSL matrix.
Definition: Matrix.h:104
const Vector & s(void) const
Access to the s vector.
const Matrix & U(void) const
Access to the U matrix.
SVDalgorithm
Definition: SVD.h:66
void solve(const VectorBase &b, Vector &x)
Solve the system using the decomposition of A.
Definition: MatrixMutable.h:58

Generated on Sat Feb 18 2023 03:31:44 for yat by  doxygen 1.8.14