@vvdb wrote:
Math.NET Numerics has singular value decomposition (SVD), but the current implementation doesn't scale well on large sparse matrices. Also, the implemented algorithm doesn't allow specifying a maximum number of dimensions: this feature would be useful when doing principal component analysis.
The solution is to get a library like LIBSVDC (https://tedlab.mit.edu/~dr/SVDLIBC/) and DllImport it. This seems to work reliably after some fiddling since the code is not exactly "friendly" to .NET in its current form. However, this pure unmanaged C code, (sadly, not thread-safe at all), is extremely fast and precise as long as you want the "top n" high order singular values.I had some time on my hands and I translated the underlying Lanzcos SVD algorithm into pure C#, with extension methods to work on Math.NET Numerics
Matrix<double>
objects. It is almost as fast as LIBSVDC (discounting the format conversion time) and my limited testing validated the results with respect to that library. It is also thread- and multiprocessor safe.
It presents the factors as a derivative of theSvd<double>
type, albeit without condition number, rank, determinant and L2 Norm, or the ability to solve systems: I didn't need the functionality and my natural laziness turned it into an exercise for the reader Image may be NSFW.
Clik here to view..
What I would like to do is contribute that code (one assembly containing 6 source files and a package config) to Math.NET Numerics, but being lazy I'd like to just send it to a project representative and be done with it.
That is, if anyone is interested.
Vincent Van Den Berghe
Bureau van Dijk Electronic Publishing
Posts: 1
Participants: 1