Question

I need to calculate the Singular Value Decomposition of a Dense matrix but it doesn't seem to be included in the package I'm using: MathNet.Numerics x86 v2.4.0.26 downloaded from Nuget package manager.

I am referencing this question Svd recomposition..

The syntax included in the answer linked is:

 var m = DenseMatrix.OfArray(new double[,] {
   { 3, 0, 0, 0, 0 },
   { 0, 2, 4, 0, 0 },
   { 0, 4, 5, -4, 5 },
   { 0, 0, -4, -8, 12},
   { 0, 0, 5, 12, -5 }});


  var svd = m.Svd(true);  //The method Svd() doesn't seem to be available in v2.4 

  svd.U() * svd.W() * svd.VT()

Nor is svd() listed in the documentation.

I'm looking for a simple example of generating a SVD of a DenseMatrix using the MathNet.Numerics x86 library.

Unfortunately the method inverse() is just returning NaN so I'm hoping to approximate the inverse using singular value decomposition.

Was it helpful?

Solution

From the documentation I found classes for singular value decomposition

MathNet.Numerics.LinearAlgebra. Double/Single/Generic .Factorization.Svd are abstract classes.

MathNet.Numerics.LinearAlgebra. Double/Single/Generic .Factorization.DenseSvd are implementations. Pass your matrix to the constructor, the results are available via members.

OTHER TIPS

Svd() used to be an extension method in v2, which unfortunately is only available if you include the right namespace. In your case, adding the following line should do the trick:

using MathNet.Numerics.LinearAlgebra.Double;

This is one of the areas that have been greatly simplified in the upcoming v3 release, where this is a proper method. I suggest you have a look at one of the recent v3 packages (as of writing this e.g. the v3.0.0-alpha7).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top