简体   繁体   中英

How to take inverse of a matrix with mathdotnet

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();

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.

If you use C# and the class:

DenseMatrix like this:

DenseMatrix yourNewDenseMatrixInverted=yourDenseMatrix.Inverse();    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM