python - ufunc.at for cases where target indices are unique (buffered call possible then) -


i use ufunc.at similar sparse matrix multiplication or better, flow in graph. c[:, 0] denotes target index each element denoted source index c[:, 1] summed up

c = np.array([[0, 1], [0, 2], [1, 1]) # sum 1 , 2 0, , 1 1 src = ... # source vector targ = ... # target vector, not 0 in beginning np.add.at(targ, c[:, 0], src[c[:, 1]]) # sum bins 

one write:

targ[c[:, 0]] += src[c[:, 1]] 

that approach work if target indices c[:, 0] unique, else there sort of race conditions. expect, bit faster because not need care accumulation internally, can 'one shot' addition, way more efficient when comes vectorization. numpy calls buffered/unbuffered operation.

is there similar syntax buffered version unique target indices? (basically convenience , more consistently looking code.)


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -