Suppose we have an array x with m rows and n columns and a vector s with m elements. I would like to sum the elements of each row of array x and save these results in vector s.
This can be easily implemented in Julia using v = sum(x, dims = 2)
. However, this procedure allocates extra memory for the operation. Is it any way to do this operation without extra allocation (and not using cycles)? I was trying function sum!
, but it does not accept keyword argument dims
.