compute the inverse of a permutation
apply the inverse of a permutation to a permuted list
InversePermutation( Permutation )
Unpermute( Data, Permutation )
list that is a permutation of the positive integers up to n for some nonnegative integer n
list having the same number of elements as Permutation
The InversePermutation command takes a permutation list P, and computes the inverse Q. More precisely, if P is a permutation of the positive integers up to nonnegative integer n, then P[Q]=N and Q[P]=N, where N=[1,..,n].
The Unpermute command takes a list B and a permutation list P of the same size as B, and applies the inverse permutation to B. That is, if Q is the inverse of P, then the command returns B[Q]. Note that A=B[Q] satisfies A[P]=B.
The commands also accept Vectors and 1-D Arrays. If an Array or Vector is passed for Permutation, the inverse is computed as a list. Moreover, if Data is an Array with first index different than 1, then the inverse permutation is performed as if Data is an Array with first index 1, but the dimensions of the result will match the original.
P ≔ 3,8,9,5,1,7,2,10,4,6
Q ≔ InversePermutation⁡P
First, consider this unsorted list:
A ≔ e,c,a,b,d
Now, sort the list and record the sorting permutation:
B,P ≔ sort⁡A,'output'='sorted','permutation'
The Unpermute returns the original, unsorted list:
X ≔ Array⁡0..2,5,10,15
P ≔ 2,3,1
Y ≔ Unpermute⁡X,P
The ListTools[InversePermutation] and ListTools[Unpermute] commands were introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
Download Help Document