I’ll explain my need with an example.
a = [1:5;]
indices = [1,1,3,3];
values = [2,3,4,5];
I need to add values
to the original vector a
as per the indices
.
The solution for above example should be,
>>> [6,2,12,4,5]
I can do this with for loop. a[indices] += values
doesn’t work (I get that). Is there any other way to do it?
nilshg
2
This seems like a perfect use case for a for loop, I find it hard to imagine anything clearer. Why would you want to avoid a loop?
Not necessary. Was just curious if there are any functions like accumarray (matlab) in julia!
nilshg
4
JuliaHub suggests:
But it looks pretty out of date.
Thank you! Guess I’ll stick to the for loop. It is better as you said.