Closed aliakhtar closed 4 years ago
Stackoverflow indicates this wasn't an issue in the past: https://stackoverflow.com/questions/46025694/add-a-vector-to-every-column-of-a-matrix-using-scala-breeze
Looks like this assert should just be removed: https://github.com/scalanlp/breeze/blob/8c216beb11cce13ea97559835ee1c65fcd3df2bc/math/src/main/scala/breeze/linalg/DenseVector.scala#L708
Hey,
I do not know if this is still up to date, but I think the assert is at the right place.
dm
in your second example has 3 rows and 2 columns:
DenseMatrix((1.0,2.0), (3.0,4.0), (5.0, 6.0))
2.0 3.0
4.0 5.0
6.0 7.0
So adding a 2 rows vector should result in a fail.
However, you can add a 3 row vector : dm(::, *) + DenseVector(1.0, 1.0, 1.0)
, or broadcast through rows: dm(*, ::) + DenseVector(1.0, 1.0)
I'm encountering a bug when adding a vector to a matrix as described in the docs. The following works:
But if I add a 3rd row to the matrix, and try to add the same vector to it, I get an error:
It looks like this issue happens if the number of rows in the matrix go higher than the length of the vector, i.e with 2 rows and a 2D vector, it works, but with 3 rows, it fails.
Any ideas why this is? Its got to be a bug, right? I'd be happy to try to send a pull to fix this, if given some pointers.