Regina Calculation Engine
|
Represents a permutation of {0,1,2,3,4}. More...
#include <maths/spec/perm5.h>
Public Types | |
typedef int | Index |
Denotes a native signed integer type large enough to count all permutations on five elements. More... | |
typedef uint16_t | Code |
Indicates the native unsigned integer type used to store the internal permutation code. More... | |
Public Member Functions | |
Perm () | |
Creates the identity permutation. More... | |
Perm (int a, int b) | |
Creates the transposition of a and b. More... | |
Perm (int a, int b, int c, int d, int e) | |
Creates a permutation mapping (0,1,2,3,4) to (a,b,c,d,e) respectively. More... | |
Perm (const int *image) | |
Creates a permutation mapping i to image[i] for each i = 0,1,2,3,4. More... | |
Perm (const int *a, const int *b) | |
Creates a permutation mapping (a[0], ..., a[4]) to (b[0], ..., b[4]) respectively. More... | |
Perm (int a0, int a1, int b0, int b1, int c0, int c1, int d0, int d1, int e0, int e1) | |
Creates a permutation mapping (a0,b0,c0,d0,e0) to (a1,b1,c1,d1,e1) respectively. More... | |
Perm (const Perm< 5 > &cloneMe)=default | |
Creates a permutation that is a clone of the given permutation. More... | |
Code | permCode () const |
Returns the internal code representing this permutation. More... | |
void | setPermCode (Code newCode) |
Sets this permutation to that represented by the given internal code. More... | |
Perm< 5 > & | operator= (const Perm< 5 > &cloneMe)=default |
Sets this permutation to be equal to the given permutation. More... | |
Perm< 5 > | operator* (const Perm< 5 > &q) const |
Returns the composition of this permutation with the given permutation. More... | |
Perm< 5 > | inverse () const |
Finds the inverse of this permutation. More... | |
Perm< 5 > | reverse () const |
Finds the reverse of this permutation. More... | |
int | sign () const |
Determines the sign of this permutation. More... | |
REGINA_INLINE_REQUIRED int | operator[] (int source) const |
Determines the image of the given integer under this permutation. More... | |
int | preImageOf (int image) const |
Determines the preimage of the given integer under this permutation. More... | |
bool | operator== (const Perm< 5 > &other) const |
Determines if this is equal to the given permutation. More... | |
bool | operator!= (const Perm< 5 > &other) const |
Determines if this differs from the given permutation. More... | |
int | compareWith (const Perm< 5 > &other) const |
Lexicographically compares the images of (0,1,2,3,4) under this and the given permutation. More... | |
bool | isIdentity () const |
Determines if this is the identity permutation. More... | |
Index | index () const |
Returns the lexicographical index of this permutation. More... | |
std::string | str () const |
Returns a string representation of this permutation. More... | |
std::string | trunc (unsigned len) const |
Returns a prefix of the string representation of this permutation, containing only the images of the first len integers. More... | |
std::string | trunc2 () const |
Returns a string representation of this permutation with only the images of 0 and 1. More... | |
std::string | trunc3 () const |
Returns a string representation of this permutation with only the images of 0, 1 and 2. More... | |
std::string | trunc4 () const |
Returns a string representation of this permutation with only the images of 0, 1, 2 and 3. More... | |
void | clear (unsigned from) |
Resets the images of all integers from from onwards to the identity map. More... | |
int | S5Index () const |
Returns the index of this permutation in the Perm<5>::S5 array. More... | |
int | SnIndex () const |
Returns the index of this permutation in the Perm<5>::S5 array. More... | |
int | orderedS5Index () const |
Returns the index of this permutation in the Perm<5>::orderedS5 array. More... | |
int | orderedSnIndex () const |
Returns the index of this permutation in the Perm<5>::orderedS5 array. More... | |
Static Public Member Functions | |
static Perm< 5 > | fromPermCode (Code newCode) |
Creates a permutation from the given internal code. More... | |
static bool | isPermCode (Code newCode) |
Determines whether the given integer is a valid internal permutation code. More... | |
static Perm | atIndex (Index i) |
Returns the ith permutation on five elements, where permutations are numbered lexicographically beginning at 0. More... | |
static Perm | rand (bool even=false) |
Returns a random permutation on five elements. More... | |
template<int k> | |
static Perm< 5 > | extend (Perm< k > p) |
Extends a k-element permutation to a 5-element permutation, where 2 ≤ k < 5. More... | |
template<int k> | |
static Perm< 5 > | contract (Perm< k > p) |
Restricts a k-element permutation to an 5-element permutation, where k > 5. More... | |
Static Public Attributes | |
static const Index | nPerms = 120 |
The total number of permutations on five elements. More... | |
static const Index | nPerms_1 = 24 |
The total number of permutations on four elements. More... | |
static const int | imageBits = 3 |
Indicates the number of bits used by the permutation code to store the image of a single integer. More... | |
static const Perm< 5 > | S5 [120] |
Contains all possible permutations of five elements. More... | |
static const Perm< 5 > * | Sn |
A dimension-agnostic alias for Perm<5>::S5. More... | |
static const Perm< 5 > | orderedS5 [120] |
Contains all possible permutations of five elements in lexicographical order. More... | |
static const Perm< 5 > * | orderedSn |
A dimension-agnostic alias for Perm<5>::orderedS5. More... | |
static const unsigned | invS5 [120] |
Contains the inverses of the permutations in the array S5. More... | |
static const unsigned * | invSn |
A dimension-agnostic alias for Perm<5>::invS5. More... | |
static const Perm< 5 > | S4 [24] |
Contains all possible permutations of four elements. More... | |
static const Perm< 5 > * | Sn_1 |
A dimension-agnostic alias for Perm<5>::S4. More... | |
static const Perm< 5 > | orderedS4 [24] |
Contains all possible permutations of four elements in lexicographical order. More... | |
static const Perm< 5 > | S3 [6] |
Contains all possible permutations of three elements. More... | |
static const Perm< 5 > | orderedS3 [6] |
Contains all possible permutations of three elements in lexicographical order. More... | |
static const Perm< 5 > | S2 [2] |
Contains all possible permutations of two elements. More... | |
Represents a permutation of {0,1,2,3,4}.
This is a specialisation of the generic Perm template: it is highly optimised, and also offers some additional functionality. Amongst other things, this permutation class is used to specify how simplices of a 4-manifold triangulation are glued together.
As with all Perm template classes, these objects are small enough to pass about by value instead of by reference.
Each permutation has an internal code, which is a single native integer that is sufficient to reconstruct the permutation. Thus the internal code may be a useful means for passing permutation objects to and from the engine. For Perm<5>, the internal code follows the general scheme used for Perm<n>: the lowest three bits represent the image of 0, the next lowest three bits represent the image of 1 and so on. See the generic Perm template for further details.
To use this class, simply include the main permutation header maths/perm.h.