More generic prototype + mex to get the permutation only.