svd.h
Go to the documentation of this file.
1 /*
2 This file is part of the Ristra wonton project.
3 Please see the license file at the root of this repository, or at:
4  https://github.com/laristra/wonton/blob/master/LICENSE
5 */
6 
7 /*
8  * svd.h - Double precision SVD decomposition routine.
9  * Takes an mxn matrix a and decomposes it into udv, where u,v are
10  * left and right orthogonal transformation matrices, and d is a
11  * diagonal matrix of singular values.
12  *
13  * This routine was adapted from Numerical Recipes SVD routines in C
14  * to be called with C++ std::vectors by Michael Rogers.
15  *
16  * Input to svd is as follows:
17  * a = mxn matrix to be decomposed, gets overwritten with u
18  * w = returns the vector of singular values of a
19  * v = returns the right orthogonal transformation matrix
20 */
21 
22 #ifndef SRC_SVD_H_
23 #define SRC_SVD_H_
24 
25 #include <vector>
26 
27 namespace Wonton {
28 
29 // Perform singular value decomposition
30 
31 int svd(std::vector<std::vector<double> > & a, std::vector<double> & w, std::vector<std::vector<double> > & v);
32 
33 // Singular value backsubstitution.
34 
35 void svd_solve(const std::vector<std::vector<double> > & u, const std::vector<double> & w, \
36  const std::vector<std::vector<double> > & v, \
37  std::vector<double> & b, std::vector<double> & x);
38  // Solves A*x=b for vector x. A is specified by the arrays
39  // u[1...m][1...n], w[1...n],v[1...n[1...n], as returned by
40  // svd. m and n are the dimensions of a. b[1...m] is the rhs.
41  // x[1...n] is the solution vector (output). Nothing is destroyed
42  // so it can be called sequentially with different b vectors.
43 
44 } // namespace Wonton
45 
46 #endif
Factorize a number N into D equal (or nearly equal) factors.
Definition: adaptive_refinement_mesh.h:31
std::vector< T > vector
Definition: wonton.h:285
int svd(std::vector< std::vector< double > > &a, std::vector< double > &w, std::vector< std::vector< double > > &v)
Definition: svd.cc:46
void svd_solve(const std::vector< std::vector< double > > &u, const std::vector< double > &w, const std::vector< std::vector< double > > &v, std::vector< double > &b, std::vector< double > &x)
Definition: svd.cc:320