Permutation Lists
A possible way of working with permutations is by relating them to the reorderings of the elements of a list. This is the standard point of view in the combinatorial approach to permutations, which shifts the emphasis to the permuted expressions, rather than the permutations themselves. This has always been an implicit interpretation of permutation lists in the Wolfram Language, reorderings of Range[n] for some non-negative integer n. Several standard functions in the Wolfram Language allow basic manipulation of permutation lists, and now other functions have been added to work with permutation lists and convert them into their disjoint cyclic form.
PermutationListQ | validate a list of integers as reordering of {1,…,n} |
PermutationSupport | points moved by a permutation |
Permutation lists can be converted into disjoint cyclic form and vice versa. This is similar to the functions ToCycles and FromCycles in the Combinatorica package in improved form.
PermutationCycles | convert permutation into disjoint cyclic form |
PermutationList | convert permutation into a permutation list |
Permutation lists can be used to permute the parts of an expression with the functions Part and Permute. There are two differences: First, depending on the length of the permutation list, Part may change the number of arguments of the expression, but Permute never changes it. Second, Part and Permute interpret the permutation in different ways.
Part |
return a subexpression, possibly reordering its elements
|
Permute | permute elements of an expression as given by a permutation |
FindPermutation | compute the permutation that takes the first list to the second |
Permute reorders the elements, changing their positions: the first element goes to fourth place etc. The number of elements does not change:
Part extracts a subexpression, possibly changing the length of the result. In order to obtain an equivalent result the permutation list needs to be inverted:
Permute also accepts cyclic notation in its second argument:
It is possible to perform permutation operations with permutation lists, using standard commands of the Wolfram Language.
Part | permutation list product |
Ordering | permutation list inverse |
Range | identity permutation list |
RandomSample | pseudorandom generation of permutation lists |
The same result can be obtained with Part reversing the order of arguments:
The identity permutation list of any length can be expressed with Range:
Another important use of permutation lists is the transposition of arrays with Transpose, which results in a generally different array of permuted dimensions.