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.

Perm16 inherits from PTransf16.

Contents

PPerm16

Class representing partial permutations.

PPerm16.copy(…)

Copy a PPerm16.

PPerm16.inverse_ref(…)

Returns the inverse permutation.

PPerm16.left_one(…)

Returns the left one of a partial transformation.

PPerm16.one(…)

Returns the identity permutation.

PPerm16.right_one(…)

Returns the right one of a partial transformation.

PPerm16.validate(…)

Check whether or not a PPerm16 is well-defined.

Full API

class hpcombi.PPerm16
__init__(*args, **kwargs)

Overloaded function.

__init__(self: PPerm16) None

Default constructor.

Constructs a PPerm16 object 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 all i and which is undefined (255 represents undefined in this context) on every other value in the range \([0, n)\).

Parameters:
Raises:
>>> 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 PPerm16 from a list of images.

This function constructs a PPerm16 from the list img of its entries. If the length of img is less than 16, then the constructed PPerm16 is padded with fixed points at the end.

Parameters:

img (list[int]) – The list of images.

Raises:
>>> 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:

PPerm16

>>> 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:

PPerm16

>>> 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 PPerm16 with the same image as self and that acts as the identity on self by left multiplication.

Returns:

The left one of self.

Return type:

PPerm16

>>> 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 PPerm16 which fixes every value in \([0, 16)\).

Returns:

The identity permutation.

Return type:

PPerm16

>>> 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 PPerm16 with the same image as self and that acts as the identity on self by right multiplication.

Returns:

The right one of self.

Return type:

PPerm16

>>> 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 PPerm16 is well-defined.

This function returns True if self is a well-defined partial permutation (i.e. no defined image value is larger than 15 and no repeated image value) on the values 0 up to bound.

Parameters:

bound (int) – the bound (defaults to 16).

Returns:

Whether or not self is valid.

Return type:

bool

>>> from libsemigroups_pybind11.hpcombi import PPerm16
>>> PPerm16([1, 0, 2]).validate()
True
>>> x = PPerm16([1, 0, 2])
>>> x[0] = 0
>>> x.validate()
False