I'm trying to add a row vector to each row of a matrix:
val M = DenseMatrix((1.0,2.0,3.0),
(4.0,5.0,6.0))
val row = DenseVector(3.0,4.0,5.0).t
val result = M(*,::) + row
// error: could not find implicit value for parameter
// op: OpAdd.Impl2[
// BroadcastedRows[DenseMatrix[Double],DenseVector[Double]],
// Transpose[DenseVector[Double]],
// That
// ]
I can use column vectors instead, but it seems a little convoluted:
val result = (M.t(::,*) + row.t).t
// result: breeze.linalg.DenseMatrix[Double] =
// 4.0 6.0 8.0
// 7.0 9.0 11.0
Thanks.