Scala breeze.linalg Densematrix:无法分配列
Scala breeze.linalg Densematrix: unable to assign columns
我无法通过 A(::,1) = DenseVector 将列分配给 DenseMatrix A。这是我在
回复:
scala> val A=DenseMatrix.vertcat(DenseVector(11,12).toDenseMatrix,DenseVector(21,22).toDenseMatrix)
A: breeze.linalg.DenseMatrix[Int] =
11 12
21 22
scala> A(::,1) = DenseVector(13,23)
<console>:14: error: type mismatch;
found : collection.immutable.::.type
required: Int
A(::,1) = DenseVector(13,23)
^
Scala 版本为 2.12,breeze 版本:1.0。这类似于此 ,其中声明这应该有效。如果将 A 声明为 var
.
,问题仍然存在
你很接近...
A(::,1) := DenseVector(13,23)
https://github.com/scalanlp/breeze/wiki/Linear-Algebra-Cheat-Sheet
我无法通过 A(::,1) = DenseVector 将列分配给 DenseMatrix A。这是我在 回复:
scala> val A=DenseMatrix.vertcat(DenseVector(11,12).toDenseMatrix,DenseVector(21,22).toDenseMatrix)
A: breeze.linalg.DenseMatrix[Int] =
11 12
21 22
scala> A(::,1) = DenseVector(13,23)
<console>:14: error: type mismatch;
found : collection.immutable.::.type
required: Int
A(::,1) = DenseVector(13,23)
^
Scala 版本为 2.12,breeze 版本:1.0。这类似于此 var
.
你很接近...
A(::,1) := DenseVector(13,23)
https://github.com/scalanlp/breeze/wiki/Linear-Algebra-Cheat-Sheet