inverse_permutation

  • full name: tenpy.tools.misc.inverse_permutation

  • parent module: tenpy.tools.misc

  • type: function

tenpy.tools.misc.inverse_permutation(perm)[source]

reverse sorting indices.

Sort functions (as LegCharge.sort()) return a (1D) permutation perm array, such that sorted_array = old_array[perm]. This function inverts the permutation perm, such that old_array = sorted_array[inverse_permutation(perm)].

Parameters:

perm (1D array_like) – The permutation to be reversed. Assumes that it is a permutation with unique indices. If it is, inverse_permutation(inverse_permutation(perm)) == perm.

Returns:

inv_perm – The inverse permutation of perm such that inv_perm[perm[j]] = j = perm[inv_perm[j]].

Return type:

1D array (int)