ListTools
InversePermutation
compute the inverse of a permutation
Unpermute
apply the inverse of a permutation to a permuted list
Calling Sequence
Parameters
Description
Examples
Compatibility
InversePermutation( Permutation )
Unpermute( Data, Permutation )
Permutation
-
list that is a permutation of the positive integers up to n for some nonnegative integer n
Data
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.
with⁡ListTools:
Example 1
P≔3,8,9,5,1,7,2,10,4,6
Q≔InversePermutation⁡P
Q≔5,7,1,9,4,10,6,2,3,8
PQ
1,2,3,4,5,6,7,8,9,10
QP
Example 2
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
B,P≔a,b,c,d,e,3,4,2,5,1
The Unpermute returns the original, unsorted list:
Unpermute⁡B,P
e,c,a,b,d
Example 3
X≔Array⁡0..2,5,10,15
P≔2,3,1
Q≔3,1,2
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.
See Also
Perm
sort
Download Help Document