英文:
Breeze - Comparison of DenseVector gives me a BitVector - is this intentional?
问题
import breeze.linalg._
val dm = DenseMatrix(0.0, 5.0, 6.0)
dm :== 6.0
val dv = DenseVector(0.0, 5.0, 6.0)
dv :== 6.0
gives me
dm: breeze.linalg.DenseMatrix[Double] =
0.0
5.0
6.0
res0: breeze.linalg.DenseMatrix[Boolean] =
false
false
true
dv: breeze.linalg.DenseVector[Double] = DenseVector(0.0, 5.0, 6.0)
res1: breeze.linalg.BitVector = BitVector(2)
I was expecting a DenseVector[Boolean]
false
false
true
Is this an intentional construct - can someone explain it for me? I found it confusing!
英文:
import breeze.linalg._
val dm = DenseMatrix(0.0, 5.0, 6.0)
dm :== 6.0
val dv = DenseVector(0.0, 5.0, 6.0)
dv :== 6.0
gives me
dm: breeze.linalg.DenseMatrix[Double] =
0.0
5.0
6.0
res0: breeze.linalg.DenseMatrix[Boolean] =
false
false
true
dv: breeze.linalg.DenseVector[Double] = DenseVector(0.0, 5.0, 6.0)
res1: breeze.linalg.BitVector = BitVector(2)
I was expecting a DenseVector[Boolean]
false
false
true
Is this an intentional construct - can someone explain it for me? I found it confusing!
答案1
得分: 1
You can get DenseVector
by (dv :== 6.0).toDenseVector
.
I'm not sure about reasons of this asymmetry, I guess authors probably were more concerned about performance in case of DenseVector
. See DenseVector source vs DenseMatrix source.
英文:
You can get DenseVector
by (dv :== 6.0).toDeseVector
.
I'm not sure about reasons of this asymmetry, I guess authors probably were more concerned about performance in case of DenseVector
. See DenseVector source vs DenseMatrix source.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论