The PPerm16 class
Class representing partial permutations.
SIMD accelerated class PPerm16 representing partial permutations on
up to 16 points (i.e. bijections between subsets of \(\{0\dots 15\}\)).
Undefined images are encoded as 255.
This class belongs to the hpcombi subpackage of libsemigroups_pybind11.
The functionality described on this page is only available if
LIBSEMIGROUPS_HPCOMBI_ENABLED is True.
Contents
Class representing partial permutations. |
|
|
Copy a |
Returns the inverse permutation. |
|
Returns the left one of a partial transformation. |
|
|
Returns the identity permutation. |
Returns the right one of a partial transformation. |
|
Check whether or not a |
Full API
- class hpcombi.PPerm16
- __init__(*args, **kwargs)
Overloaded function.
- __init__(self: PPerm16) None
Default constructor.
Constructs a
PPerm16object with its entries uninitialized. This means there is no guarantee about the values in the constructed object.>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16()
- __init__(self: PPerm16, dom: list[int], im: list[int]) None
Construct from domain and image.
Constructs a partial permutation of degree n such that
(dom[i])f = im[i]for alliand which is undefined (255represents undefined in this context) on every other value in the range \([0, n)\).- Parameters:
- Raises:
LibsemigroupsError – dom and im do not have the same size.
LibsemigroupsError – any value in dom or im is greater than 15.
LibsemigroupsError – there are repeated entries in dom or im.
TypeError – any value in dom or im is greater than 15.
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> PPerm16([1, 2], [3, 4]) PPerm16([255, 3, 4,255,255,255,255,255,255,255,255,255,255,255,255,255])
- __init__(self: PPerm16, img: list[int]) None
Construct a
PPerm16from a list of images.This function constructs a
PPerm16from the list img of its entries. If the length of img is less than16, then the constructedPPerm16is padded with fixed points at the end.- Parameters:
- Raises:
LibsemigroupsError – if any value in img exceeds
16and is not equal to255.LibsemigroupsError – if the length of img exceeds
16.TypeError – if any value in img is larger than
255.
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> PPerm16([1, 255, 4, 10]) PPerm16([ 1,255, 4,10, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15])
- copy(self: PPerm16) PPerm16
Copy a
PPerm16.- Returns:
A copy of the argument.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16([1, 2, 3, 4, 0]) >>> x.copy() is not x True >>> x.copy() == x True
- inverse_ref(self: PPerm16) PPerm16
Returns the inverse permutation.
This function returns the inverse of self. The inverse of a partial perm \(x\) is the unique partial permutation \(y\) such that \(xyx = x\) and \(xyx = x\).
- Returns:
The inverse of self.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16([0,3,2,4,1]) >>> x.inverse_ref() PPerm16([ 0, 4, 2, 1, 3, 5, 6, 7, 8, 9,10,11,12,13,14,15])
- left_one(self: PPerm16) PPerm16
Returns the left one of a partial transformation.
This function returns a newly constructed
PPerm16with the same image as self and that acts as the identity on self by left multiplication.- Returns:
The left one of self.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16([1, 3, 4, 255, 10]) >>> x.left_one() * x == x True
- static one() PPerm16
Returns the identity permutation.
This function returns the identity
PPerm16which fixes every value in \([0, 16)\).- Returns:
The identity permutation.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16([1, 2, 0]) >>> x * x.one() == PPerm16.one() * x == x True
- right_one(self: PPerm16) PPerm16
Returns the right one of a partial transformation.
This function returns a newly constructed
PPerm16with the same image as self and that acts as the identity on self by right multiplication.- Returns:
The right one of self.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> x = PPerm16([1, 3, 4, 255, 10]) >>> x * x.right_one() == x True
- validate(self: PPerm16, bound: int = 16) bool
Check whether or not a
PPerm16is well-defined.This function returns
Trueif self is a well-defined partial permutation (i.e. no defined image value is larger than15and no repeated image value) on the values0up to bound.- Parameters:
bound (int) – the bound (defaults to
16).- Returns:
Whether or not self is valid.
- Return type:
>>> from libsemigroups_pybind11.hpcombi import PPerm16 >>> PPerm16([1, 0, 2]).validate() True >>> x = PPerm16([1, 0, 2]) >>> x[0] = 0 >>> x.validate() False