Regina 7.4.1 Calculation Engine
regina::Perm< 4 > Class Reference

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

#include <maths/spec/perm4.h>

Public Types

using Index = int
 Denotes a native signed integer type large enough to count all permutations on four elements.
 
using ImagePack = uint8_t
 Indicates the native unsigned integer type used to store a single image pack.
 
using Code1 = ImagePack
 Indicates the native unsigned integer type used to store a first-generation permutation code.
 
using Code2 = uint8_t
 Indicates the native unsigned integer type used to store a second-generation permutation code.
 
using Index
 Denotes a native signed integer type large enough to count all permutations on n elements.
 
using ImagePack
 Indicates the native unsigned integer type used to store a single image pack.
 
using Code
 Indicates the native unsigned integer type used to store the internal permutation code.
 

Public Member Functions

constexpr Perm ()
 Creates the identity permutation.
 
constexpr Perm (int a, int b)
 Creates the transposition of a and b.
 
constexpr Perm (int a, int b, int c, int d)
 Creates a permutation mapping (0,1,2,3) to (a,b,c,d) respectively.
 
constexpr Perm (const std::array< int, 4 > &image)
 Creates a permutation mapping i to image[i] for each i = 0,1,2,3.
 
constexpr 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.
 
constexpr Perm (const Perm< 4 > &cloneMe)=default
 Creates a permutation that is a clone of the given permutation.
 
constexpr Code1 permCode1 () const
 Returns the first-generation code representing this permutation.
 
constexpr Code2 permCode2 () const
 Returns the second-generation code representing this permutation.
 
void setPermCode1 (Code1 code)
 Sets this permutation to that represented by the given first-generation permutation code.
 
void setPermCode2 (Code2 code)
 Sets this permutation to that represented by the given second-generation permutation code.
 
constexpr ImagePack imagePack () const
 Returns the image pack that represents this permutation.
 
Perm< 4 > & operator= (const Perm< 4 > &cloneMe)=default
 Sets this permutation to be equal to the given permutation.
 
constexpr Perm< 4 > operator* (const Perm< 4 > &q) const
 Returns the composition of this permutation with the given permutation.
 
Perm< 4 > cachedComp (const Perm< 4 > &q) const
 An alias for the composition operator, provided to assist with writing generic code.
 
Perm< 4 > cachedComp (const Perm< 4 > &q, const Perm< 4 > &r) const
 Deprecated alias for using the composition operator twice, provided to assist with writing generic code.
 
constexpr Perm< 4 > conjugate (const Perm< 4 > &q) const
 Computes the conjugate of this permutation by q.
 
Perm< 4 > cachedConjugate (const Perm< 4 > &q) const
 An alias for conjugate(), provided to assist with writing generic code.
 
constexpr Perm< 4 > inverse () const
 Finds the inverse of this permutation.
 
Perm< 4 > cachedInverse () const
 An alias for inverse(), provided to assist with writing generic code.
 
constexpr Perm< 4 > pow (long exp) const
 Computes the given power of this permutation.
 
Perm< 4 > cachedPow (long exp) const
 An alias for pow(), provided to assist with writing generic code.
 
constexpr int order () const
 Returns the order of this permutation.
 
int cachedOrder () const
 An alias for order(), provided to assist with writing generic code.
 
constexpr Perm< 4 > reverse () const
 Finds the reverse of this permutation.
 
constexpr int sign () const
 Determines the sign of this permutation.
 
constexpr int operator[] (int source) const
 Determines the image of the given integer under this permutation.
 
constexpr int pre (int image) const
 Determines the preimage of the given integer under this permutation.
 
constexpr bool operator== (const Perm &) const =default
 Determines if this is equal to the given permutation.
 
constexpr int compareWith (const Perm< 4 > &other) const
 Lexicographically compares the images of (0,1,2,3) under this and the given permutation.
 
constexpr bool isIdentity () const
 Determines if this is the identity permutation.
 
Perm< 4 > & operator++ ()
 A preincrement operator that changes this to be the next permutation in the array Perm<4>::Sn.
 
constexpr Perm< 4 > operator++ (int)
 A postincrement operator that changes this to be the next permutation in the array Perm<4>::Sn.
 
constexpr std::strong_ordering operator<=> (const Perm &) const =default
 Compares two permutations according to which appears earlier in the array Perm<4>::Sn.
 
std::string str () const
 Returns a string representation of this permutation.
 
std::string trunc (int len) const
 Returns a prefix of the string representation of this permutation, containing only the images of the first len integers.
 
std::string trunc2 () const
 Returns a string representation of this permutation with only the images of 0 and 1.
 
std::string trunc3 () const
 Returns a string representation of this permutation with only the images of 0, 1 and 2 included.
 
void tightEncode (std::ostream &out) const
 Writes the tight encoding of this permutation to the given output stream.
 
std::string tightEncoding () const
 Returns the tight encoding of this permutation.
 
constexpr size_t hash () const
 Hashes this permutation to a non-negative integer, allowing it to be used for keys in hash tables.
 
void clear (unsigned from)
 Resets the images of all integers from from onwards to the identity map.
 
constexpr Index SnIndex () const
 Returns the index of this permutation in the Perm<4>::Sn array.
 
constexpr Index S4Index () const
 Returns the index of this permutation in the Perm<4>::Sn array.
 
constexpr Index orderedSnIndex () const
 Returns the lexicographical index of this permutation.
 
constexpr Index orderedS4Index () const
 Returns the lexicographical index of this permutation.
 
constexpr bool isConjugacyMinimal () const
 Is this permutation minimal in its conjugacy class?
 
constexpr Perm< 6 > pairs () const
 Returns the induced permutation on all six pairs of elements from 0,1,2,3.
 
constexpr Perm ()
 Creates the identity permutation.
 
constexpr Perm (int a, int b)
 Creates the transposition of a and b.
 
constexpr Perm (const std::array< int, n > &image)
 Creates a permutation mapping i to image[i] for each 0 ≤ i < n.
 
constexpr Perm (const Perm &)=default
 Creates a permutation that is a clone of the given permutation.
 
constexpr Code permCode () const
 Returns the internal code representing this permutation.
 
void setPermCode (Code code)
 Sets this permutation to that represented by the given internal code.
 
constexpr ImagePack imagePack () const
 Returns the image pack that represents this permutation.
 
Perm & operator= (const Perm &cloneMe)=default
 Sets this permutation to be equal to the given permutation.
 
constexpr Perm operator* (const Perm &q) const
 Returns the composition of this permutation with the given permutation.
 
Perm cachedComp (const Perm &q) const
 An alias for the composition operator, provided to assist with writing generic code.
 
Perm cachedComp (const Perm &q, const Perm &r) const
 Deprecated alias for using the composition operator twice, provided to assist with writing generic code.
 
constexpr Perm conjugate (const Perm &q) const
 Computes the conjugate of this permutation by q.
 
Perm cachedConjugate (const Perm &q) const
 An alias for conjugate(), provided to assist with writing generic code.
 
constexpr Perm inverse () const
 Finds the inverse of this permutation.
 
Perm cachedInverse () const
 Finds the inverse of this permutation, optimised using precomputed "partial lookup tables".
 
constexpr Perm pow (long exp) const
 Computes the given power of this permutation.
 
Perm cachedPow (long exp) const
 An alias for pow(), provided to assist with writing generic code.
 
constexpr int order () const
 Returns the order of this permutation.
 
int cachedOrder () const
 An alias for order(), provided to assist with writing generic code.
 
constexpr Perm reverse () const
 Finds the reverse of this permutation.
 
constexpr int sign () const
 Determines the sign of this permutation.
 
constexpr int operator[] (int source) const
 Determines the image of the given integer under this permutation.
 
constexpr int pre (int image) const
 Determines the preimage of the given integer under this permutation.
 
constexpr bool operator== (const Perm &) const=default
 Determines if this is equal to the given permutation.
 
constexpr int compareWith (const Perm &other) const
 Lexicographically compares the images of (0,1,...,n-1) under this and the given permutation.
 
constexpr bool isIdentity () const
 Determines if this is the identity permutation.
 
Perm & operator++ ()
 A preincrement operator that changes this to be the next permutation in the array Perm<n>::Sn.
 
Perm operator++ (int)
 A postincrement operator that changes this to be the next permutation in the array Perm<n>::Sn.
 
constexpr std::strong_ordering operator<=> (const Perm &rhs) const
 Compares two permutations according to which appears earlier in the array Perm<n>::Sn.
 
constexpr Index SnIndex () const
 Returns the index of this permutation in the Perm<n>::Sn array.
 
constexpr Index orderedSnIndex () const
 Returns the lexicographical index of this permutation.
 
std::string str () const
 Returns a string representation of this permutation.
 
std::string trunc (int len) const
 Returns a prefix of the string representation of this permutation, containing only the images of the first len integers.
 
void tightEncode (std::ostream &out) const
 Writes the tight encoding of this permutation to the given output stream.
 
std::string tightEncoding () const
 Returns the tight encoding of this permutation.
 
constexpr size_t hash () const
 Hashes this permutation to a non-negative integer, allowing it to be used for keys in hash tables.
 
void clear (unsigned from)
 Resets the images of all integers from from onwards to the identity map.
 
constexpr bool isConjugacyMinimal () const
 Is this permutation minimal in its conjugacy class?
 

Static Public Member Functions

static constexpr void precompute ()
 A do-nothing routine that assists with writing generic code.
 
static constexpr Perm< 4 > fromPermCode1 (Code1 code)
 Creates a permutation from the given first-generation permutation code.
 
static constexpr Perm< 4 > fromPermCode2 (Code2 code)
 Creates a permutation from the given second-generation permutation code.
 
static constexpr bool isPermCode1 (Code1 code)
 Determines whether the given character is a valid first-generation permutation code.
 
static constexpr bool isPermCode2 (Code2 code)
 Determines whether the given character is a valid second-generation permutation code.
 
static constexpr Perm fromImagePack (ImagePack pack)
 Creates a permutation from the given image pack.
 
static constexpr bool isImagePack (ImagePack pack)
 Determines whether the given argument is the image pack of some 4-element permutation.
 
static constexpr Perm rot (int i)
 Returns the ith rotation.
 
static Perm rand (bool even=false)
 Returns a random permutation on four elements.
 
template<class URBG>
static Perm rand (URBG &&gen, bool even=false)
 Returns a random permutation on four elements, using the given uniform random bit generator.
 
static Perm tightDecoding (const std::string &enc)
 Reconstructs a permutation from its given tight encoding.
 
static Perm tightDecode (std::istream &input)
 Reconstructs a permutation from its given tight encoding.
 
template<int k>
static constexpr Perm< 4 > extend (Perm< k > p)
 Extends a k-element permutation to a 4-element permutation, where 2 ≤ k < 4.
 
template<int k>
static constexpr Perm< 4 > contract (Perm< k > p)
 Restricts a k-element permutation to an 4-element permutation, where k > 4.
 
static void precompute ()
 Performs the precomputation necessary for using the optimised cachedInverse() routine.
 
static constexpr Perm fromPermCode (Code code)
 Creates a permutation from the given internal code.
 
static constexpr bool isPermCode (Code code)
 Determines whether the given integer is a valid internal permutation code.
 
static constexpr Perm fromImagePack (ImagePack pack)
 Creates a permutation from the given image pack.
 
static constexpr bool isImagePack (ImagePack pack)
 Determines whether the given argument is the image pack of some n-element permutation.
 
static constexpr Perm rot (int i)
 Returns the ith rotation.
 
static Perm rand (bool even=false)
 Returns a random permutation on n elements.
 
static Perm rand (URBG &&gen, bool even=false)
 Returns a random permutation on n elements, using the given uniform random bit generator.
 
static Perm tightDecoding (const std::string &enc)
 Reconstructs a permutation from its given tight encoding.
 
static Perm tightDecode (std::istream &input)
 Reconstructs a permutation from its given tight encoding.
 
static constexpr Perm extend (Perm< k > p)
 Extends a k-element permutation to an n-element permutation, where 2 ≤ k < n.
 
static constexpr Perm contract (Perm< k > p)
 Restricts a k-element permutation to an n-element permutation, where k > n.
 

Static Public Attributes

static constexpr int degree = 4
 The degree of the underlying symmetric group; that is, the template parameter n.
 
static constexpr PermCodeType codeType = PermCodeType::Index
 Indicates what type of internal permutation code is used by this instance of the Perm class template.
 
static constexpr Index nPerms = 24
 The total number of permutations on four elements.
 
static constexpr Index nPerms_1 = 6
 Deprecated constant holding the total number of permutations on three elements.
 
static constexpr int imageBits = 2
 Indicates the number of bits used in an image pack to store the image of a single integer.
 
static constexpr ImagePack imageMask
 A bitmask whose lowest imageBits bits are 1, and whose remaining higher order bits are all 0.
 
static constexpr PermSn< 4, PermOrder::Sign > Sn {}
 Gives fast access to all possible permutations of four elements in a sign-based order, with support for both array-like indexing and iteration.
 
static constexpr PermSn< 4, PermOrder::Sign > S4 {}
 Gives fast access to all possible permutations of four elements in a sign-based order, with support for both array-like indexing and iteration.
 
static constexpr PermSn< 4, PermOrder::Lex > orderedSn {}
 Gives fast access to all possible permutations of four elements in lexicographical order, with support for both array-like indexing and iteration.
 
static constexpr PermSn< 4, PermOrder::Lex > orderedS4 {}
 Gives fast access to all possible permutations of four elements in lexicographical order, with support for both array-like indexing and iteration.
 
static constexpr detail::PermSubSn< 4, 3 > S3 {}
 Deprecated array-like object that lists all possible permutations of three elements in a sign-based order.
 
static constexpr detail::PermSubSn< 4, 3 > Sn_1 {}
 Deprecated alias for S3, which gives fast array-like access to all possible permutations of three elements in a sign-based order.
 
static constexpr detail::PermSubSn< 4, 3, PermOrder::Lex > orderedS3 {}
 Deprecated array-like object that lists all possible permutations of three elements in lexicographical order.
 
static constexpr detail::PermSubSn< 4, 2 > S2 {}
 Deprecated array-like object that lists all possible permutations of two elements.
 
static constexpr int degree
 The degree of the underlying symmetric group; that is, the template parameter n.
 
static constexpr int imageBits
 Indicates the number of bits used in an image pack to store the image of a single integer.
 
static constexpr ImagePack imageMask
 A bitmask whose lowest imageBits bits are 1, and whose remaining higher order bits are all 0.
 
static constexpr PermCodeType codeType
 Indicates what type of internal permutation code is used by this instance of the Perm class template.
 
static constexpr Index nPerms
 The total number of permutations on n elements.
 
static constexpr Index nPerms_1
 Deprecated constant holding the total number of permutations on n-1 elements.
 
static constexpr PermSn< n, PermOrder::Sign > Sn
 Gives access to all possible permutations of n elements in a sign-based order, with support for both array-like indexing and iteration.
 
static constexpr PermSn< n, PermOrder::Lex > orderedSn
 Gives access to all possible permutations of n elements in lexicographical order, with support for both array-like indexing and iteration.
 

Protected Member Functions

constexpr Perm (Code2 code)
 Creates a permutation from the given second-generation permutation code.
 
constexpr Perm (Code code)
 Creates a permutation from the given internal code.
 

Protected Attributes

Code2 code_
 The internal second-generation permutation code representing this permutation.
 
Code code_
 The internal code representing this permutation.
 

Friends

class PermSn< 4, PermOrder::Sign >
 
class PermSn< 4, PermOrder::Lex >
 
class PermSn< n, PermOrder::Sign >
 
class PermSn< n, PermOrder::Lex >
 

Detailed Description

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 by value and swap with std::swap(), with no need for any specialised move operations or swap functions. Moreover, Perm<4> in particular 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 are image packs: characters whose lowest two bits represent the image of 0, whose next lowest two bits represent the image of 1, and so on. The routines permCode1(), setPermCode1(), fromPermCode1() and isPermCode1() 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>::Sn. 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>).

You can iterate through all permutations using a range-based for loop over Sn, and this will be extremely fast in both C++ and Python:

for (auto p : Perm<4>::Sn) { ... }
static constexpr PermSn< n, PermOrder::Sign > Sn
Gives access to all possible permutations of n elements in a sign-based order, with support for both ...
Definition perm.h:482

This behaviour does not generalise to the large permutation classes Perm<n> with n ≥ 8, which are not as tightly optimised: such range-based for loops are still supported for n ≥ 8 but will be significantly slower in Python than in C++. See the generic Perm class notes for further details.

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

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

Member Typedef Documentation

◆ Code

using regina::Perm< n >::Code

Indicates the native unsigned integer type used to store the internal permutation code.

This type alias is present for most values of n, though its precise size depends on how the permutation code is constructed. However, for n = 4,...,7 it is replaced by two type aliases Code1 and Code2, which describe the older first-generation and newer second-generation permutation codes respectively.

◆ Code1

using regina::Perm< 4 >::Code1 = ImagePack

Indicates the native unsigned integer type used to store a first-generation permutation code.

Although types Code1 and Code2 are identical, they are provided as separate type aliases to help communicate in your source code which type of code is being used.

◆ Code2

using regina::Perm< 4 >::Code2 = uint8_t

Indicates the native unsigned integer type used to store a second-generation permutation code.

Although types Code1 and Code2 are identical, they are provided as separate type aliases to help communicate in your source code which type of code is being used.

◆ ImagePack [1/2]

using regina::Perm< n >::ImagePack

Indicates the native unsigned integer type used to store a single image pack.

See the class notes for more information on image packs, and how they are used as permutation codes for n ≥ 8.

◆ ImagePack [2/2]

using regina::Perm< 4 >::ImagePack = uint8_t

Indicates the native unsigned integer type used to store a single image pack.

See the class notes for more information on image packs, and how they are used to build the old first-generation permutation codes.

◆ Index [1/2]

using regina::Perm< n >::Index

Denotes a native signed integer type large enough to count all permutations on n elements.

In other words, this is a native signed integer type large enough to store (n!).

Note
This type is not hyper-optimised: for very small n where Index is hard-coded this is just an int, and for larger n where Index is derived it is actually large enough to hold an entire image pack. If at any stage there are plans to optimise this type, be careful of the special case of n = 8, where (8!) can be stored in an unsigned 16-bit type but not a signed 16-bit type.

◆ Index [2/2]

using regina::Perm< 4 >::Index = int

Denotes a native signed integer type large enough to count all permutations on four elements.

In other words, this is a native signed integer type large enough to store (4!).

Constructor & Destructor Documentation

◆ Perm() [1/12]

regina::Perm< 4 >::Perm ( )
inlineconstexpr

Creates the identity permutation.

◆ Perm() [2/12]

regina::Perm< 4 >::Perm ( int a,
int b )
inlineconstexpr

Creates the transposition of a and b.

Note that a and b need not be distinct.

Precondition
a and b are in {0,1,2,3}.
Parameters
athe element to switch with b.
bthe element to switch with a.

◆ Perm() [3/12]

regina::Perm< 4 >::Perm ( int a,
int b,
int c,
int d )
inlineconstexpr

Creates a permutation mapping (0,1,2,3) to (a,b,c,d) respectively.

Precondition
{a,b,c,d} = {0,1,2,3}.
Parameters
athe desired image of 0.
bthe desired image of 1.
cthe desired image of 2.
dthe desired image of 3.

◆ Perm() [4/12]

regina::Perm< 4 >::Perm ( const std::array< int, 4 > & image)
inlineconstexpr

Creates a permutation mapping i to image[i] for each i = 0,1,2,3.

Precondition
The elements of image are 0, 1, 2 and 3 in some order.
Parameters
imagethe array of images.

◆ Perm() [5/12]

regina::Perm< 4 >::Perm ( int a0,
int a1,
int b0,
int b1,
int c0,
int c1,
int d0,
int d1 )
inlineconstexpr

Creates a permutation mapping (a0,b0,c0,d0) to (a1,b1,c1,d1) respectively.

Precondition
{a0,b0,c0,d0} = {a1,b1,c1,d1} = {0,1,2,3}.
Parameters
a0the desired preimage of a1.
b0the desired preimage of b1.
c0the desired preimage of c1.
d0the desired preimage of d1.
a1the desired image of a0.
b1the desired image of b0.
c1the desired image of c0.
d1the desired image of d0.

◆ Perm() [6/12]

regina::Perm< 4 >::Perm ( const Perm< 4 > & cloneMe)
constexprdefault

Creates a permutation that is a clone of the given permutation.

Parameters
cloneMethe permutation to clone.

◆ Perm() [7/12]

regina::Perm< 4 >::Perm ( Code2 code)
inlineconstexprprotected

Creates a permutation from the given second-generation permutation code.

Precondition
the given code is a valid second-generation permutation code; see isPermCode2() for details.
Parameters
codethe second-generation code from which the new permutation will be created.

◆ Perm() [8/12]

regina::Perm< n >::Perm ( )
inlineconstexpr

Creates the identity permutation.

◆ Perm() [9/12]

regina::Perm< n >::Perm ( int a,
int b )
inlineconstexpr

Creates the transposition of a and b.

Note that a and b need not be distinct.

Precondition
0 ≤ a,b < n.
Parameters
athe element to switch with b.
bthe element to switch with a.

◆ Perm() [10/12]

regina::Perm< n >::Perm ( const std::array< int, n > & image)
inlineconstexpr

Creates a permutation mapping i to image[i] for each 0 ≤ i < n.

Precondition
The elements of image are 0,...,n-1 in some order.
Parameters
imagethe array of images.

◆ Perm() [11/12]

regina::Perm< n >::Perm ( const Perm< 4 > & )
constexprdefault

Creates a permutation that is a clone of the given permutation.

◆ Perm() [12/12]

regina::Perm< n >::Perm ( Code code)
inlineconstexprprotected

Creates a permutation from the given internal code.

Precondition
the given code is a valid permutation code; see isPermCode() for details.
Parameters
codethe internal code from which the new permutation will be created.

Member Function Documentation

◆ cachedComp() [1/4]

Perm< n > regina::Perm< n >::cachedComp ( const Perm< 4 > & q) const
inline

An alias for the composition operator, provided to assist with writing generic code.

This generic Perm<n> class does not use precomputation to compute compositions. The only point of having cachedComp() in this generic Perm<n> class is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with the generic Perm<n>, you should just use the composition operator instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedComp().

The permutation that is returned is the same as you would obtain by calling (*this) * q.

Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedComp(). For generic Perm<n>, precompute() does not affect compositions; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe permutation to compose this with.
Returns
the composition of both permutations.

◆ cachedComp() [2/4]

Perm< n > regina::Perm< n >::cachedComp ( const Perm< 4 > & q,
const Perm< 4 > & r ) const
inline

Deprecated alias for using the composition operator twice, provided to assist with writing generic code.

The permutation that is returned is the same as you would obtain by calling (*this) * q * r.

Deprecated
The three-way cachedComp() was originally written to support conjugation. If you are indeed conjugating, then call cachedConjugate() instead; otherwise just call the two-way cachedComp() twice.
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedComp(). For generic Perm<n>, precompute() does not affect compositions; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe first permutation to compose this with.
rthe second permutation to compose this with.
Returns
the composition of both permutations.

◆ cachedComp() [3/4]

Perm< 4 > regina::Perm< 4 >::cachedComp ( const Perm< 4 > & q) const
inline

An alias for the composition operator, provided to assist with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations. The only point of having cachedComp() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you should just use the composition operator instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedComp(). (For Perm<4>, which does not use precomputation for its optimisations, precompute() does nothing.)

The permutation that is returned is the same as you would obtain by calling (*this) * q.

Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedComp(). For Perm<4>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe permutation to compose this with.
Returns
the composition of both permutations.

◆ cachedComp() [4/4]

Perm< 4 > regina::Perm< 4 >::cachedComp ( const Perm< 4 > & q,
const Perm< 4 > & r ) const
inline

Deprecated alias for using the composition operator twice, provided to assist with writing generic code.

The permutation that is returned is the same as you would obtain by calling (*this) * q * r.

Deprecated
The three-way cachedComp() was originally written to support conjugation. If you are indeed conjugating, then call cachedConjugate() instead; otherwise just call the two-way cachedComp() twice.
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedComp(). For Perm<4>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe first permutation to compose this with.
rthe second permutation to compose this with.
Returns
the composition of both permutations.

◆ cachedConjugate() [1/2]

Perm< n > regina::Perm< n >::cachedConjugate ( const Perm< 4 > & q) const
inline

An alias for conjugate(), provided to assist with writing generic code.

This generic Perm<n> class does not use precomputation to compute conjugates. The only point of having cachedConjugate() in this generic Perm<n> class is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with the generic Perm<n>, you should just call conjugate() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedConjugate().
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedConjugate(). For generic Perm<n>, precompute() does not affect conjugate computations; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe permutation to conjugate this by.
Returns
the conjugate of this permutation by q.

◆ cachedConjugate() [2/2]

Perm< 4 > regina::Perm< 4 >::cachedConjugate ( const Perm< 4 > & q) const
inline

An alias for conjugate(), provided to assist with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations. The only point of having cachedConjugate() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you should just call conjugate() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedConjugate(). (For Perm<4>, which does not use precomputation for its optimisations, precompute() does nothing.)
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedConjugate(). For Perm<6>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
qthe permutation to conjugate this by.
Returns
the conjugate of this permutation by q.

◆ cachedInverse() [1/2]

Perm< n > regina::Perm< n >::cachedInverse ( ) const
inline

Finds the inverse of this permutation, optimised using precomputed "partial lookup tables".

The advantage of this routine is speed: calling cachedInverse() involves two table lookups and some simple arithmetic to combine the results, whereas inverse() requires time linear in n.

The disadvantages of this routine are that (1) you must remember to call precompute() in advance, and (2) the precomputed lookup tables will consume additional memory for the lifetime of your program. See precompute() for details on just how much memory these tables will consume for each n.

The permutation that is returned is the same as you would obtain by calling inverse().

Precondition
You must have called the routine precompute() at least once in the lifetime of the program before using cachedInverse(). Otherwise this routine will almost certainly crash your program.
Returns
the inverse of this permutation.

◆ cachedInverse() [2/2]

Perm< 4 > regina::Perm< 4 >::cachedInverse ( ) const
inline

An alias for inverse(), provided to assist with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations. The only point of having cachedInverse() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you should just call inverse() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedInverse(). (For Perm<4>, which does not use precomputation for its optimisations, precompute() does nothing.)
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedInverse(). For Perm<4>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Returns
the inverse of this permutation.

◆ cachedOrder() [1/2]

int regina::Perm< n >::cachedOrder ( ) const
inline

An alias for order(), provided to assist with writing generic code.

This specialised Perm<n> class does not use precomputation to compute orders. The only point of having cachedOrder() in this generic Perm<n> class is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with the generic Perm<n>, you should just call order() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedOrder().
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedOrder(). For generic Perm<n>, precompute() does not affect order computations; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Returns
the order of this permutation.

◆ cachedOrder() [2/2]

int regina::Perm< 4 >::cachedOrder ( ) const
inline

An alias for order(), provided to assist with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations. The only point of having cachedOrder() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you should just call order() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedOrder(). (For Perm<4>, which does not use precomputation for its optimisations, precompute() does nothing.)
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedOrder(). For Perm<4>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Returns
the order of this permutation.

◆ cachedPow() [1/2]

Perm< n > regina::Perm< n >::cachedPow ( long exp) const
inline

An alias for pow(), provided to assist with writing generic code.

This specialised Perm<n> class does not use precomputation to compute powers. The only point of having cachedPow() in this generic Perm<n> class is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with the generic Perm<n>, you should just call pow() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedPow().
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedPow(). For generic Perm<n>, precompute() does not affect powers; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
expthe exponent; this may be positive, zero or negative.
Returns
this permutation raised to the power of exp.

◆ cachedPow() [2/2]

Perm< 4 > regina::Perm< 4 >::cachedPow ( long exp) const
inline

An alias for pow(), provided to assist with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations. The only point of having cachedPow() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you should just call pow() instead.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using cachedPow(). (For Perm<4>, which does not use precomputation for its optimisations, precompute() does nothing.)
Precondition
You must have called precompute() at least once in the lifetime of this program before calling cachedPow(). For Perm<4>, precompute() does nothing; however, for other Perm<n> classes a failure to do this will almost certainly crash your program.
Parameters
expthe exponent; this may be positive, zero or negative.
Returns
this permutation raised to the power of exp.

◆ clear() [1/2]

void regina::Perm< n >::clear ( unsigned from)
inline

Resets the images of all integers from from onwards to the identity map.

Specifically, for each i in the range from,...,n-1, this routine will ensure that image[i] == i. The images of 0,1,...,from-1 will not be altered.

Precondition
The images of from,...,n-1 are exactly from,...,n-1, but possibly in a different order.
Parameters
fromthe first integer whose image should be reset. This must be between 0 and n inclusive.

◆ clear() [2/2]

void regina::Perm< 4 >::clear ( unsigned from)

Resets the images of all integers from from onwards to the identity map.

Specifically, for each i in the range from,...,3, this routine will ensure that image[i] == i. The images of 0,1,...,from-1 will not be altered.

Precondition
The images of from,...,3 are exactly from,...,3, but possibly in a different order.
Parameters
fromthe first integer whose image should be reset. This must be between 0 and 4 inclusive.

◆ compareWith() [1/2]

int regina::Perm< n >::compareWith ( const Perm< 4 > & other) const
constexpr

Lexicographically compares the images of (0,1,...,n-1) under this and the given permutation.

Parameters
otherthe permutation with which to compare this.
Returns
-1 if this permutation produces a smaller image, 0 if the permutations are equal, and 1 if this permutation produces a greater image.

◆ compareWith() [2/2]

int regina::Perm< 4 >::compareWith ( const Perm< 4 > & other) const
inlineconstexpr

Lexicographically compares the images of (0,1,2,3) under this and the given permutation.

Note that this does not yield the same ordering of permutations as used by the less-than and increment operators. Moreover, compareWith() is slower than the less-than operator to compute.

Parameters
otherthe permutation with which to compare this.
Returns
-1 if this permutation produces a smaller image, 0 if the permutations are equal and 1 if this permutation produces a greater image.

◆ conjugate() [1/2]

Perm< n > regina::Perm< n >::conjugate ( const Perm< 4 > & q) const
inlineconstexpr

Computes the conjugate of this permutation by q.

Specifically, calling p.conjugate(q) is equivalent to computing q * p * q.inverse(). The resulting permutation will have the same cycle structure as p, but with the cycle elements translated according to q.

Parameters
qthe permutation to conjugate this by.
Returns
the conjugate of this permutation by q.

◆ conjugate() [2/2]

Perm< 4 > regina::Perm< 4 >::conjugate ( const Perm< 4 > & q) const
inlineconstexpr

Computes the conjugate of this permutation by q.

Specifically, calling p.conjugate(q) is equivalent to computing q * p * q.inverse(). The resulting permutation will have the same cycle structure as p, but with the cycle elements translated according to q.

Parameters
qthe permutation to conjugate this by.
Returns
the conjugate of this permutation by q.

◆ contract() [1/2]

static constexpr Perm regina::Perm< n >::contract ( Perm< k > p)
staticconstexpr

Restricts a k-element permutation to an n-element permutation, where k > n.

The resulting permutation will map 0,...,n-1 to their respective images under p, and will ignore the "unused" images p[n],...,p[k-1].

Precondition
The given permutation maps 0,...,n-1 to 0,...,n-1 in some order.
Template Parameters
kthe number of elements for the input permutation; this must be strictly greater than n.
Parameters
pa permutation on k elements.
Returns
the same permutation restricted to a permutation on n elements.

◆ contract() [2/2]

template<int k>
static constexpr Perm< 4 > regina::Perm< 4 >::contract ( Perm< k > p)
staticconstexpr

Restricts a k-element permutation to an 4-element permutation, where k > 4.

The resulting permutation will map 0,...,3 to their respective images under p, and will ignore the "unused" images p[4],...,p[k-1].

Precondition
The given permutation maps 0,...,3 to 0,...,3 in some order.
Template Parameters
kthe number of elements for the input permutation; this must be strictly greater than 4.
Parameters
pa permutation on k elements.
Returns
the same permutation restricted to a permutation on 4 elements.

◆ extend() [1/2]

static constexpr Perm regina::Perm< n >::extend ( Perm< k > p)
staticconstexpr

Extends a k-element permutation to an n-element permutation, where 2 ≤ k < n.

The resulting permutation will map 0,...,k-1 to their respective images under p, and will map the "unused" elements k,...,n-1 to themselves.

Template Parameters
kthe number of elements for the input permutation; this must be at least 2, and strictly less than n.
Parameters
pa permutation on k elements.
Returns
the same permutation expressed as a permutation on n elements.

◆ extend() [2/2]

template<int k>
static constexpr Perm< 4 > regina::Perm< 4 >::extend ( Perm< k > p)
staticconstexpr

Extends a k-element permutation to a 4-element permutation, where 2 ≤ k < 4.

The resulting permutation will map 0,...,k-1 to their respective images under p, and will map the "unused" elements k,...,3 to themselves.

Template Parameters
kthe number of elements for the input permutation; this must be 2 or 3.
Parameters
pa permutation on k elements.
Returns
the same permutation expressed as a permutation on four elements.

◆ fromImagePack() [1/2]

Perm< n > regina::Perm< n >::fromImagePack ( ImagePack pack)
inlinestaticconstexpr

Creates a permutation from the given image pack.

See the class notes for more information on image packs, and how they are used to build permutation codes.

For n ≥ 8, this routine is identical to fromPermCode().

Precondition
The argument pack is a valid image pack; see isImagePack() for details.
Parameters
packan image pack that describes a permutation.
Returns
the permutation represented by the given image pack.

◆ fromImagePack() [2/2]

Perm< 4 > regina::Perm< 4 >::fromImagePack ( ImagePack pack)
inlinestaticconstexpr

Creates a permutation from the given image pack.

See the class notes for more information on image packs, and how they are used to build the old first-generation permutation codes.

For Perm<4>, this routine is identical to fromPermCode1().

Precondition
The argument pack is a valid image pack; see isImagePack() for details.
Parameters
packan image pack that describes a permutation.
Returns
the permutation represented by the given image pack.

◆ fromPermCode()

Perm< n > regina::Perm< n >::fromPermCode ( Code code)
inlinestaticconstexpr

Creates a permutation from the given internal code.

Precondition
the given code is a valid permutation code; see isPermCode() for details.
Parameters
codethe internal code for the new permutation.
Returns
the permutation reprsented by the given internal code.

◆ fromPermCode1()

Perm< 4 > regina::Perm< 4 >::fromPermCode1 ( Code1 code)
inlinestaticconstexpr

Creates a permutation from the given first-generation permutation code.

Precondition
the given code is a valid first-generation permutation code; see isPermCode1() for details.
Warning
This routine will incur additional overhead, since Perm<4> now uses second-generation codes internally. See the class notes and the routine fromPermCode2() for details.
Parameters
codethe first-generation code for the new permutation.
Returns
the permutation represented by the given code.

◆ fromPermCode2()

Perm< 4 > regina::Perm< 4 >::fromPermCode2 ( Code2 code)
inlinestaticconstexpr

Creates a permutation from the given second-generation permutation code.

Second-generation codes are fast to work with, since they are used internally by the Perm<4> class.

Precondition
the given code is a valid second-generation permutation code; see isPermCode2() for details.
Parameters
codethe second-generation code for the new permutation.
Returns
the permutation represented by the given code.

◆ hash() [1/2]

size_t regina::Perm< n >::hash ( ) const
constexpr

Hashes this permutation to a non-negative integer, allowing it to be used for keys in hash tables.

The implementation currently returns the internal permutation code, truncated to a size_t where necessary. For the larger permutation classes (n ≥ 8), this is almost certainly a bad choice of hash function (since permutation codes are image packs, which have enormous "holes" across their overall integer range). This implementation (and therefore the specific hash values obtained) is subject to change in future versions of Regina.

Python
For Python users, this function uses the standard Python name hash(). This allows permutations to be used as keys in Python dictionaries and sets.
Returns
The integer hash of this permutation.

◆ hash() [2/2]

size_t regina::Perm< 4 >::hash ( ) const
inlineconstexpr

Hashes this permutation to a non-negative integer, allowing it to be used for keys in hash tables.

The implementation currently returns the internal permutation code (which for Perm<4> will always fit within a size_t). This implementation (and therefore the specific hash values obtained) is subject to change in future versions of Regina.

Python
For Python users, this function uses the standard Python name hash(). This allows permutations to be used as keys in Python dictionaries and sets.
Returns
The integer hash of this permutation.

◆ imagePack() [1/2]

Perm< n >::ImagePack regina::Perm< n >::imagePack ( ) const
inlineconstexpr

Returns the image pack that represents this permutation.

See the class notes for more information on image packs, and how they are used to build permutation codes.

For n ≥ 8, this routine is identical to permCode().

Returns
the image pack for this permutation.

◆ imagePack() [2/2]

Perm< 4 >::ImagePack regina::Perm< 4 >::imagePack ( ) const
inlineconstexpr

Returns the image pack that represents this permutation.

See the class notes for more information on image packs, and how they are used to build the old first-generation permutation codes.

For Perm<4>, this routine is identical to permCode1().

Returns
the image pack for this permutation.

◆ inverse() [1/2]

Perm< n > regina::Perm< n >::inverse ( ) const
inlineconstexpr

Finds the inverse of this permutation.

For permutations of seven and fewer objects, inversion is extremely fast because it uses hard-coded lookup tables. However, for this generic Perm<n> class, inversion cannot use these lookup tables (for multiple reasons), and so inverse() takes time linear in n.

If you are going to make significant use of the generic Perm<n> class for some particular value of n, you should instead:

Returns
the inverse of this permutation.

◆ inverse() [2/2]

Perm< 4 > regina::Perm< 4 >::inverse ( ) const
inlineconstexpr

Finds the inverse of this permutation.

Returns
the inverse of this permutation.

◆ isConjugacyMinimal() [1/2]

bool regina::Perm< n >::isConjugacyMinimal ( ) const
constexpr

Is this permutation minimal in its conjugacy class?

Here "minimal" means that, amongst all its conjugates, this permutation has the smallest index in the array Perm<n>::Sn.

See Sn for further information on how permutations are indexed.

Returns
true if and only if this permutation is minimal in its conjugacy class.

◆ isConjugacyMinimal() [2/2]

bool regina::Perm< 4 >::isConjugacyMinimal ( ) const
inlineconstexpr

Is this permutation minimal in its conjugacy class?

Here "minimal" means that, amongst all its conjugates, this permutation has the smallest index in the array Perm<4>::Sn.

See Sn for further information on how permutations are indexed.

This routine is extremely fast for Perm<4>, since it essentially uses a hard-coded lookup table.

Returns
true if and only if this permutation is minimal in its conjugacy class.

◆ isIdentity() [1/2]

bool regina::Perm< n >::isIdentity ( ) const
inlineconstexpr

Determines if this is the identity permutation.

This is true if and only if every integer 0 ≤ i < n is mapped to itself.

Returns
true if and only if this is the identity permutation.

◆ isIdentity() [2/2]

bool regina::Perm< 4 >::isIdentity ( ) const
inlineconstexpr

Determines if this is the identity permutation.

This is true if and only if each of 0, 1, 2 and 3 is mapped to itself.

Returns
true if and only if this is the identity permutation.

◆ isImagePack() [1/2]

bool regina::Perm< n >::isImagePack ( ImagePack pack)
inlinestaticconstexpr

Determines whether the given argument is the image pack of some n-element permutation.

See the class notes for more information on image packs, and how they are used to build permutation codes.

For n ≥ 8, this routine is identical to isPermCode().

Parameters
packthe candidate image pack to test.
Returns
true if and only if pack is a valid image pack.

◆ isImagePack() [2/2]

bool regina::Perm< 4 >::isImagePack ( ImagePack pack)
inlinestaticconstexpr

Determines whether the given argument is the image pack of some 4-element permutation.

See the class notes for more information on image packs, and how they are used to build the old first-generation permutation codes.

For Perm<4>, this routine is identical to isPermCode1().

Parameters
packthe candidate image pack to test.
Returns
true if and only if pack is a valid image pack.

◆ isPermCode()

bool regina::Perm< n >::isPermCode ( Code code)
staticconstexpr

Determines whether the given integer is a valid internal permutation code.

Valid permutation codes can be passed to setPermCode() or fromPermCode(), and are returned by permCode().

Parameters
codethe permutation code to test.
Returns
true if and only if the given code is a valid internal permutation code.

◆ isPermCode1()

bool regina::Perm< 4 >::isPermCode1 ( Code1 code)
inlinestaticconstexpr

Determines whether the given character is a valid first-generation permutation code.

Valid first-generation codes can be passed to setPermCode1() or fromPermCode1(), and are returned by permCode1().

Warning
This routine will incur additional overhead, since Perm<4> now uses second-generation codes internally. See the class notes and the routine isPermCode2() for details.
Parameters
codethe permutation code to test.
Returns
true if and only if the given code is a valid first-generation permutation code.

◆ isPermCode2()

bool regina::Perm< 4 >::isPermCode2 ( Code2 code)
inlinestaticconstexpr

Determines whether the given character is a valid second-generation permutation code.

Valid second-generation codes can be passed to setPermCode2() or fromPermCode2(), and are returned by permCode2().

Second-generation codes are fast to work with, since they are used internally by the Perm<4> class.

Parameters
codethe permutation code to test.
Returns
true if and only if the given code is a valid second-generation permutation code.

◆ operator*() [1/2]

Perm< n > regina::Perm< n >::operator* ( const Perm< 4 > & q) const
inlineconstexpr

Returns the composition of this permutation with the given permutation.

If this permutation is p, the resulting permutation will be p∘q, and will satisfy (p*q)[x] == p[q[x]].

Parameters
qthe permutation to compose this with.
Returns
the composition of both permutations.

◆ operator*() [2/2]

Perm< 4 > regina::Perm< 4 >::operator* ( const Perm< 4 > & q) const
inlineconstexpr

Returns the composition of this permutation with the given permutation.

If this permutation is p, the resulting permutation will be p∘q, and will satisfy (p*q)[x] == p[q[x]].

Parameters
qthe permutation with which to compose this.
Returns
the composition of both permutations.

◆ operator++() [1/4]

Perm & regina::Perm< n >::operator++ ( )

A preincrement operator that changes this to be the next permutation in the array Perm<n>::Sn.

If this is the last such permutation then this will wrap around to become the first permutation in Perm<n>::Sn, which is the identity.

Python
Not present. The postincrement operator is present in Python as the member function inc().
Returns
a reference to this permutation after the increment.

◆ operator++() [2/4]

Perm< 4 > & regina::Perm< 4 >::operator++ ( )
inline

A preincrement operator that changes this to be the next permutation in the array Perm<4>::Sn.

If this is the last such permutation then this will wrap around to become the first permutation in Perm<4>::Sn, which is the identity.

Python
Not present. The postincrement operator is present in Python as the member function inc().
Returns
a reference to this permutation after the increment.

◆ operator++() [3/4]

Perm< n > regina::Perm< n >::operator++ ( int )
inline

A postincrement operator that changes this to be the next permutation in the array Perm<n>::Sn.

If this is the last such permutation then this will wrap around to become the first permutation in Perm<n>::Sn, which is the identity.

Python
This routine is named inc() since python does not support the increment operator.
Returns
a copy of this permutation before the increment took place.

◆ operator++() [4/4]

Perm< 4 > regina::Perm< 4 >::operator++ ( int )
inlineconstexpr

A postincrement operator that changes this to be the next permutation in the array Perm<4>::Sn.

If this is the last such permutation then this will wrap around to become the first permutation in Perm<4>::Sn, which is the identity.

Python
This routine is named inc() since python does not support the increment operator.
Returns
a copy of this permutation before the increment took place.

◆ operator<=>() [1/2]

std::strong_ordering regina::Perm< 4 >::operator<=> ( const Perm< 4 > & ) const
constexprdefault

Compares two permutations according to which appears earlier in the array Perm<4>::Sn.

Note that this is not the same ordering of permutations as the ordering implied by compareWith(). This ordering is, however, consistent with the ordering implied by the ++ operators, and this ordering is also faster to compute than compareWith().

This generates all of the usual comparison operators, including <, <=, >, and >=.

Python
This spaceship operator x <=> y is not available, but the other comparison operators that it generates are available.
Returns
The result that indicates which permutation appears earlier in Sn.

◆ operator<=>() [2/2]

std::strong_ordering regina::Perm< n >::operator<=> ( const Perm< 4 > & rhs) const
constexpr

Compares two permutations according to which appears earlier in the array Perm<n>::Sn.

Note that this is not the same ordering of permutations as the ordering implied by compareWith(). This ordering is, however, consistent with the ordering implied by the ++ operators.

Unlike the smaller permutation classes that use Sn indices as internal permutation codes, for this generic Perm class the ordering defined here is slower to compute than compareWith(). It is recommended that, unless you specifically need to align your ordering with Sn indices, you either (i) use compareWith() for lexicographical ordering (which is a little faster), or else (ii) just compare permutation codes if you are happy with an arbitrary ordering (which will be much faster).

This generates all of the usual comparison operators, including <, <=, >, and >=.

Python
This spaceship operator x <=> y is not available, but the other comparison operators that it generates are available.
Parameters
rhsthe permutation to compare this with.
Returns
The result that indicates which permutation appears earlier in Sn.

◆ operator=() [1/2]

Perm & regina::Perm< n >::operator= ( const Perm< 4 > & cloneMe)
default

Sets this permutation to be equal to the given permutation.

Parameters
cloneMethe permutation whose value will be assigned to this permutation.
Returns
a reference to this permutation.

◆ operator=() [2/2]

Perm< 4 > & regina::Perm< 4 >::operator= ( const Perm< 4 > & cloneMe)
default

Sets this permutation to be equal to the given permutation.

Parameters
cloneMethe permutation whose value will be assigned to this permutation.
Returns
a reference to this permutation.

◆ operator==() [1/2]

bool regina::Perm< 4 >::operator== ( const Perm< 4 > & ) const
constexprdefault

Determines if this is equal to the given permutation.

This is true if and only if both permutations have the same images for 0, 1, 2 and 3.

Returns
true if and only if this and the given permutation are equal.

◆ operator==() [2/2]

bool regina::Perm< n >::operator== ( const Perm< 4 > & ) const
constexprdefault

Determines if this is equal to the given permutation.

This is true if and only if both permutations have the same images for all 0 ≤ i < n.

Returns
true if and only if this and the given permutation are equal.

◆ operator[]() [1/2]

int regina::Perm< n >::operator[] ( int source) const
inlineconstexpr

Determines the image of the given integer under this permutation.

Parameters
sourcethe integer whose image we wish to find. This should be between 0 and n-1 inclusive.
Returns
the image of source.

◆ operator[]() [2/2]

int regina::Perm< 4 >::operator[] ( int source) const
inlineconstexpr

Determines the image of the given integer under this permutation.

Parameters
sourcethe integer whose image we wish to find. This should be between 0 and 3 inclusive.
Returns
the image of source.

◆ order() [1/2]

int regina::Perm< n >::order ( ) const
constexpr

Returns the order of this permutation.

In other words; this routine returns the smallest positive integer k for which the kth power of this permutation is the identity.

Note that the largest possible order for the largest supported n (n = 16) is 140. See OEIS sequence A000793 for details.

Returns
the order of this permutation.

◆ order() [2/2]

int regina::Perm< 4 >::order ( ) const
inlineconstexpr

Returns the order of this permutation.

In other words; this routine returns the smallest positive integer k for which the kth power of this permutation is the identity.

Returns
the order of this permutation.

◆ orderedS4Index()

Perm< 4 >::Index regina::Perm< 4 >::orderedS4Index ( ) const
inlineconstexpr

Returns the lexicographical index of this permutation.

This will be the index of this permutation in the Perm<4>::orderedSn array.

This is a dimension-specific alias for orderedSnIndex(). In general, for every n there will be a member function Perm<n>::orderedSnIndex(); however, these numerical aliases Perm<2>::orderedS2Index(), ..., Perm<7>::orderedS7Index() are only available for small n.

See orderedSn for further information on lexicographical ordering.

Returns
the lexicographical index of this permutation. This will be between 0 and 23 inclusive.

◆ orderedSnIndex() [1/2]

Perm< n >::Index regina::Perm< n >::orderedSnIndex ( ) const
constexpr

Returns the lexicographical index of this permutation.

This will be the index of this permutation in the Perm<n>::orderedSn array.

See orderedSn for further information on lexicographical ordering.

Returns
the lexicographical index of this permutation. This will be between 0 and n!-1 inclusive.

◆ orderedSnIndex() [2/2]

Perm< 4 >::Index regina::Perm< 4 >::orderedSnIndex ( ) const
inlineconstexpr

Returns the lexicographical index of this permutation.

This will be the index of this permutation in the Perm<4>::orderedSn array.

See orderedSn for further information on lexicographical ordering.

Returns
the lexicographical index of this permutation. This will be between 0 and 23 inclusive.

◆ pairs()

Perm< 6 > regina::Perm< 4 >::pairs ( ) const
inlineconstexpr

Returns the induced permutation on all six pairs of elements from 0,1,2,3.

Specifically: suppose we number the six pairs in lexicographical order, so that the pairs 01, 02, 03, 12, 13, 23 are indexed as 0, 1, 2, 3, 4, 5 respectively. Then this permutation induces a corresponding permutation of 0,...,5, where the pair (a, b) maps to the pair (p[a], p[b]). This routine returns that induced permutation.

Note that, if p permutes the four vertices (or equivalently, the four faces) of a tetrahedron, then p.pairs() is the induced permutation on the six edges of the tetrahedron.

Returns
the induced permutation on six pairs of elements.

◆ permCode()

Perm< n >::Code regina::Perm< n >::permCode ( ) const
inlineconstexpr

Returns the internal code representing this permutation.

Note that the internal code is sufficient to reproduce the entire permutation.

The code returned will be a valid permutation code as determined by isPermCode().

Returns
the internal code.

◆ permCode1()

Perm< 4 >::Code1 regina::Perm< 4 >::permCode1 ( ) const
inlineconstexpr

Returns the first-generation code representing this permutation.

This code is sufficient to reproduce the entire permutation.

The code returned will be a valid first-generation permutation code as determined by isPermCode1().

Warning
This routine will incur additional overhead, since Perm<4> now uses second-generation codes internally. See the class notes and the routine permCode2() for details.
Returns
the first-generation permutation code.

◆ permCode2()

Perm< 4 >::Code2 regina::Perm< 4 >::permCode2 ( ) const
inlineconstexpr

Returns the second-generation code representing this permutation.

This code is sufficient to reproduce the entire permutation.

The code returned will be a valid second-generation permutation code as determined by isPermCode2().

Second-generation codes are fast to work with, since they are used internally by the Perm<4> class.

Returns
the second-generation permutation code.

◆ pow() [1/2]

Perm< n > regina::Perm< n >::pow ( long exp) const
constexpr

Computes the given power of this permutation.

This routine runs in time linear in n (in particular, the running time does not depend upon the given exponent).

Parameters
expthe exponent; this may be positive, zero or negative.
Returns
this permutation raised to the power of exp.

◆ pow() [2/2]

Perm< 4 > regina::Perm< 4 >::pow ( long exp) const
inlineconstexpr

Computes the given power of this permutation.

This routine runs in constant time.

Parameters
expthe exponent; this may be positive, zero or negative.
Returns
this permutation raised to the power of exp.

◆ pre() [1/2]

int regina::Perm< n >::pre ( int image) const
inlineconstexpr

Determines the preimage of the given integer under this permutation.

Parameters
imagethe integer whose preimage we wish to find. This should be between 0 and n-1 inclusive.
Returns
the preimage of image.

◆ pre() [2/2]

int regina::Perm< 4 >::pre ( int image) const
inlineconstexpr

Determines the preimage of the given integer under this permutation.

Parameters
imagethe integer whose preimage we wish to find. This should be between 0 and 3 inclusive.
Returns
the preimage of image.

◆ precompute() [1/2]

static void regina::Perm< n >::precompute ( )
static

Performs the precomputation necessary for using the optimised cachedInverse() routine.

This must be called before using any of the optimised cachedXXX() functions.

This only needs to be done once in the lifetime of the program. If you do try to call precompute() a second time then it will do nothing and return immediately.

The precomputed tables will consume roughly:

  • 33 kB for n = 8;
  • 8.9 MB for n = 9;
  • 17 MB for n = 10;
  • 143 MB for n = 11;
  • 268 MB for n = 12;
  • 2.3 GB for n = 13;
  • 4.3 GB for n = 14;
  • 37 GB for n = 15;
  • 69 GB for n = 16.

In particular, a 32-bit machine will not be able to store these tables for n ≥ 13, a 24-bit machine will not be these tables for n ≥ 9, and a 16-bit machine will not be able to store these tables for any n ≥ 8.

Precondition
There is enough memory available to store the precomputed tables; see above for the estimated space requirements.
Exceptions
FailedPreconditionThere was not enough memory to available to store the precomputed tables.

This routine is thread-safe.

◆ precompute() [2/2]

void regina::Perm< 4 >::precompute ( )
inlinestaticconstexpr

A do-nothing routine that assists with writing generic code.

This specialised Perm<4> class does not use precomputation for its optimisations, and so this precompute() function does nothing. The only point of having precompute() in Perm<4> is to make it easier to write generic code that works with Perm<n> for any n.

  • If you know you are only working with Perm<4>, you do not need to call this function at all.
  • If you are writing generic code, you must remember to call precompute() at least once in the lifetime of this program before using any of the optimised cachedXXX() functions, such as cachedComp(), cachedInverse(), and so on.

All Perm<n>::precompute() routines are thread-safe, and are harmless if called multiple times (since any call after the first will do nothing).

◆ rand() [1/4]

Perm< n > regina::Perm< n >::rand ( bool even = false)
static

Returns a random permutation on n elements.

All permutations are returned with equal probability.

This routine is thread-safe, and uses RandomEngine for its random number generation.

Warning
This routine is expensive, since it locks and unlocks the mutex protecting Regina's global uniform random bit generator. If you are calling this many times in quick succession, consider creating a single RandomEngine object yourself and then calling rand(randomEngine.engine(), even).
Parameters
evenif true, then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability).
Returns
a random permutation.

◆ rand() [2/4]

Perm< 4 > regina::Perm< 4 >::rand ( bool even = false)
inlinestatic

Returns a random permutation on four elements.

All permutations are returned with equal probability.

This routine is thread-safe, and uses RandomEngine for its random number generation.

Warning
This routine is expensive, since it locks and unlocks the mutex protecting Regina's global uniform random bit generator. If you are calling this many times in quick succession, consider creating a single RandomEngine object yourself and then calling rand(randomEngine.engine(), even).
Parameters
evenif true, then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability).
Returns
a random permutation.

◆ rand() [3/4]

static Perm regina::Perm< n >::rand ( URBG && gen,
bool even = false )
static

Returns a random permutation on n elements, using the given uniform random bit generator.

All permutations are returned with equal probability.

The thread safety of this routine is of course dependent on the thread safety of your uniform random bit generator gen.

Template Parameters
URBGA type which, once any references are removed, must adhere to the C++ UniformRandomBitGenerator concept.
Python
Not present. Python users are still able to use the non-thread-safe variant without the gen argument.
Parameters
genthe source of randomness to use (e.g., one of the many options provided in the C++ standard random header).
evenif true, then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability).
Returns
a random permutation.

◆ rand() [4/4]

template<class URBG>
static Perm regina::Perm< 4 >::rand ( URBG && gen,
bool even = false )
static

Returns a random permutation on four elements, using the given uniform random bit generator.

All permutations are returned with equal probability.

The thread safety of this routine is of course dependent on the thread safety of your uniform random bit generator gen.

Template Parameters
URBGA type which, once any references are removed, must adhere to the C++ UniformRandomBitGenerator concept.
Python
Not present. Python users are still able to use the non-thread-safe variant without the gen argument.
Parameters
genthe source of randomness to use (e.g., one of the many options provided in the C++ standard random header).
evenif true, then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability).
Returns
a random permutation.

◆ reverse() [1/2]

Perm< n > regina::Perm< n >::reverse ( ) const
inlineconstexpr

Finds the reverse of this permutation.

Here reverse means that we reverse the images of 0,...,n-1. In other words, if permutation q is the reverse of p, then p[i] == q[n - 1 - i] for all i.

◆ reverse() [2/2]

Perm< 4 > regina::Perm< 4 >::reverse ( ) const
inlineconstexpr

Finds the reverse of this permutation.

Here reverse means that we reverse the images of 0,...,3. In other words, if permutation q is the reverse of p, then p[i] == q[3 - i] for all i.

◆ rot() [1/2]

Perm< n > regina::Perm< n >::rot ( int i)
staticconstexpr

Returns the ith rotation.

This maps k to k + i (mod n) for all k.

Parameters
ithe image of 0; this must be between 0 and n-1 inclusive.
Returns
the ith rotation.

◆ rot() [2/2]

Perm< 4 > regina::Perm< 4 >::rot ( int i)
inlinestaticconstexpr

Returns the ith rotation.

This maps k to k + i (mod 4) for all k.

Parameters
ithe image of 0; this must be between 0 and 3 inclusive.
Returns
the ith rotation.

◆ S4Index()

Perm< 4 >::Index regina::Perm< 4 >::S4Index ( ) const
inlineconstexpr

Returns the index of this permutation in the Perm<4>::Sn array.

This is a dimension-specific alias for SnIndex(). In general, for every n there will be a member function Perm<n>::SnIndex(); however, these numerical aliases Perm<2>::S2Index(), ..., Perm<7>::S7Index() are only available for small n.

See Sn for further information on how these permutations are indexed.

Returns
the index i for which this permutation is equal to Perm<4>::Sn[i]. This will be between 0 and 23 inclusive.

◆ setPermCode()

void regina::Perm< n >::setPermCode ( Code code)
inline

Sets this permutation to that represented by the given internal code.

Precondition
the given code is a valid permutation code; see isPermCode() for details.
Parameters
codethe internal code that will determine the new value of this permutation.

◆ setPermCode1()

void regina::Perm< 4 >::setPermCode1 ( Code1 code)
inline

Sets this permutation to that represented by the given first-generation permutation code.

Precondition
the given code is a valid first-generation permutation code; see isPermCode1() for details.
Warning
This routine will incur additional overhead, since Perm<4> now uses second-generation codes internally. See the class notes and the routine setPermCode2() for details.
Parameters
codethe first-generation code that will determine the new value of this permutation.

◆ setPermCode2()

void regina::Perm< 4 >::setPermCode2 ( Code2 code)
inline

Sets this permutation to that represented by the given second-generation permutation code.

Second-generation codes are fast to work with, since they are used internally by the Perm<4> class.

Precondition
the given code is a valid second-generation permutation code; see isPermCode2() for details.
Parameters
codethe second-generation code that will determine the new value of this permutation.

◆ sign() [1/2]

int regina::Perm< n >::sign ( ) const
constexpr

Determines the sign of this permutation.

Returns
1 if this permutation is even, or -1 if this permutation is odd.

◆ sign() [2/2]

int regina::Perm< 4 >::sign ( ) const
inlineconstexpr

Determines the sign of this permutation.

Returns
1 if this permutation is even, or -1 if this permutation is odd.

◆ SnIndex() [1/2]

Perm< n >::Index regina::Perm< n >::SnIndex ( ) const
constexpr

Returns the index of this permutation in the Perm<n>::Sn array.

See Sn for further information on how these permutations are indexed.

Returns
the index i for which this permutation is equal to Perm<n>::Sn[i]. This will be between 0 and n!-1 inclusive.

◆ SnIndex() [2/2]

Perm< 4 >::Index regina::Perm< 4 >::SnIndex ( ) const
inlineconstexpr

Returns the index of this permutation in the Perm<4>::Sn array.

See Sn for further information on how these permutations are indexed.

Returns
the index i for which this permutation is equal to Perm<4>::Sn[i]. This will be between 0 and 23 inclusive.

◆ str() [1/2]

std::string regina::Perm< n >::str ( ) const

Returns a string representation of this permutation.

The representation will consist of n adjacent digits representing the images of 0,...,n-1 respectively. If n > 10, then lower-case hexadecimal digits will be used.

An example of a string representation for n = 5 is 30421.

Returns
a string representation of this permutation.

◆ str() [2/2]

std::string regina::Perm< 4 >::str ( ) const

Returns a string representation of this permutation.

The representation will consist of four adjacent digits representing the images of 0, 1, 2 and 3 respectively. An example of a string representation is 1302.

Returns
a string representation of this permutation.

◆ tightDecode() [1/2]

Perm< n > regina::Perm< n >::tightDecode ( std::istream & input)
inlinestatic

Reconstructs a permutation from its given tight encoding.

See the page on tight encodings for details.

The tight encoding will be read from the given input stream. If the input stream contains leading whitespace then it will be treated as an invalid encoding (i.e., this routine will throw an exception). The input stream may contain further data: if this routine is successful then the input stream will be left positioned immediately after the encoding, without skipping any trailing whitespace.

Tight encodings are fast to work with for small permutation classes (n ≤ 7), but slower for larger permutation classes (8 ≤ n ≤ 16). See tightEncoding() for further details.

Exceptions
InvalidInputThe given input stream does not begin with a tight encoding of an n-element permutation.
Python
Not present. Use tightDecoding() instead, which takes a string as its argument.
Parameters
inputan input stream that begins with the tight encoding for an n-element permutation.
Returns
the permutation represented by the given tight encoding.

◆ tightDecode() [2/2]

Perm< 4 > regina::Perm< 4 >::tightDecode ( std::istream & input)
inlinestatic

Reconstructs a permutation from its given tight encoding.

See the page on tight encodings for details.

The tight encoding will be read from the given input stream. If the input stream contains leading whitespace then it will be treated as an invalid encoding (i.e., this routine will throw an exception). The input stream may contain further data: if this routine is successful then the input stream will be left positioned immediately after the encoding, without skipping any trailing whitespace.

Tight encodings are fast to work with for small permutation classes (n ≤ 7), but slower for larger permutation classes (8 ≤ n ≤ 16). See tightEncoding() for further details.

Exceptions
InvalidInputThe given input stream does not begin with a tight encoding of a 4-element permutation.
Python
Not present. Use tightDecoding() instead, which takes a string as its argument.
Parameters
inputan input stream that begins with the tight encoding for a 4-element permutation.
Returns
the permutation represented by the given tight encoding.

◆ tightDecoding() [1/2]

Perm< n > regina::Perm< n >::tightDecoding ( const std::string & enc)
inlinestatic

Reconstructs a permutation from its given tight encoding.

See the page on tight encodings for details.

The tight encoding will be given as a string. If this string contains leading whitespace or any trailing characters at all (including trailing whitespace), then it will be treated as an invalid encoding (i.e., this routine will throw an exception).

Tight encodings are fast to work with for small permutation classes (n ≤ 7), but slower for larger permutation classes (8 ≤ n ≤ 16). See tightEncoding() for further details.

Exceptions
InvalidArgumentThe given string is not a tight encoding of an n-element permutation.
Parameters
encthe tight encoding for an n-element permutation.
Returns
the permutation represented by the given tight encoding.

◆ tightDecoding() [2/2]

Perm< 4 > regina::Perm< 4 >::tightDecoding ( const std::string & enc)
inlinestatic

Reconstructs a permutation from its given tight encoding.

See the page on tight encodings for details.

The tight encoding will be given as a string. If this string contains leading whitespace or any trailing characters at all (including trailing whitespace), then it will be treated as an invalid encoding (i.e., this routine will throw an exception).

Tight encodings are fast to work with for small permutation classes (n ≤ 7), but slower for larger permutation classes (8 ≤ n ≤ 16). See tightEncoding() for further details.

Exceptions
InvalidArgumentThe given string is not a tight encoding of a 4-element permutation.
Parameters
encthe tight encoding for a 4-element permutation.
Returns
the permutation represented by the given tight encoding.

◆ tightEncode() [1/2]

void regina::Perm< n >::tightEncode ( std::ostream & out) const

Writes the tight encoding of this permutation to the given output stream.

See the page on tight encodings for details.

For all permutation classes Perm<n>, the tight encoding is based on the index into the full permutation group S_n. For smaller permutation classes (n ≤ 7), such encodings are very fast to work with since the S_n index is used as the internal permutation code. For larger permutation classes however (8 ≤ n ≤ 16), the S_n index requires some non-trivial work to compute.

Python
Not present. Use tightEncoding() instead, which returns a string.
Parameters
outthe output stream to which the encoded string will be written.

◆ tightEncode() [2/2]

void regina::Perm< 4 >::tightEncode ( std::ostream & out) const
inline

Writes the tight encoding of this permutation to the given output stream.

See the page on tight encodings for details.

For all permutation classes Perm<n>, the tight encoding is based on the index into the full permutation group S_n. For smaller permutation classes (n ≤ 7), such encodings are very fast to work with since the S_n index is used as the internal permutation code. For larger permutation classes however (8 ≤ n ≤ 16), the S_n index requires some non-trivial work to compute.

Python
Not present. Use tightEncoding() instead, which returns a string.
Parameters
outthe output stream to which the encoded string will be written.

◆ tightEncoding() [1/2]

std::string regina::Perm< n >::tightEncoding ( ) const

Returns the tight encoding of this permutation.

See the page on tight encodings for details.

For all permutation classes Perm<n>, the tight encoding is based on the index into the full permutation group S_n. For smaller permutation classes (n ≤ 7), such encodings are very fast to work with since the S_n index is used as the internal permutation code. For larger permutation classes however (8 ≤ n ≤ 16), the S_n index requires some non-trivial work to compute.

Returns
the resulting encoded string.

◆ tightEncoding() [2/2]

std::string regina::Perm< 4 >::tightEncoding ( ) const
inline

Returns the tight encoding of this permutation.

See the page on tight encodings for details.

For all permutation classes Perm<n>, the tight encoding is based on the index into the full permutation group S_n. For smaller permutation classes (n ≤ 7), such encodings are very fast to work with since the S_n index is used as the internal permutation code. For larger permutation classes however (8 ≤ n ≤ 16), the S_n index requires some non-trivial work to compute.

Returns
the resulting encoded string.

◆ trunc() [1/2]

std::string regina::Perm< n >::trunc ( int len) const

Returns a prefix of the string representation of this permutation, containing only the images of the first len integers.

Parameters
lenthe length of the prefix required; this must be between 0 and n inclusive.
Returns
the corresponding prefix of the string representation of this permutation.

◆ trunc() [2/2]

std::string regina::Perm< 4 >::trunc ( int len) const

Returns a prefix of the string representation of this permutation, containing only the images of the first len integers.

Parameters
lenthe length of the prefix required; this must be between 0 and 4 inclusive.
Returns
the corresponding prefix of the string representation of this permutation.

◆ trunc2()

std::string regina::Perm< 4 >::trunc2 ( ) const

Returns a string representation of this permutation with only the images of 0 and 1.

The resulting string will therefore have length two.

Returns
a truncated string representation of this permutation.

◆ trunc3()

std::string regina::Perm< 4 >::trunc3 ( ) const

Returns a string representation of this permutation with only the images of 0, 1 and 2 included.

The resulting string will therefore have length three.

Returns
a truncated string representation of this permutation.

Member Data Documentation

◆ code_ [1/2]

Code regina::Perm< n >::code_
protected

The internal code representing this permutation.

◆ code_ [2/2]

Code2 regina::Perm< 4 >::code_
protected

The internal second-generation permutation code representing this permutation.

◆ codeType [1/2]

PermCodeType regina::Perm< n >::codeType
staticconstexpr

Indicates what type of internal permutation code is used by this instance of the Perm class template.

◆ codeType [2/2]

PermCodeType regina::Perm< 4 >::codeType = PermCodeType::Index
staticconstexpr

Indicates what type of internal permutation code is used by this instance of the Perm class template.

◆ degree [1/2]

int regina::Perm< n >::degree
staticconstexpr

The degree of the underlying symmetric group; that is, the template parameter n.

This compile-time constant allows the programmer to extract n from the type (e.g., when writing templated code).

◆ degree [2/2]

int regina::Perm< 4 >::degree = 4
staticconstexpr

The degree of the underlying symmetric group; that is, the template parameter n.

This compile-time constant allows the programmer to extract n from the type (e.g., when writing templated code).

◆ imageBits [1/2]

int regina::Perm< n >::imageBits
staticconstexpr

Indicates the number of bits used in an image pack to store the image of a single integer.

A full image pack combines n such images together, and so uses n * imageBits bits in total.

◆ imageBits [2/2]

int regina::Perm< 4 >::imageBits = 2
staticconstexpr

Indicates the number of bits used in an image pack to store the image of a single integer.

A full image pack combines 4 such images together, and so uses 4 * imageBits bits in total.

◆ imageMask [1/2]

ImagePack regina::Perm< n >::imageMask
staticconstexpr

A bitmask whose lowest imageBits bits are 1, and whose remaining higher order bits are all 0.

This may be useful when creating or analysing image packs.

◆ imageMask [2/2]

ImagePack regina::Perm< 4 >::imageMask
staticconstexpr
Initial value:
=
(static_cast<ImagePack>(1) << imageBits) - 1
static constexpr int imageBits
Indicates the number of bits used in an image pack to store the image of a single integer.
Definition perm4.h:161
typename IntOfMinBits< imageBits *n >::utype ImagePack
Indicates the native unsigned integer type used to store a single image pack.
Definition perm.h:364

A bitmask whose lowest imageBits bits are 1, and whose remaining higher order bits are all 0.

This may be useful when creating or analysing image packs.

◆ nPerms [1/2]

Index regina::Perm< n >::nPerms
staticconstexpr

The total number of permutations on n elements.

This is the size of the symmetric group Sn.

◆ nPerms [2/2]

Index regina::Perm< 4 >::nPerms = 24
staticconstexpr

The total number of permutations on four elements.

This is the size of the array Sn.

◆ nPerms_1 [1/2]

Index regina::Perm< n >::nPerms_1
staticconstexpr

Deprecated constant holding the total number of permutations on n-1 elements.

Deprecated
Just use Perm<n-1>::nPerms instead.

◆ nPerms_1 [2/2]

Index regina::Perm< 4 >::nPerms_1 = 6
staticconstexpr

Deprecated constant holding the total number of permutations on three elements.

Deprecated
Just use Perm<3>::nPerms instead.

◆ orderedS3

detail::PermSubSn<4, 3, PermOrder::Lex> regina::Perm< 4 >::orderedS3 {}
staticconstexpr

Deprecated array-like object that lists all possible permutations of three elements in lexicographical order.

In each permutation, 3 maps to 3.

To access the permutation at index i, you simply use the square bracket operator: orderedS3[i]. The index i must be between 0 and 5 inclusive. Unlike Sn, you cannot iterate over orderedS3 in C++ (though you can still do this in Python).

This array uses the same lexicographical ordering as Perm<3>::orderedS3: specifically, it treats each permutation p as the ordered tuple (p[0], ..., p[2]).

In Regina 6.0.1 and earlier, this was a hard-coded C-style array; since Regina 7.0 it has changed type, but accessing elements as described above remains extremely fast. This is now a lightweight object, and is defined in the headers only; in particular, you cannot make a reference to it (but you can always make a copy).

Deprecated
Instead of Perm<4>::orderedS3[i], you can use Perm<4>::extend(Perm<3>::orderedSn[i]).

◆ orderedS4

PermSn<4, PermOrder::Lex> regina::Perm< 4 >::orderedS4 {}
staticconstexpr

Gives fast access to all possible permutations of four elements in lexicographical order, with support for both array-like indexing and iteration.

This is a dimension-specific alias for Perm<4>::orderedSn; see that member for further information. In general, for every n there will be a static member Perm<n>::orderedSn; however, these numerical aliases Perm<2>::orderedS2, ..., Perm<7>::orderedS7 are only available for small n.

◆ orderedSn [1/2]

PermSn<n, PermOrder::Lex> regina::Perm< n >::orderedSn
staticconstexpr

Gives access to all possible permutations of n elements in lexicographical order, with support for both array-like indexing and iteration.

To access the permutation at index i, you simply use the square bracket operator: orderedSn[i]. The index i must be between 0 and n!-1 inclusive.

You can also iterate over all permutations in orderedSn using a range-based for loop:

for (auto p : Perm<n>::orderedSn) { ... }
static constexpr PermSn< n, PermOrder::Lex > orderedSn
Gives access to all possible permutations of n elements in lexicographical order, with support for bo...
Definition perm.h:514

Lexicographical ordering treats each permutation p as the n-tuple (p[0], p[1], ..., p[n-1]).

This array is different from Perm<n>::Sn, since orderedSn accesses permutations in lexicographical order, whereas Sn alternates between even and odd permutations.

This is a lightweight object, and it is defined in the headers only. In particular, you cannot make a reference to it (but it is cheap to make a copy).

See the PermSn documentation for further details, including time complexity of lookup and iteration.

◆ orderedSn [2/2]

PermSn<4, PermOrder::Lex> regina::Perm< 4 >::orderedSn {}
staticconstexpr

Gives fast access to all possible permutations of four elements in lexicographical order, with support for both array-like indexing and iteration.

To access the permutation at index i, you simply use the square bracket operator: orderedSn[i]. The index i must be between 0 and 23 inclusive.

You can also iterate over all permutations in orderedSn using a range-based for loop:

for (auto p : Perm<4>::orderedSn) { ... }

For this class (and all Perm<n> with n ≤ 7), such index-based access and iteration are both extremely fast.

Lexicographical ordering treats each permutation p as the ordered tuple (p[0], ..., p[3]).

This array is different from Perm<4>::Sn, since orderedSn accesses permutations in lexicographical order, whereas Sn alternates between even and odd permutations.

In Regina 6.0.1 and earlier, this was a hard-coded C-style array; since Regina 7.0 it has changed type, but accessing elements as described above remains extremely fast. This is now a lightweight object, and is defined in the headers only; in particular, you cannot make a reference to it (but you can always make a copy).

◆ S2

detail::PermSubSn<4, 2> regina::Perm< 4 >::S2 {}
staticconstexpr

Deprecated array-like object that lists all possible permutations of two elements.

In each permutation, 2 maps to 2 and 3 maps to 3.

To access the permutation at index i, you simply use the square bracket operator: S2[i]. The index i must be between 0 and 1 inclusive. Unlike Sn, you cannot iterate over S2 in C++ (though you can still do this in Python).

This array uses the same sign-based ordering as Perm<2>::S2: it begins with the identity and alternates between even and odd permutations.

In Regina 6.0.1 and earlier, this was a hard-coded C-style array; since Regina 7.0 it has changed type, but accessing elements as described above remains extremely fast. This is now a lightweight object, and is defined in the headers only; in particular, you cannot make a reference to it (but you can always make a copy).

Deprecated
Instead of Perm<4>::S2[i], you can use Perm<4>::extend(Perm<2>::Sn[i]).

◆ S3

detail::PermSubSn<4, 3> regina::Perm< 4 >::S3 {}
staticconstexpr

Deprecated array-like object that lists all possible permutations of three elements in a sign-based order.

In each permutation, 3 maps to 3.

To access the permutation at index i, you simply use the square bracket operator: S3[i]. The index i must be between 0 and 5 inclusive. Unlike Sn, you cannot iterate over S3 in C++ (though you can still do this in Python).

This array uses the same sign-based ordering as Perm<3>::S3: it begins with the identity and alternates between even and odd permutations.

In Regina 6.0.1 and earlier, this was a hard-coded C-style array; since Regina 7.0 it has changed type, but accessing elements as described above remains extremely fast. This is now a lightweight object, and is defined in the headers only; in particular, you cannot make a reference to it (but you can always make a copy).

Deprecated
Instead of Perm<4>::S3[i], you can use Perm<4>::extend(Perm<3>::Sn[i]).

◆ S4

PermSn<4, PermOrder::Sign> regina::Perm< 4 >::S4 {}
staticconstexpr

Gives fast access to all possible permutations of four elements in a sign-based order, with support for both array-like indexing and iteration.

This is a dimension-specific alias for Perm<4>::Sn; see that member for further information. In general, for every n there will be a static member Perm<n>::Sn; however, these numerical aliases Perm<2>::S2, ..., Perm<7>::S7 are only available for small n.

Note that both permutation classes Perm<4> and Perm<5> have an S4 array; these both store the same 24 permutations in the same order (but of course using different data types).

◆ Sn [1/2]

PermSn<n, PermOrder::Sign> regina::Perm< n >::Sn
staticconstexpr

Gives access to all possible permutations of n elements in a sign-based order, with support for both array-like indexing and iteration.

To access the permutation at index i, you simply use the square bracket operator: Sn[i]. The index i must be between 0 and n!-1 inclusive.

You can also iterate over all permutations in Sn using a range-based for loop:

for (auto p : Perm<n>::Sn) { ... }

The permutations with even indices in the array are the even permutations, and those with odd indices in the array are the odd permutations. The first permutation (at index 0) is the identity.

This array is different from Perm<n>::orderedSn, since Sn alternates between even and odd permutations, whereas orderedSn accesses permutations in lexicographical order.

This is a lightweight object, and it is defined in the headers only. In particular, you cannot make a reference to it (but it is cheap to make a copy).

See the PermSn documentation for further details, including time complexity of lookup and iteration.

◆ Sn [2/2]

PermSn<4, PermOrder::Sign> regina::Perm< 4 >::Sn {}
staticconstexpr

Gives fast access to all possible permutations of four elements in a sign-based order, with support for both array-like indexing and iteration.

To access the permutation at index i, you simply use the square bracket operator: Sn[i]. The index i must be between 0 and 23 inclusive.

You can also iterate over all permutations in Sn using a range-based for loop:

for (auto p : Perm<4>::Sn) { ... }

For this class (and all Perm<n> with n ≤ 7), such index-based access and iteration are both extremely fast.

The permutations with even indices in the array are the even permutations, and those with odd indices in the array are the odd permutations. The first permutation (at index 0) is the identity.

This array is different from Perm<4>::orderedSn, since Sn alternates between even and odd permutations, whereas orderedSn accesses permutations in lexicographical order.

In Regina 6.0.1 and earlier, this was a hard-coded C-style array; since Regina 7.0 it has changed type, but accessing elements as described above remains extremely fast. This is now a lightweight object, and is defined in the headers only; in particular, you cannot make a reference to it (but you can always make a copy).

See the PermSn documentation for further details, including time complexity of lookup and iteration.

◆ Sn_1

detail::PermSubSn<4, 3> regina::Perm< 4 >::Sn_1 {}
staticconstexpr

Deprecated alias for S3, which gives fast array-like access to all possible permutations of three elements in a sign-based order.

See the S3 documentation for further information.

Deprecated
Instead of Perm<4>::Sn_1[i], you can use Perm<4>::extend(Perm<3>::Sn[i]).

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