Regina 7.4 Calculation Engine
regina::detail::PermSubSn< n, m, order > Struct Template Reference

A lightweight array-like object that indexes smaller permutations within larger permutation groups; that is, it embeds the group S_m inside S_n for some n > m. More...

#include <maths/permsn.h>

Public Member Functions

constexpr Perm< n > operator[] (int index) const
 Returns the permutation at the given index.
 
constexpr int size ()
 Returns the total number of permutations on m objects.
 
constexpr bool operator== (const PermSubSn &) const
 A trivial equality test that always returns true.
 

Static Public Member Functions

static constexpr Perm< n > at (int index)
 Returns the permutation at the given index.
 

Detailed Description

template<int n, int m, PermOrder order = PermOrder::Sign>
struct regina::detail::PermSubSn< n, m, order >

A lightweight array-like object that indexes smaller permutations within larger permutation groups; that is, it embeds the group S_m inside S_n for some n > m.

This class is not intended for end users. Its main purpose is to support other parts of Regina's API, such as Perm<n>::extend(), and some old (and now deprecated) permutation class constants such as Perm<4>::S3. This class is hard-coded only for some specific small values of n and m (where the operations are trivial or the compiler can use small lookup tables). If you need to express a smaller permutation using a larger permutation class, you should use Perm<n>::extend() instead.

This class only offers index-based lookup: you can either use the static function at(index), or you can treat an object of this class like a container and use c[index] and c.size() (and in Python, len(c)). This class does not support iteration in C++ (although Python still allows it because Python detects the array-like structure).

Permutations are indexed according to the template parameter order. In particular, PermSubSn<n, m, order> indexes permutations in the same order as PermSn<m, order>.

All operations in this class are fast constant time.

Objects of this type contain no data at all, which means they are trivial to pass by value or swap with std::swap(), and all objects of this type are essentially identical.

Warning
This class may be altered or removed without notice from a future version of Regina, since this is essentially an internal class designed to support deprecated constants such as Perm<4>::S3. The "officially supported" way of accessing the ith permutation of m objects using the type Perm<n> is Perm<n>::extend(Perm<m>::Sn[i]).
Python
This class does not live inside an inner detail namespace, though as an internal class it is subject to change or removal without notice (see the warning above). Moreover, Python does not support templates, and so the name of this class is constructed by appending n, m and order as suffixes (e.g., PermSubSn4_3_Sign, or PermSubSn5_3_Lex). The only template parameters that are bound in Python are those that are used in Regina's public-facing API (specifically, those that are used by deprecated constants such as Perm4.S3).
Template Parameters
nindicates the return type: permutations of m objects will be returned as the larger type Perm<n>. It is required that 2 ≤ n ≤ 5.
mthe number of objects being permuted in the group S_m that we are enumerating. It is required that 1 ≤ m < n.
orderthe way in which this class orders permutations for the purposes of indexing.

Member Function Documentation

◆ at()

template<int n, int m, PermOrder order = PermOrder::Sign>
static constexpr Perm< n > regina::detail::PermSubSn< n, m, order >::at ( int index)
staticconstexpr

Returns the permutation at the given index.

This is a permutation on m objects being returned as the larger type Perm<n>, and so the unused elements m,m+1,...,n-1 will all be mapped to themselves.

Parameters
indexan index between 0 and m!-1 inclusive.
Returns
the corresponding permutation of m objects.

◆ operator==()

template<int n, int m, PermOrder order = PermOrder::Sign>
bool regina::detail::PermSubSn< n, m, order >::operator== ( const PermSubSn< n, m, order > & ) const
constexpr

A trivial equality test that always returns true.

Since PermSubSn contains no data of its own, any two PermSubSn objects of the same type (i.e., using the same template parameters) will always describe the same sequence of permutations in the same order.

Returns
true, always.

◆ operator[]()

template<int n, int m, PermOrder order = PermOrder::Sign>
Perm< n > regina::detail::PermSubSn< n, m, order >::operator[] ( int index) const
constexpr

Returns the permutation at the given index.

This is a permutation on m objects being returned as the larger type Perm<n>, and so the unused elements m,m+1,...,n-1 will all be mapped to themselves.

This operator is identical to calling the static member function at(). It is provided for convenience so that permutations can be accessed using array-like syntax.

Parameters
indexan index between 0 and m!-1 inclusive.
Returns
the corresponding permutation of m objects.

◆ size()

template<int n, int m, PermOrder order = PermOrder::Sign>
int regina::detail::PermSubSn< n, m, order >::size ( )
constexpr

Returns the total number of permutations on m objects.

This of course is just m!.

Python
This is also used to implement the Python special method len().
Returns
the total number of permutations.

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