Singular Value Decomposition Implementation
I have a SVD library implemented in C. But I want to call its functions in a Java program. Is there a easy way to do that? Or someone please suggest a link for a SVD implementation i开发者_运维技巧n Java.
There's also the Apache commons Math library: http://commons.apache.org/math/
which has matrices and SVD algorithms. And lots of other useful stuff!
If it's straight C, you could look at JNA, which will allow you to call C from java relatively easily.
There's also JNI and/or SWIG, but they're more involved.
Colt is another Java maths library with matrices and SVD.
You can use the Java Native Interface (JNI) to call native code from your java program. It's not too difficult to get set up.
Adrian Kuhn and David Erni recently released SVDLIBJ, which is a pure Java port of SVDLIBC. If you're looking to do a thin SVD (where you only need a few of the most singular values or vectors), this is probably best bet. JAMA, COLT and the Apache Commons Math packages all perform the full SVD.
If you're wanting to use the SVD as a stand-alone program, the S-Space Package also has a command-line tool for using SVDLIBJ just like SVDLIBC, with supports for more matrix formats as well.
Back when I had to do matrix operations in Java I used JAMA: A Java Matrix Package
I know it has SVD, but I can't vouch for the efficiency or current status of the package.
See also Apache Mahout's implementation(s) - https://cwiki.apache.org/confluence/display/MAHOUT/Dimensional+Reduction
精彩评论