Reputation: 19
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
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