Click or drag to resize

PermutationParse Method

Converts a text representation into a permutation.

Namespace:  Meta.Numerics.Functions
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 4.1.4
Syntax
public static Permutation Parse(
	string text
)

Parameters

text
Type: SystemString
A text representation of the permutation.

Return Value

Type: Permutation
The corresponding permutation.
Exceptions
ExceptionCondition
ArgumentNullExceptiontext is null.
FormatExceptiontext is not a valid text representation of a permutation.
Remarks

This method is able to parse both map representations and cycle representations of permutations.

A map representation of an n-dimensional permutation is a space-separated list of all integers between 0 and n-1 (inclusive), enclosed in square brackets. The number at (zero-based) position k indicates the index of the position to which the object which was originally at position k is mapped by the permutation. For example, [2 1 0] denotes the permutation that moves the object at index 0 to index 2, leaves the object at index 1 at index 1, and moves the object at index 2 to index 0. Therefore the numbers in the map representation are the same as the numbers on the second line of Cauchy's two-line notation.

A cycle representation of an n-dimensional representation is a space-separated list of all integers between 0 and n-1 (inclusive), grouped into cycles by non-nested parenthesis. Each cycle indicates that the element at the location with the first index in the cycle is moved to the location with the second index in the cycle, the element at the location with the second index in the cycle is moved to the location with the third index in the cycle, and so on, until the element at the location with the last index is moved to the location with the first index. Thus (0 2)(1) indicates that the elements at locations 0 and 2 change places and the element at location 1 is left alone. So (0 2)(1) and [2 1 0] represent the same permutation.

Both map and cycle notation are in common use and each makes manifest different aspects of a permutation.

See Also