Problem with Singular Value Decomposition - Timeout

Jun 8, 2011 at 10:09 AM
Edited Jun 8, 2011 at 10:13 AM

Hi there,

 

I'm trying to do a singular value decomposition.

This is how I create the Matrix:

 

 

Matrix TDM = new Matrix(new double[][] {
            //             1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
            new double[] { 0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0 }, //1
            new double[] { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, //2
            new double[] { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0},  //3
            new double[] { 0,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0 },
            new double[] { 1,1,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0 }, //5
            new double[] { 0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
            new double[] { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 },
            new double[] { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 },
            //             1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
            new double[] { 0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0 },
            new double[] { 0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0 },
            new double[] { 0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0 },
            new double[] { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 },  //6
            new double[] { 0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0 },
            new double[] { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0 },
            new double[] { 0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0 },
            new double[] { 0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1 }});
            //             1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 *

 

When I debug my code and check the variable TDM in my locals view (Sorry, got the german version of Visual Studio 2010 C#)

I get this error at the SingularValueDecomposition: "Das Timeout für die Funktionsauswertung wurde überschritten"

Which means "The timeout for the evaluation function has been exceeded".

Additionally I get an: "System.IndexOutOfRangeException" error at EigenValueDecomposition, EigenValues and EigenVectors.

 

If I comment out one of the lines marked //1 - //6 everything works fine.

 

Does anybody have any clue on why? May be something wrong with the declaration of my matrix?

 

Thanks in advance,

ScheffK0ch

Jun 8, 2011 at 12:36 PM

Hi ScheffK0ch,

This matrix works with SVD in Math.NET Numerics. You seem to be using Math.NET Iridium. Can you give Numerics a try? As for the EigenValueDecompostion, Numerics only supports square matrices.

Regards,
Marcus 

Jun 8, 2011 at 1:00 PM

Hi Marcus,

 

thanks for the quick reply.

How do I test this in Numerics?

Seems I'm too stupid to declare my matrix ;)

But anyway I will need SVDs of non square matrices in the future...

So it seems I'm bound to Iridium?

 

Thanks,

ScheffK0ch

Jun 8, 2011 at 1:08 PM

 

SVD supports non-square matrices, but our EVD class does not. 
  using MathNet.Numerics.LinearAlgebra.Double;
  ...
  var TDM = new DenseMatrix(new double[,] {
            { 0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0 }, //1
            { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }, //2
            { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0},  //3
            { 0,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0 },
            { 1,1,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0 }, //5
            { 0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
            { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 },
            { 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0 },
            { 0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0 },
            { 0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0 },
            { 0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0 },
            { 0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0 },  //6
            { 0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0 },
            { 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0 },
            { 0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0 },
            { 0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1 }});

            var svd = TDM.Svd(true);

 

 

Jun 8, 2011 at 1:12 PM

Thanks for your help :o)