I have a numpy array such as
original_array=np.arange(5)
I have another array that stores the value of indices to be updated
indices=[0,1,2,1,1]
Repetition in elements of indices
signify that the element is being updated multiple times.
I have also the array that stores the values to be added.
updation_values=[0.2,0.2,0.4, 0.5, 0.4]
Usually I update the array as
for update_value, index in zip(updation_values, indices):
original_array[index]+=update_value
Is there a better way of doing it apart from loops?
original_array[indices]+=updation_values
does not seem to work as it only does the updation of the last instance of each unique index.