IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Represents a permutation. More...
Public Member Functions | |
override string | ToString () |
string | ToString (string format) |
Converts the permutation to its string representation in the given format. More... | |
string | ToString (string format, IFormatProvider formatProvider) |
Converts the permutation to its string representation in the given format. More... | |
void | Apply< T > (IList< T > x) |
Applies the permutation to a list. More... | |
Permutation | Inverse () |
Gets the inverse of the permutation. More... | |
bool | Equals (Permutation other) |
Determines whether the given permutation is equal to the permutation instance. More... | |
override bool | Equals (object obj) |
Determines whether the given object is equal to the permutation. More... | |
override int | GetHashCode () |
Static Public Member Functions | |
static Permutation | Parse (string text) |
Converts a text representation into a permutation. More... | |
static bool | TryParse (string text, out Permutation output) |
Attempts to convert a text representation into a permutation. More... | |
static Permutation | operator* (Permutation a, Permutation b) |
Multiplies two permutations. More... | |
static IEnumerable< Permutation > | Permutations (int dimension) |
Generates all permutations of the given dimension. More... | |
static Permutation | Identity (int dimension) |
Returns the identity permutation of the given dimension. More... | |
static bool | operator== (Permutation a, Permutation b) |
Determines whether two permutations are equal. More... | |
static bool | operator!= (Permutation a, Permutation b) |
Determines whether two permutations are not equal. More... | |
static Permutation | GetRandomPermutation (int dimension, Random rng) |
Get a random permutation. More... | |
Properties | |
int | Dimension [get] |
Gets the dimension of the permutation. More... | |
bool | IsEven [get] |
Gets a Boolean value that is true if the permutation is even and false if the permutation is odd. More... | |
long | Order [get] |
Gets the order of the permutation. More... | |
bool | IsIdentity [get] |
Gets a Boolean value indicating whether the permutation is the identity. More... | |
bool | IsDerangement [get] |
Gets a Boolean flag indicating whether the permutation is a derangement. More... | |
bool | IsInvolution [get] |
Gets a Boolean flag indicating whether the permutation is an involution. More... | |
Private Member Functions | |
string | ToStringAsMap () |
string | ToStringAsCycles () |
void | ComputeCycles () |
void | ComputeMap () |
Static Private Member Functions | |
static int[][] | FromMapToCycles (int[] map) |
static int[] | FromCyclesToMap (int[][] cycles) |
static int | FindLargestMobile (int[] values, bool[] directions) |
static bool | InstanceEquals (Permutation a, Permutation b) |
Private Attributes | |
PermutationAsMap | map |
PermutationAsCycles | cycles |
Represents a permutation.
|
inlineprivate |
|
inlineprivate |
|
inline |
Referenced by Test.PermutationTest.PermutationFormat(), and Test.PermutationTest.PermutationOrder().
|
inline |
Converts the permutation to its string representation in the given format.
format | A standard or custom permutation format string. |
The standard permutation format strings are "M", which produces a map representation, and "C", which produces a cycle representation.
|
inline |
Converts the permutation to its string representation in the given format.
format | A standard or custom permutation format string. |
formatProvider | An object that provides culture-specific formatting information. |
The standard permutation format strings are "M", which produces a map representation, and "C", which produces a cycle representation.
|
inlinestatic |
Converts a text representation into a permutation.
text | The text representation of the permutation. |
ArgumentNullException | text is null. |
FormatException | text is not a valid text representation of a permutation. |
Referenced by Test.PermutationTest.GenerateGroups(), Test.PermutationTest.PermutationEquality(), and Test.PermutationTest.PermutationFormat().
|
inlinestatic |
Attempts to convert a text representation into a permutation.
text | The text representaiton of the permutation. |
output | The corresponding permutation. |
|
inlinestaticprivate |
|
inlinestaticprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Applies the permutation to a list.
T | The type of the list. |
x | The list. |
|
inline |
Gets the inverse of the permutation.
Referenced by Test.PermutationTest.PermutationInverse().
|
inlinestatic |
Multiplies two permutations.
a | The first permutation. |
b | The second permutation. |
The product ab means first applying b, then applying a. This right-to-left convention arises from the convention that operators are applied to the right.
References Meta.Numerics.Functions.Permutation.ComputeMap(), Meta.Numerics.Functions.Permutation.Dimension, and Meta.Numerics.Functions.Permutation.map.
|
inlinestatic |
Generates all permutations of the given dimension.
dimension | The number of elements on which the permutations act. |
See http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm and Knuth 7.2.1.2.
Referenced by Test.PermutationTest.PermutationCount(), and Test.PermutationTest.PermutationDistribution().
|
inlinestaticprivate |
|
inlinestatic |
Returns the identity permutation of the given dimension.
dimension | The number of elements on which the permutation acts. |
Referenced by Test.PermutationTest.GenerateGroup().
|
inlinestaticprivate |
|
inlinestatic |
Determines whether two permutations are equal.
a | The first permutation. |
b | The second permutation. |
|
inlinestatic |
Determines whether two permutations are not equal.
a | The first permutation. |
b | The second permutation. |
|
inline |
Determines whether the given permutation is equal to the permutation instance.
other | The permutation to compare. |
Referenced by Test.PermutationTest.PermutationEquality().
|
inline |
Determines whether the given object is equal to the permutation.
obj | The object to compare. |
|
inline |
Referenced by Test.PermutationTest.PermutationEquality().
|
inlinestatic |
Get a random permutation.
dimension | The number of elements on which the permutation acts. |
rng | A random number generator. |
Referenced by Test.PermutationTest.PermutationDistribution(), Test.PermutationTest.PermutationFormat(), Test.PermutationTest.PermutationInverse(), Test.PermutationTest.PermutationOrder(), and Test.PermutationTest.PermutationProduct().
|
private |
|
private |
|
get |
Gets the dimension of the permutation.
The dimension of a permutation is the number of elements to which the permutation applies.
Referenced by Meta.Numerics.Functions.Permutation.InstanceEquals(), and Meta.Numerics.Functions.Permutation.operator*().
|
get |
Gets a Boolean value that is true if the permutation is even and false if the permutation is odd.
An even permutation moves an even number of elements; an odd permutation moves an odd number of elements.
Referenced by Test.PermutationTest.PermutationCount().
|
get |
Gets the order of the permutation.
The order of a permutation is the number of times it must be applied in order to return all elements to their original position. Stated differently, the order of a permutation is the smallest power to which it must be raised to obtain the identity permutation.
Some permutations with dimension greater than about 300 have an order larger than Int64.MaxValue; for these permutations the returned value will overflow.
Note that the word order is also used to refer to the number of distinct permutations of a given dimension. That "order" is a property of the permutation group. This "order" is a property of each permutation.
Referenced by Test.PermutationTest.PermutationOrder().
|
get |
Gets a Boolean value indicating whether the permutation is the identity.
True if the permutation is the identity, otherwise false.
The identity permutation is the permutation that leaves all elements in their original positions.
Referenced by Test.PermutationTest.PermutationOrder().
|
get |
Gets a Boolean flag indicating whether the permutation is a derangement.
True if the permutation is a derangement, otherwise false.
A derangement is a permutation that leaves no element in its original position.
Referenced by Test.PermutationTest.PermutationCount().
|
get |
Gets a Boolean flag indicating whether the permutation is an involution.
True if the permutation is an involution, otherwise false.
An involution is a permutation that is its own inverse.