Evy Lino
Evy Lino

Reputation: 19

MathNet.Numerics.LinearAlgebra in .Net framework

How can I instantiate a matrix and perform some matrix operations? Example if I want to perform matrix multiplication between;

A = [[ 1 2 ][ 3 4 ]]

B = [[ 2 4 ][ 6 8 ]]

C=A*B

I only need a simple sample code using the namespace "MathNet.Numerics.LinearAlgebra" to instantiate and perform the above operation.

Upvotes: 0

Views: 918

Answers (1)

Dennis_E
Dennis_E

Reputation: 8904

The DenseMatrix class has a factory method that takes a 2-dimensional array (of double). So you can do this:

DenseMatrix A = DenseMatrix.OfArray(new double[,] { {1, 2}, {3, 4} }); DenseMatrix A = DenseMatrix.OfArray(new double[,] { {2, 4}, {6, 8} });

Then just multiply them:

DenseMatrix C = A * B;

Is this what you needed?

Upvotes: 1

Related Questions