简体   繁体   English

.Net框架中的MathNet.Numerics.LinearAlgebra

[英]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 ]] A = [[1 2] [3 4]]

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

C=A*B C = A * B

I only need a simple sample code using the namespace "MathNet.Numerics.LinearAlgebra" to instantiate and perform the above operation. 我只需要使用名称空间“ MathNet.Numerics.LinearAlgebra”的简单示例代码即可实例化并执行上述操作。

The DenseMatrix class has a factory method that takes a 2-dimensional array (of double). DenseMatrix类具有一个采用二维数组(两倍)的工厂方法。 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? 这是您所需要的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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