are there any numpy function or clever use of views to accomplish what the following function do?
import numpy as np
def permuteIndexes(array, perm):
newarray = np.empty_like(array)
max_i, max_j = newarray.shape
for i in xrange(max_i):
for j in xrange(max_j):
newarray[i,j] = array[perm[i], perm[j]]
return newarray
That is, for a given permutation of the indexes of the matrix in a list perm
, this function calculates the result of applying this permutation to the indexes of a matrix.