Skip to content

Instantly share code, notes, and snippets.

@dvsseed
Created June 23, 2022 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvsseed/da6da2f5ddaa3011ac20d6add6a1e902 to your computer and use it in GitHub Desktop.
Save dvsseed/da6da2f5ddaa3011ac20d6add6a1e902 to your computer and use it in GitHub Desktop.
The header is for gsl_svd.cpp
#ifndef GSLSINGULARVALUEDECOMPOSITION_H
#define GSLSINGULARVALUEDECOMPOSITION_H
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_errno.h>
void linearSolve_SVD(const gsl_matrix *A, const gsl_vector *b, gsl_vector *x);
class GslSVD {
public:
GslSVD();
~GslSVD();
int SV_decomp(const gsl_matrix *A);
int SV_decomp_mod(const gsl_matrix *A);
int SV_decomp_jacobi(gsl_matrix *A);
int SV_solve(const gsl_vector *b, gsl_vector *x);
gsl_vector *getVectorS();
gsl_matrix *getMatrixU();
gsl_matrix *getMatrixV();
int trimVectorS(double abseps);
private:
gsl_vector *S;
gsl_matrix *U;
gsl_matrix *V;
void alloc_suv(int rows, int cols);
};
#endif // GSLSINGULARVALUEDECOMPOSITION_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment