Breeze – DenseVector的比较会给我一个BitVector – 这是有意的吗?

huangapple go评论132阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年1月7日 00:40:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/59615818.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定