the following sourcecode produces a memoryerror on my machine:
import numpy as np
x = np.random.random([100,100,100])
y = np.random.random([100,100,100])
c_sort = np.argsort(x, axis = 2)
f = y[c_sort]
Do you have a nice and easy idea how to avoid the memory error?
The other way to do this is
x = np.random.random([100,100,100])
y = np.random.random([100,100,100])
f = np.zeros([100,100,100])
for i in range(100):
for j in range(100):
f[i,j,:] = y[i,j, np.argsort(x[i,j,:])]
But I wonder why the solutions above does not lead to the same result?