0

I have the following code got from this site as a download from here. The full path after the zip file is extracted would be some thing like E:\Csharp2Dand3DTestbed\GraphicsBook\LA\LA\MatrixTransform2.cs

protected static double[,] MatrixInverse(double[,] mat)
{
    Matrix m = new Matrix(mat);
    Matrix k = m.Inverse();
    return k;
}

But that does not compile. I see from here that I need to do something like

protected static double[,] MatrixInverse(double[,] mat)
{
    Matrix<double> m = Matrix<double>.Build.WhatHere(???)(3, 4); // How with existing matrix
    Matrix k = m.Inverse();
    return k;
}

Can someone please guide me. I am not able to go further. I am using the latest version of the Math.NET Numerics

1 Answer 1

2

From double[,] to matrix (two options):

var matrix = Matrix<double>.Build.DenseOfArray(array);
var matrix = CreateMatrix.DenseOfArray(array);

From matrix to double[,]:

var array = matrix.ToArray();

Note that these involve a full copy since matrices do not use 2D arrays internally. There are more examples on this in the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.