繁体   English   中英

Math.NET数值-矩阵 <double> 来自双打

[英]Math.NET Numerics - Matrix<double> from an array of doubles

假设我有:

double[] someArray = new [] { 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44 };

是否有任何开箱即用的方法可以从该数组中创建4x4矩阵而不必自己将其拆分为4个数组?

我知道这样做很简单,但是我正在探索有多少现成的东西。

编辑

抱歉,不清楚(标题是):

我想知道的是Math.NET Numerics中的“矩阵”构建器是否具有开箱即用的功能。 就像是:

Matrix<double> someMatrix = DenseMatrix.OfArray(columns: 4, rows: 4, data: someArray);

通过查看文档 ,可以直接使用构造函数,也可以使用OfColumnMajor(int rows, int columns, IEnumerable<double> columnMajor)函数,如果您的数据是以列为主的顺序。

代码如下所示:

//Using the constructor
Matrix<double> someMatrix = new DenseMatrix(4, 4, someArray)

//Using the static function
Matrix<double> someMatrix = DenseMatrix.OfColumnMajor(4, 4, someArray);

如果数据按行优先顺序排列,则可以拆分为数组,并使用OfRows函数之一,也可以使用构造函数并转置矩阵,如Christoph所建议。

暂无
暂无

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

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