IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Meta.Numerics.Functions.Permutation Class Reference

Represents a permutation. More...

+ Inheritance diagram for Meta.Numerics.Functions.Permutation:
+ Collaboration diagram for Meta.Numerics.Functions.Permutation:

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< PermutationPermutations (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
 

Detailed Description

Represents a permutation.

Member Function Documentation

string Meta.Numerics.Functions.Permutation.ToStringAsMap ( )
inlineprivate
string Meta.Numerics.Functions.Permutation.ToStringAsCycles ( )
inlineprivate
override string Meta.Numerics.Functions.Permutation.ToString ( )
inline
string Meta.Numerics.Functions.Permutation.ToString ( string  format)
inline

Converts the permutation to its string representation in the given format.

Parameters
formatA standard or custom permutation format string.
Returns
The requested string representation of the permutation.

The standard permutation format strings are "M", which produces a map representation, and "C", which produces a cycle representation.

string Meta.Numerics.Functions.Permutation.ToString ( string  format,
IFormatProvider  formatProvider 
)
inline

Converts the permutation to its string representation in the given format.

Parameters
formatA standard or custom permutation format string.
formatProviderAn object that provides culture-specific formatting information.
Returns
The requested string represenation of the permutation.

The standard permutation format strings are "M", which produces a map representation, and "C", which produces a cycle representation.

static Permutation Meta.Numerics.Functions.Permutation.Parse ( string  text)
inlinestatic

Converts a text representation into a permutation.

Parameters
textThe text representation of the permutation.
Returns
The corresponding permutation.
Exceptions
ArgumentNullExceptiontext is null.
FormatExceptiontext is not a valid text representation of a permutation.

Referenced by Test.PermutationTest.GenerateGroups(), Test.PermutationTest.PermutationEquality(), and Test.PermutationTest.PermutationFormat().

static bool Meta.Numerics.Functions.Permutation.TryParse ( string  text,
out Permutation  output 
)
inlinestatic

Attempts to convert a text representation into a permutation.

Parameters
textThe text representaiton of the permutation.
outputThe corresponding permutation.
Returns
True if the conversion succeeded, otherwise false.
static int [][] Meta.Numerics.Functions.Permutation.FromMapToCycles ( int[]  map)
inlinestaticprivate
static int [] Meta.Numerics.Functions.Permutation.FromCyclesToMap ( int  cycles[][])
inlinestaticprivate
void Meta.Numerics.Functions.Permutation.ComputeCycles ( )
inlineprivate
void Meta.Numerics.Functions.Permutation.ComputeMap ( )
inlineprivate
void Meta.Numerics.Functions.Permutation.Apply< T > ( IList< T >  x)
inline

Applies the permutation to a list.

Template Parameters
TThe type of the list.
Parameters
xThe list.
Permutation Meta.Numerics.Functions.Permutation.Inverse ( )
inline

Gets the inverse of the permutation.

Returns
The inverse of the permutation.

Referenced by Test.PermutationTest.PermutationInverse().

static Permutation Meta.Numerics.Functions.Permutation.operator* ( Permutation  a,
Permutation  b 
)
inlinestatic

Multiplies two permutations.

Parameters
aThe first permutation.
bThe second permutation.
Returns
The product permutation ab.

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.

static IEnumerable<Permutation> Meta.Numerics.Functions.Permutation.Permutations ( int  dimension)
inlinestatic
static int Meta.Numerics.Functions.Permutation.FindLargestMobile ( int[]  values,
bool[]  directions 
)
inlinestaticprivate
static Permutation Meta.Numerics.Functions.Permutation.Identity ( int  dimension)
inlinestatic

Returns the identity permutation of the given dimension.

Parameters
dimensionThe number of elements on which the permutation acts.
Returns
The identity permutation of the requested dimension.

Referenced by Test.PermutationTest.GenerateGroup().

static bool Meta.Numerics.Functions.Permutation.InstanceEquals ( Permutation  a,
Permutation  b 
)
inlinestaticprivate
static bool Meta.Numerics.Functions.Permutation.operator== ( Permutation  a,
Permutation  b 
)
inlinestatic

Determines whether two permutations are equal.

Parameters
aThe first permutation.
bThe second permutation.
Returns
True if the two permutations are equal, otherwise false.
static bool Meta.Numerics.Functions.Permutation.operator!= ( Permutation  a,
Permutation  b 
)
inlinestatic

Determines whether two permutations are not equal.

Parameters
aThe first permutation.
bThe second permutation.
Returns
True if the two permutations are not equal, otherwise true.
bool Meta.Numerics.Functions.Permutation.Equals ( Permutation  other)
inline

Determines whether the given permutation is equal to the permutation instance.

Parameters
otherThe permutation to compare.
Returns
True if other equals the permutation instance, otherwise false.

Referenced by Test.PermutationTest.PermutationEquality().

override bool Meta.Numerics.Functions.Permutation.Equals ( object  obj)
inline

Determines whether the given object is equal to the permutation.

Parameters
objThe object to compare.
Returns
True if obj is a permutation equal to the permutation instance, otherwise false.
override int Meta.Numerics.Functions.Permutation.GetHashCode ( )
inline
static Permutation Meta.Numerics.Functions.Permutation.GetRandomPermutation ( int  dimension,
Random  rng 
)
inlinestatic

Get a random permutation.

Parameters
dimensionThe number of elements on which the permutation acts.
rngA random number generator.
Returns
A random permutation of the specified dimension. All permutations of the specified dimension are equally likely.

Referenced by Test.PermutationTest.PermutationDistribution(), Test.PermutationTest.PermutationFormat(), Test.PermutationTest.PermutationInverse(), Test.PermutationTest.PermutationOrder(), and Test.PermutationTest.PermutationProduct().

Member Data Documentation

PermutationAsMap Meta.Numerics.Functions.Permutation.map
private
PermutationAsCycles Meta.Numerics.Functions.Permutation.cycles
private

Property Documentation

int Meta.Numerics.Functions.Permutation.Dimension
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*().

bool Meta.Numerics.Functions.Permutation.IsEven
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().

long Meta.Numerics.Functions.Permutation.Order
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().

bool Meta.Numerics.Functions.Permutation.IsIdentity
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().

bool Meta.Numerics.Functions.Permutation.IsDerangement
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().

bool Meta.Numerics.Functions.Permutation.IsInvolution
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.


The documentation for this class was generated from the following file: