scalascala-breeze

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!


Solution

  • 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.