scalanlp / breeze

Breeze is a numerical processing library for Scala.
www.scalanlp.org
Apache License 2.0
3.44k stars 691 forks source link

Compile Error when adding a constant to DenseVector/DenseMatrix #816

Closed tebartsch closed 3 years ago

tebartsch commented 3 years ago

The Following yields an error: (Scala 2.13, Breeze 1.2)

import breeze.linalg._

// Works Fine
1.0 - DenseVector(1.0, 2.0)
1.0 - DenseMatrix((1.0, 2.0), (3.0, 4.0))

// Error: 
// overloaded method + with alternatives: ... cannot be applied to (breeze.linalg.DenseVector[Double])
1.0 + DenseVector(1.0, 2.0)
1.0 + DenseMatrix((1.0, 2.0), (3.0, 4.0))
dlwh commented 3 years ago

Sorry I thought I replied to this. Scala's weird treatment of + to match Java's for string concatenation somehow makes it so that I can't make this overload work. You can use +:+ instead if you want, or obviously you can just flip the LHS and RHS.