I have a ragged array in the form of a vector of values, vals, and a corresponding vector of indices, ind. Both of these vectors are of length n. The elements of ind are in the range 1:k.
I want to increment a k-vector of sums, sums, with the values of vals according to inds, as in
for (v, i) in zip(vals, inds)
sums[i] += v
end
Is there a sum method like this?
Writing this out explicitly is obviously not very difficult but I have the feeling that I am missing an abstraction here.