Permutations¶
This page contains the documentation for functionality in
libsemigroups_pybind11 for permutations.
Permutations on up to 4294967296 points are available in
libsemigroups_pybind11 using the function Perm.
Perm is a function that returns an instance of one of a number of
internal classes. These internal types are optimised for the number of points
in the image of the specified permutation with fewer points requiring less
space per point. If libsemigroups has been compiled with HPCombi
enabled, then the objects returned by Perm use the SSE and AVX
instruction sets are used for very fast manipulation.
While Perm is not a class the objects returned by
Perm have identical methods, and so we document
Perm as if it was a class.
- class Perm¶
Instances of this class implement permutations.
A permutation \(f\) is just a bijective function defined on the whole of \(\{0,1,\ldots,n−1\}\) for some positive integer \(n\) called the degree of \(f\). A permutation is stored as an array of the images \(\{(0)f,(1)f,\ldots,(n−1)f\}\).
- __eq__(self: Perm, that: Perm) bool¶
Equality comparison.
Returns
Trueifselfequalsthatby comparing their image values.- Parameters
that (Perm) -- the permutation for comparison.
- Returns
A
bool.
- __getitem__(self: Perm, i: int) int¶
Returns the image of
i.- Parameters
i (int) -- the value whose image is sought.
- Returns
An
int.
- __lt__(self: Perm, that: Perm) bool¶
Less than comparison.
Returns
Trueif the list of images ofselfis lexicographically less than the list of images ofthat.- Parameters
that (Perm) -- the permutation for comparison.
- Returns
A
bool.
- degree(self: Perm) int¶
Returns the degree.
Returns the number of points that the permutation is defined on.
- Parameters
None- Returns
An
int.
- identity(self: Perm) int¶
Returns the identity permutation on
degree()points.- Parameters
None
- Returns
A
Perm.
- static make(l: List[int]) Perm¶
Construct and validate.
Constructs a permutation initialized using list
las follows: the image of the pointiunder the permutation isl[i].- Parameters
l (List[int]) -- the list of images.
- Returns
A newly constructed permutation.
- Return type
- Raises
RuntimeError -- if any value in
lexceedslen(l).
- static make_identity(M: int) Perm¶
Returns the identity permutation on the given number of points.
- Parameters
M (int) - the degree.
- Returns
A value of type
Perm.
- product_inplace(self: Perm, x: Perm, y: Perm) None¶
Multiply two permutations and store the product in
self.
- rank(self: Perm) int¶
Returns the number of distinct image values.
The rank of a permutation is the number of its distinct image values.
- Parameters
None
- Returns
An
int.