1

I get all the values of invone as NaN with this. Can't figure out what is wrong. Is there any easier way to take inverse of a matrix other than mathdotnet? It is hard to google cause when you type inverse you get the transpose codes.

        for( int i = 0 ; i < classOneCount ; i++ )
        {
            for( int j = 0 ; j < classOneCount ; j++ )
            {
                gecicione[ gecicicounter ] = classOneEpsilon[ i , j ];
                gecicicounter++;
            }
        }
        inverseOneEpsilon = new DenseMatrix( classOneCount , classOneCount , gecicione );
        var invone= inverseOneEpsilon.Inverse();
  • Provided `classOneEpsilon` is not too large, could you add its value in your question ? Because @celsound is probably right in assuming your original matrix cannot be inverted. If the matrix is large, just check that its determinant (`inverseOneEpsilone.Determinant`) is not zero. – Faibbus Apr 18 '18 at 08:33

2 Answers2

0

If your matrix is singular Math.NET will return NaN when trying the Inverse() method.

The answer is that your matrix is not invertible. You should have checks in your code for this.

celsound
  • 59
  • 8
-1

If you use C# and the class:

DenseMatrix like this:

DenseMatrix yourNewDenseMatrixInverted=yourDenseMatrix.Inverse();    
Pj Toopmuch
  • 115
  • 10
  • This is the same as `var invone= inverseOneEpsilon.Inverse();`, see [var](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/implicitly-typed-local-variables) – Faibbus Mar 28 '18 at 16:38