scalanlp / breeze

Breeze is/was a numerical processing library for Scala.
https://www.scalanlp.org
Apache License 2.0
3.45k stars 692 forks source link

Vector * Vector does not work #728

Closed schlichtanders closed 5 years ago

schlichtanders commented 6 years ago

with scala 2.11.12, breeze 0.12 the following astonishingly basic operation does not work

val b = breeze.linalg.DenseVector(1.0,2.0,3.0)
b * b

but throws the following error

diverging implicit expansion for type breeze.linalg.operators.OpMulMatrix.Impl2[breeze.linalg.DenseVector[Double],breeze.linalg.DenseVector[Double],That]
starting with method collapseUred in object UFunc
       b * b
akopich commented 6 years ago

It works in breeze 0.13.2 as an element-wise product.

If you need a dot-product, you should rather use

a.t * a

or

dot(a, a)

Your version doesn't work because DenseVector stands for a column-vector and a product of two column-vectors is not defined.

schlichtanders commented 6 years ago

thank you very much for the fast response!!

I was experimenting a bit in the meanwhile and found that `b :* b does give a element-wise product in breeze 0.12