I have an array farr, size Nx*Nx.
I have a function frk that maps index {n,m} to an integer (approximately Floor[Norm[{n,m}]])
I want to Bin all the elements in the array, according to their index and that function, and then sum them.
I am using this, but it is far too slow:
res = ConstantArray[0, 3*Nx]; Do[res[[frk[n,m,Nx] + 1]] += farr[[n, m]], {m, Nx}, {n, Nx}]; Any ideas?.. GatherBy seems almost right, but it cares about values, not indexes
frkdo? $\endgroup$frkinformally as using two arguments and then calls it with three. $\endgroup$