breeze 中切片的线性运算
Linear operations with slices in breeze
是否可以在 breeze 中对矩阵进行切片更新?我找不到参数 op 的隐式值。
Breeze0.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)
以迭代方式更新行有难看的work-around。
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.
上打开一个问题
是否可以在 breeze 中对矩阵进行切片更新?我找不到参数 op 的隐式值。 Breeze0.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)
以迭代方式更新行有难看的work-around。
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.
上打开一个问题