With Scalala it was possible to perform element-wise operations on a Vector using a scalar operand. Say you have a Vector of random numbers between 0 and 1 and you want to subtract each value from 1:
import breeze.linalg._
val x = DenseVector.rand(5)
val y = 1d :- x //DOESN'T COMPILE: "value :- is not a member of Double"
Unlike Scalala, Breeze fails to compile with this approach. You can work around this by generating a Vector of ones but it just seems like there should be a better way.
val y = DenseVector.ones[Double](x.size) :- x
Another workaround would be to use the mapValues method which is a bit more readable:
val y = x mapValues { 1 - _ }
What is the proper way to accomplish this with Breeze?