Regina 7.4 Calculation Engine
|
Represents a permutation of {0,1,2,3,4}. More...
#include <maths/spec/perm5.h>
Public Types | |
using | Index = int |
Denotes a native signed integer type large enough to count all permutations on five elements. | |
using | ImagePack = uint16_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. | |
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, int e) |
Creates a permutation mapping (0,1,2,3,4) to (a,b,c,d,e) respectively. | |
constexpr | Perm (const std::array< int, 5 > &image) |
Creates a permutation mapping i to image[i] for each i = 0,1,2,3,4. | |
constexpr | Perm (int a0, int a1, int b0, int b1, int c0, int c1, int d0, int d1, int e0, int e1) |
Creates a permutation mapping (a0,b0,c0,d0,e0) to (a1,b1,c1,d1,e1) respectively. | |
constexpr | Perm (const Perm< 5 > &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< 5 > & | operator= (const Perm< 5 > &cloneMe)=default |
Sets this permutation to be equal to the given permutation. | |
constexpr Perm< 5 > | operator* (const Perm< 5 > &q) const |
Returns the composition of this permutation with the given permutation. | |
Perm< 5 > | cachedComp (const Perm< 5 > &q) const |
An alias for the composition operator, provided to assist with writing generic code. | |
Perm< 5 > | cachedComp (const Perm< 5 > &q, const Perm< 5 > &r) const |
Deprecated alias for using the composition operator twice, provided to assist with writing generic code. | |
constexpr Perm< 5 > | conjugate (const Perm< 5 > &q) const |
Computes the conjugate of this permutation by q. | |
Perm< 5 > | cachedConjugate (const Perm< 5 > &q) const |
An alias for conjugate(), provided to assist with writing generic code. | |
constexpr Perm< 5 > | inverse () const |
Finds the inverse of this permutation. | |
Perm< 5 > | cachedInverse () const |
An alias for inverse(), provided to assist with writing generic code. | |
constexpr Perm< 5 > | pow (long exp) const |
Computes the given power of this permutation. | |
Perm< 5 > | 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< 5 > | 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< 5 > &other) const |
Lexicographically compares the images of (0,1,2,3,4) under this and the given permutation. | |
constexpr bool | isIdentity () const |
Determines if this is the identity permutation. | |
Perm< 5 > & | operator++ () |
A preincrement operator that changes this to be the next permutation in the array Perm<5>::Sn. | |
constexpr Perm< 5 > | operator++ (int) |
A postincrement operator that changes this to be the next permutation in the array Perm<5>::Sn. | |
constexpr std::strong_ordering | operator<=> (const Perm &) const =default |
Compares two permutations according to which appears earlier in the array Perm<5>::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. | |
std::string | trunc4 () const |
Returns a string representation of this permutation with only the images of 0, 1, 2 and 3. | |
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<5>::Sn array. | |
constexpr Index | S5Index () const |
Returns the index of this permutation in the Perm<5>::Sn array. | |
constexpr Index | orderedSnIndex () const |
Returns the lexicographical index of this permutation. | |
constexpr Index | orderedS5Index () const |
Returns the lexicographical index of this permutation. | |
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< 5 > | fromPermCode1 (Code1 code) |
Creates a permutation from the given first-generation permutation code. | |
static constexpr Perm< 5 > | 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 5-element permutation. | |
static constexpr Perm | rot (int i) |
Returns the ith rotation. | |
static Perm | rand (bool even=false) |
Returns a random permutation on five elements. | |
template<class URBG > | |
static Perm | rand (URBG &&gen, bool even=false) |
Returns a random permutation on five 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< 5 > | extend (Perm< k > p) |
Extends a k-element permutation to a 5-element permutation, where 2 ≤ k < 5. | |
template<int k> | |
static constexpr Perm< 5 > | contract (Perm< k > p) |
Restricts a k-element permutation to an 5-element permutation, where k > 5. | |
Static Public Attributes | |
static constexpr int | degree = 5 |
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 = 120 |
The total number of permutations on five elements. | |
static constexpr Index | nPerms_1 = 24 |
Deprecated constant holding the total number of permutations on four elements. | |
static constexpr int | imageBits = 3 |
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< 5, PermOrder::Sign > | Sn {} |
Gives fast access to all possible permutations of five elements in a sign-based order, with support for both array-like indexing and iteration. | |
static constexpr PermSn< 5, PermOrder::Sign > | S5 {} |
Gives fast access to all possible permutations of five elements in a sign-based order, with support for both array-like indexing and iteration. | |
static constexpr PermSn< 5, PermOrder::Lex > | orderedSn {} |
Gives fast access to all possible permutations of five elements in lexicographical order, with support for both array-like indexing and iteration. | |
static constexpr PermSn< 5, PermOrder::Lex > | orderedS5 {} |
Gives fast access to all possible permutations of five elements in lexicographical order, with support for both array-like indexing and iteration. | |
static constexpr detail::PermSubSn< 5, 4 > | S4 {} |
Deprecated array-like object that lists all possible permutations of four elements in a sign-based order. | |
static constexpr detail::PermSubSn< 5, 4 > | Sn_1 {} |
Deprecated alias for S4, which gives fast array-like access to all possible permutations of four elements in a sign-based order. | |
static constexpr detail::PermSubSn< 5, 4, PermOrder::Lex > | orderedS4 {} |
Deprecated array-like object that lists all possible permutations of four elements in lexicographical order. | |
static constexpr detail::PermSubSn< 5, 3 > | S3 {} |
Deprecated array-like object that lists all possible permutations of three elements in a sign-based order. | |
static constexpr detail::PermSubSn< 5, 3, PermOrder::Lex > | orderedS3 {} |
Deprecated array-like object that lists all possible permutations of three elements in lexicographical order. | |
static constexpr detail::PermSubSn< 5, 2 > | S2 {} |
Deprecated array-like object that lists all possible permutations of two elements. | |
Protected Member Functions | |
constexpr | Perm (Code2 code) |
Creates a permutation from the given second-generation permutation code. | |
Protected Attributes | |
Code2 | code2_ |
The internal second-generation permutation code representing this permutation. | |
Friends | |
class | PermSn< 5, PermOrder::Sign > |
class | PermSn< 5, PermOrder::Lex > |
Represents a permutation of {0,1,2,3,4}.
This is a specialisation of the generic Perm template: it is highly optimised, and also offers some additional functionality. Amongst other things, this permutation class is used to specify how simplices of a 4-manifold triangulation are glued together.
As with all Perm template classes, these objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.
Each permutation has an internal code, which is a single native integer that is sufficient to reconstruct the permutation. Thus the internal code may be a useful means for passing permutation objects to and from the engine. For Perm<5>, the internal permutation codes have changed as of Regina 7.0:
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<5>).
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:
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.
using regina::Perm< 5 >::Code1 = ImagePack |
Indicates the native unsigned integer type used to store a first-generation permutation code.
using regina::Perm< 5 >::Code2 = uint8_t |
Indicates the native unsigned integer type used to store a second-generation permutation code.
using regina::Perm< 5 >::ImagePack = uint16_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.
using regina::Perm< 5 >::Index = int |
Denotes a native signed integer type large enough to count all permutations on five elements.
In other words, this is a native signed integer type large enough to store (5!).
|
inlineconstexpr |
Creates the identity permutation.
|
inlineconstexpr |
Creates the transposition of a and b.
Note that a and b need not be distinct.
a | the element to switch with b. |
b | the element to switch with a. |
|
inlineconstexpr |
Creates a permutation mapping (0,1,2,3,4) to (a,b,c,d,e) respectively.
a | the desired image of 0. |
b | the desired image of 1. |
c | the desired image of 2. |
d | the desired image of 3. |
e | the desired image of 4. |
|
inlineconstexpr |
Creates a permutation mapping i to image[i] for each i = 0,1,2,3,4.
image | the array of images. |
|
inlineconstexpr |
Creates a permutation mapping (a0,b0,c0,d0,e0) to (a1,b1,c1,d1,e1) respectively.
a0 | the desired preimage of a1. |
b0 | the desired preimage of b1. |
c0 | the desired preimage of c1. |
d0 | the desired preimage of d1. |
e0 | the desired preimage of e1. |
a1 | the desired image of a0. |
b1 | the desired image of b0. |
c1 | the desired image of c0. |
d1 | the desired image of d0. |
e1 | the desired image of e0. |
|
constexprdefault |
Creates a permutation that is a clone of the given permutation.
cloneMe | the permutation to clone. |
|
inlineconstexprprotected |
Creates a permutation from the given second-generation permutation code.
code | the second-generation code from which the new permutation will be created. |
|
inline |
An alias for the composition operator, provided to assist with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations. The only point of having cachedComp() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
The permutation that is returned is the same as you would obtain by calling (*this) * q
.
q | the permutation to compose this with. |
|
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
.
q | the first permutation to compose this with. |
r | the second permutation to compose this with. |
|
inline |
An alias for conjugate(), provided to assist with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations. The only point of having cachedConjugate() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
q | the permutation to conjugate this by. |
|
inline |
An alias for inverse(), provided to assist with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations. The only point of having cachedInverse() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
|
inline |
An alias for order(), provided to assist with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations. The only point of having cachedOrder() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
|
inline |
An alias for pow(), provided to assist with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations. The only point of having cachedPow() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
exp | the exponent; this may be positive, zero or negative. |
void regina::Perm< 5 >::clear | ( | unsigned | from | ) |
Resets the images of all integers from from onwards to the identity map.
Specifically, for each i in the range from,...,4, this routine will ensure that image[i] == i
. The images of 0,1,...,from-1 will not be altered.
from | the first integer whose image should be reset. This must be between 0 and 5 inclusive. |
|
inlineconstexpr |
Lexicographically compares the images of (0,1,2,3,4) 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.
other | the permutation with which to compare this. |
|
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.
q | the permutation to conjugate this by. |
|
staticconstexpr |
Restricts a k-element permutation to an 5-element permutation, where k > 5.
The resulting permutation will map 0,...,4 to their respective images under p, and will ignore the "unused" images p[5],...,p[k-1].
k | the number of elements for the input permutation; this must be strictly greater than 5. |
p | a permutation on k elements. |
|
staticconstexpr |
Extends a k-element permutation to a 5-element permutation, where 2 ≤ k < 5.
The resulting permutation will map 0,...,k-1 to their respective images under p, and will map the "unused" elements k,...,4 to themselves.
k | the number of elements for the input permutation; this must be 2, 3 or 4. |
p | a permutation on k elements. |
|
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<5>, this routine is identical to fromPermCode1().
pack | an image pack that describes a permutation. |
|
inlinestaticconstexpr |
Creates a permutation from the given first-generation permutation code.
code | the first-generation code for the new permutation. |
|
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<5> class.
code | the second-generation code for the new permutation. |
|
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<5> 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.
|
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<5>, this routine is identical to permCode1().
|
inlineconstexpr |
Finds the inverse of this permutation.
|
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<5>::Sn.
See Sn for further information on how permutations are indexed.
This routine is extremely fast for Perm<5>, since it essentially uses a hard-coded lookup table.
true
if and only if this permutation is minimal in its conjugacy class.
|
inlineconstexpr |
Determines if this is the identity permutation.
This is true if and only if each of 0, 1, 2, 3 and 4 is mapped to itself.
true
if and only if this is the identity permutation.
|
inlinestaticconstexpr |
Determines whether the given argument is the image pack of some 5-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<5>, this routine is identical to isPermCode1().
pack | the candidate image pack to test. |
true
if and only if pack is a valid image pack.
|
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().
code | the permutation code to test. |
true
if and only if the given code is a valid first-generation permutation 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<5> class.
code | the permutation code to test. |
true
if and only if the given code is a valid second-generation permutation code.
|
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]]
.
q | the permutation with which to compose this. |
|
inline |
A preincrement operator that changes this to be the next permutation in the array Perm<5>::Sn.
If this is the last such permutation then this will wrap around to become the first permutation in Perm<5>::Sn, which is the identity.
|
inlineconstexpr |
A postincrement operator that changes this to be the next permutation in the array Perm<5>::Sn.
If this is the last such permutation then this will wrap around to become the first permutation in Perm<5>::Sn, which is the identity.
|
constexprdefault |
Compares two permutations according to which appears earlier in the array Perm<5>::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 >=
.
x <=> y
is not available, but the other comparison operators that it generates are available.
|
default |
Sets this permutation to be equal to the given permutation.
cloneMe | the permutation whose value will be assigned to this permutation. |
|
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, 3 and 4.
true
if and only if this and the given permutation are equal.
|
inlineconstexpr |
Determines the image of the given integer under this permutation.
source | the integer whose image we wish to find. This should be between 0 and 4 inclusive. |
|
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.
|
inlineconstexpr |
Returns the lexicographical index of this permutation.
This will be the index of this permutation in the Perm<5>::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.
|
inlineconstexpr |
Returns the lexicographical index of this permutation.
This will be the index of this permutation in the Perm<5>::orderedSn array.
See orderedSn for further information on lexicographical ordering.
|
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().
|
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<5> class.
|
inlineconstexpr |
Computes the given power of this permutation.
This routine runs in constant time.
exp | the exponent; this may be positive, zero or negative. |
|
inlineconstexpr |
Determines the preimage of the given integer under this permutation.
image | the integer whose preimage we wish to find. This should be between 0 and 4 inclusive. |
|
inlinestaticconstexpr |
A do-nothing routine that assists with writing generic code.
This specialised Perm<5> class does not use precomputation for its optimisations, and so this precompute() function does nothing. The only point of having precompute() in Perm<5> is to make it easier to write generic code that works with Perm<n> for any n.
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).
|
inlinestatic |
Returns a random permutation on five elements.
All permutations are returned with equal probability.
This routine is thread-safe, and uses RandomEngine for its random number generation.
rand(randomEngine.engine(), even)
.even | if true , then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability). |
|
static |
Returns a random permutation on five 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.
URBG | A type which, once any references are removed, must adhere to the C++ UniformRandomBitGenerator concept. |
gen | the source of randomness to use (e.g., one of the many options provided in the C++ standard random header). |
even | if true , then the resulting permutation is guaranteed to be even (and again all even permutations are returned with equal probability). |
|
inlineconstexpr |
Finds the reverse of this permutation.
Here reverse means that we reverse the images of 0,...,4. In other words, if permutation q is the reverse of p, then p[i] == q[4 - i]
for all i.
|
inlinestaticconstexpr |
Returns the ith rotation.
This maps k to k + i (mod 5) for all k.
i | the image of 0; this must be between 0 and 4 inclusive. |
|
inlineconstexpr |
Returns the index of this permutation in the Perm<5>::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.
|
inline |
Sets this permutation to that represented by the given first-generation permutation code.
code | the first-generation code that will determine the new value of this permutation. |
|
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<5> class.
code | the second-generation code that will determine the new value of this permutation. |
|
inlineconstexpr |
Determines the sign of this permutation.
|
inlineconstexpr |
Returns the index of this permutation in the Perm<5>::Sn array.
See Sn for further information on how these permutations are indexed.
std::string regina::Perm< 5 >::str | ( | ) | const |
Returns a string representation of this permutation.
The representation will consist of five adjacent digits representing the images of 0, 1, 2, 3 and 4 respectively. An example of a string representation is 30421
.
|
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.
InvalidInput | The given input stream does not begin with a tight encoding of a 5-element permutation. |
input | an input stream that begins with the tight encoding for a 5-element permutation. |
|
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.
InvalidArgument | The given string is not a tight encoding of a 5-element permutation. |
enc | the tight encoding for a 5-element permutation. |
|
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.
out | the output stream to which the encoded string will be written. |
|
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.
std::string regina::Perm< 5 >::trunc | ( | int | len | ) | const |
Returns a prefix of the string representation of this permutation, containing only the images of the first len integers.
len | the length of the prefix required; this must be between 0 and 5 inclusive. |
std::string regina::Perm< 5 >::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.
std::string regina::Perm< 5 >::trunc3 | ( | ) | const |
Returns a string representation of this permutation with only the images of 0, 1 and 2.
The resulting string will therefore have length three.
std::string regina::Perm< 5 >::trunc4 | ( | ) | const |
Returns a string representation of this permutation with only the images of 0, 1, 2 and 3.
The resulting string will therefore have length four.
|
protected |
The internal second-generation permutation code representing this permutation.
|
staticconstexpr |
Indicates what type of internal permutation code is used by this instance of the Perm class template.
|
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).
|
staticconstexpr |
Indicates the number of bits used in an image pack to store the image of a single integer.
A full image pack combines 5 such images together, and so uses 5 * imageBits bits in total.
|
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.
|
staticconstexpr |
The total number of permutations on five elements.
This is the size of the array Sn.
|
staticconstexpr |
Deprecated constant holding the total number of permutations on four elements.
|
staticconstexpr |
Deprecated array-like object that lists all possible permutations of three elements in lexicographical order.
In each permutation, 3 maps to 3 and 4 maps to 4.
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).
Perm<5>::orderedS3[i]
, you can use Perm<5>::extend(Perm<3>::orderedSn[i])
.
|
staticconstexpr |
Deprecated array-like object that lists all possible permutations of four elements in lexicographical order.
In each permutation, 4 maps to 4.
To access the permutation at index i, you simply use the square bracket operator: orderedS4[i]
. The index i must be between 0 and 23 inclusive. Unlike Sn, you cannot iterate over orderedS4 in C++ (though you can still do this in Python).
This array uses the same lexicographical ordering as Perm<4>::orderedS4
: specifically, it treats each permutation p as the ordered tuple (p[0], ..., p[3])
.
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).
Perm<5>::orderedS4[i]
, you can use Perm<5>::extend(Perm<4>::orderedSn[i])
.
|
staticconstexpr |
Gives fast access to all possible permutations of five elements in lexicographical order, with support for both array-like indexing and iteration.
This is a dimension-specific alias for Perm<5>::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.
|
staticconstexpr |
Gives fast access to all possible permutations of five 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 119 inclusive.
You can also iterate over all permutations in orderedSn using a range-based for
loop:
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[4])
.
This array is different from Perm<5>::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).
|
staticconstexpr |
Deprecated array-like object that lists all possible permutations of two elements.
In each permutation, 2 maps to 2, 3 maps to 3, and 4 maps to 4.
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).
Perm<5>::S2[i]
, you can use Perm<5>::extend(Perm<2>::Sn[i])
.
|
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 and 4 maps to 4.
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).
Perm<5>::S3[i]
, you can use Perm<5>::extend(Perm<3>::Sn[i])
.
|
staticconstexpr |
Deprecated array-like object that lists all possible permutations of four elements in a sign-based order.
In each permutation, 4 maps to 4.
To access the permutation at index i, you simply use the square bracket operator: S4[i]
. The index i must be between 0 and 23 inclusive. Unlike Sn, you cannot iterate over S4 in C++ (though you can still do this in Python).
This array uses the same sign-based ordering as Perm<4>::S4
: 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).
Perm<5>::S4[i]
, you can use Perm<5>::extend(Perm<4>::Sn[i])
.
|
staticconstexpr |
Gives fast access to all possible permutations of five elements in a sign-based order, with support for both array-like indexing and iteration.
This is a dimension-specific alias for Perm<5>::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.
|
staticconstexpr |
Gives fast access to all possible permutations of five 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 119 inclusive.
You can also iterate over all permutations in Sn using a range-based for
loop:
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<5>::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.
|
staticconstexpr |
Deprecated alias for S4, which gives fast array-like access to all possible permutations of four elements in a sign-based order.
See the S4 documentation for further information.
Perm<5>::Sn_1[i]
, you can use Perm<5>::extend(Perm<4>::Sn[i])
.