Singular Value Decomposition simple code in c

6k views Asked by At

I am looking for Singular Value Decomposition (SVD) code in C, would you please help me?

I found many sources but I cannot run them, I am looking for a version of SVD code that provide all 3 matrix of S, V and U for me.

3

There are 3 answers

5
Ander Biguri On BEST ANSWER

You can use the Numerical recipies code for that svdcmp.c reference. Actually in my case I found more accurate the openCV one, but both work fine.

8
Stephen Canon On

Don't write it yourself, don't deal with trying to build someone else's source. Use a library that provides this function for you. There's probably already one available on your target platform.

Specifically, use the industry-standard LAPACK library or use the GSL or whatever other linear algebra library you want. They all have an SVD implementation.

0
Danijel On

Use one of the libraries listed at the Wiki page: comparison of linear algebra libraries. Look under the "SVD" column to make sure algorithm is supported (even vast majority of the libraries do support SVD).