InversePermutation - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

Calling Sequence

InversePermutation( Permutation )

Unpermute( Data, Permutation )

Parameters

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

Description

• 

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.

Examples

withListTools:

Example 1

P3,8,9,5,1,7,2,10,4,6

P3,8,9,5,1,7,2,10,4,6

(1)

QInversePermutationP

Q5,7,1,9,4,10,6,2,3,8

(2)

PQ

1,2,3,4,5,6,7,8,9,10

(3)

QP

1,2,3,4,5,6,7,8,9,10

(4)

Example 2

• 

First, consider this unsorted list:

Ae,c,a,b,d

Ae,c,a,b,d

(5)
• 

Now, sort the list and record the sorting permutation:

B,PsortA,output=sorted,permutation

B,Pa,b,c,d,e,3,4,2,5,1

(6)
• 

The Unpermute returns the original, unsorted list:

UnpermuteB,P

e,c,a,b,d

(7)

Example 3

XArray0..2,5,10,15

P2,3,1

P2,3,1

(8)

QInversePermutationP

Q3,1,2

(9)

YUnpermuteX,P

Compatibility

• 

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

ListTools

Perm

sort