【问题标题】:MathNet.Numerics.LinearAlgebra - How to lookup multiple rows in MatrixMathNet.Numerics.LinearAlgebra - 如何在矩阵中查找多行
【发布时间】:2019-11-14 08:26:15
【问题描述】:

我正在尝试使用 MathDotNet Numerics 进行稀疏矩阵乘法。输入:

Matrix<float> mat  // dense matrix of size n x k, where n is large and k ~ 10
int[] index        // int[] of length l ~ 10, e.g. { 7, 13, 11, ... }

所以我想查找多个列,即“mat[index]”之类的内容,其形状为l x k

谁能告诉我该怎么做?

(我是遍历index 并堆叠行还是有更好的方法?)

【问题讨论】:

    标签: matrix-multiplication matrix-indexing mathnet-numerics


    【解决方案1】:

    这是堆叠解决方案:

    Matrix<T> lookup = CreateMatrix.DenseOfRowVectors(indices.Select(i => matrix.Row(i)));
    

    感觉可能有更好的方法,不需要分配新的内存。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      • 2012-10-11
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多