是否可以轻松地对矩阵进行切片更新?我找不到参数 op 的隐式值。 微风0.11.2。
val idxs = Seq(0,1)
val x = DenseMatrix.rand(3,3)
val y = DenseMatrix.rand(3,3)
x(idxs,idxs)+= y(idxs, idxs) // cant find implicit conversion for += here.
使用 DenseVectors 的模拟代码可以正常工作。
val xv = DenseVector.rand(3)
val yv = DenseVector.rand(3)
x(idxs) += y(idxs)
存在以迭代方式更新行的丑陋解决方法。
val idxs = IndexedSeq(0, 1)
val x:DenseMatrix[Double] = DenseMatrix.zeros(3, 3)
val y = DenseMatrix.rand(3, 3)
for(r<-idxs) {
val slx = x(::, r)
val sly = y(::, r)
slx(idxs) += sly(idxs)
}
最佳答案
这是一个疏忽。请在 github 上提出问题。
关于scala - 微风中的切片线性运算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33570375/