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.
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?
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.