regina::Perm< 4 > Class Template Reference
Mathematical Support

Represents a permutation of {0,1,2,3}. More...

`#include <maths/spec/perm4.h>`

## Public Types

typedef int | Index
| Denotes a native signed integer type large enough to count all permutations on four elements. More...
typedef uint8_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)
| Creates a permutation mapping (0,1,2,3) to (a,b,c,d) respectively. More...
| Perm (const int *image)
| Creates a permutation mapping i to image[i] for each i = 0,1,2,3. More...
| Perm (const int *a, const int *b)
| Creates a permutation mapping (a[0], ..., a[3]) to (b[0], ..., b[3]) respectively. More...
| Perm (int a0, int a1, int b0, int b1, int c0, int c1, int d0, int d1)
| Creates a permutation mapping (a0,b0,c0,d0) to (a1,b1,c1,d1) respectively. More...
| Perm (const Perm< 4 > &cloneMe)
| Creates a permutation that is a clone of the given permutation. More...
Code | permCode () const
| Returns the first-generation code representing this permutation. More...
Code | permCode2 () const
| Returns the second-generation code representing this permutation. More...
void | setPermCode (Code code)
| Sets this permutation to that represented by the given first-generation permutation code. More...
void | setPermCode2 (Code code)
| Sets this permutation to that represented by the given second-generation permutation code. More...
Perm< 4 > & | operator= (const Perm< 4 > &cloneMe)
| Sets this permutation to be equal to the given permutation. More...
Perm< 4 > | operator* (const Perm< 4 > &q) const
| Returns the composition of this permutation with the given permutation. More...
Perm< 4 > | inverse () const
| Finds the inverse of this permutation. More...
Perm< 4 > | reverse () const
| Finds the reverse of this permutation. More...
int | sign () const
| Determines the sign of this permutation. More...
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< 4 > &other) const
| Determines if this is equal to the given permutation. More...
bool | operator!= (const Perm< 4 > &other) const
| Determines if this differs from the given permutation. More...
int | compareWith (const Perm< 4 > &other) const
| Lexicographically compares the images of (0,1,2,3) 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 included. More...
void | clear (unsigned from)
| Resets the images of all integers from from onwards to the identity map. More...
int | S4Index () const
| Returns the index of this permutation in the Perm<4>::S4 array. More...
int | SnIndex () const
| Returns the index of this permutation in the Perm<4>::S4 array. More...
REGINA_INLINE_REQUIRED int | orderedS4Index () const
| Returns the index of this permutation in the Perm<4>::orderedS4 array. More...
int | orderedSnIndex () const
| Returns the index of this permutation in the Perm<4>::orderedS4 array. More...

## Static Public Member Functions

static Perm< 4 > | fromPermCode (Code code)
| Creates a permutation from the given first-generation permutation code. More...
static Perm< 4 > | fromPermCode2 (Code code)
| Creates a permutation from the given second-generation permutation code. More...
static bool | isPermCode (Code code)
| Determines whether the given character is a valid first-generation permutation code. More...
static bool | isPermCode2 (Code code)
| Determines whether the given character is a valid second-generation permutation code. More...
static Perm | atIndex (Index i)
| Returns the ith permutation on four elements, where permutations are numbered lexicographically beginning at 0. More...
static Perm | rand ()
| Returns a random permutation on four elements. More...
template<int k>
static Perm< 4 > | extend (Perm< k > p)
| Extends a k-element permutation to a 4-element permutation, where 2 ≤ k < 4. More...
template<int k>
static Perm< 4 > | contract (Perm< k > p)
| Restricts a k-element permutation to an 4-element permutation, where k > 4. More...

## Static Public Attributes

static const Index | nPerms = 24
| The total number of permutations on four elements. More...
static const Index | nPerms_1 = 6
| The total number of permutations on three elements. More...
static const Perm< 4 > | S4 [24]
| Contains all possible permutations of four elements. More...
static const Perm< 4 > * | Sn
| A dimension-agnostic alias for Perm<4>::S4. More...
static const unsigned | invS4 [24]
| Contains the inverses of the permutations in the array S4. More...
static const unsigned * | invSn
| A dimension-agnostic alias for Perm<4>::invS4. More...
static const Perm< 4 > | orderedS4 [24]
| Contains all possible permutations of four elements in lexicographical order. More...
static const Perm< 4 > * | orderedSn
| A dimension-agnostic alias for Perm<4>::orderedS4. More...
static const Perm< 4 > | S3 [6]
| Contains all possible permutations of three elements. More...
static const Perm< 4 > * | Sn_1
| A dimension-agnostic alias for Perm<4>::S3. More...
static const Perm< 4 > | orderedS3 [6]
| Contains all possible permutations of three elements in lexicographical order. More...
static const Perm< 4 > | S2 [2]
| Contains all possible permutations of two elements. More...

## Detailed Description

### template<>
class regina::Perm< 4 >

Represents a permutation of {0,1,2,3}.

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 3-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. Moreover, Perm<4> is extremely fast to work with.

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<4>, the internal permutation codes have changed as of Regina 4.6.1:

- First-generation codes were used internally in Regina 4.6 and earlier. These codes were characters whose lowest two bits represented the image of 0, whose next lowest two bits represented the image of 1, and so on. The routines permCode(), setPermCode(), fromPermCode() and isPermCode() continue to work with first-generation codes for backward compatibility. Likewise, the XML data file format continues to use first-generation codes to describe tetrahedron gluings.
- Second-generation codes are used internally in Regina 4.6.1 and above. These codes are integers between 0 and 23 inclusive, representing the index of the permutation in the array Perm<4>::S4. The routines permCode2(), setPermCode2(), fromPermCode2() and isPermCode2() work with second-generation codes.

It is highly recommended that, if you need to work with permutation codes at all, you use second-generation codes where possible. This is because the first-generation routines incur additional overhead in converting back and forth between the second-generation codes (which are used internally by Perm<4>).

To use this class, simply include the main permutation header maths/perm.h.

Python:\n Since Python does not support templates, this class is
  made available under the name Perm4.

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

- maths/spec/perm4.h

Copyright © 1999-2016, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).