The Transf class
Class for representing transformations on up to 2 ** 32 points.
A transformation \(f\) is just a function defined on the whole of \(\{0, 1, \ldots, n - 1\}\) for some integer \(n\) called the degree of \(f\). A transformation is stored as a list of the images of \(\{0, 1, \ldots, n - 1\}\), i.e. \([(0)f, (1)f, \ldots, (n - 1)f]\).
Transformations are optimised for the number of points in the image with fewer points requiring less space per point.
>>> from libsemigroups_pybind11.transf import Transf, one
>>> x = Transf([0, 0, 2, 2, 0, 1])
>>> x.degree()
6
>>> x[0]
0
>>> x[5]
1
>>> x
Transf([0, 0, 2, 2, 0, 1])
>>> x * x
Transf([0, 0, 2, 2, 0, 0])
>>> x < x * x
False
>>> y = Transf([9, 7, 3, 5, 3, 4, 2, 7, 7, 1])
>>> x = one(y)
>>> x.product_inplace(y, y)
>>> x
Transf([1, 7, 5, 4, 5, 3, 3, 7, 7, 7])
>>> list(x.images())
[1, 7, 5, 4, 5, 3, 3, 7, 7, 7]
>>> x.rank()
5
>>> one(x)
Transf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> x = Transf.one(8)
>>> x
Transf([0, 1, 2, 3, 4, 5, 6, 7])
>>> x.degree()
8
>>> x.swap(y)
>>> x, y
(Transf([9, 7, 3, 5, 3, 4, 2, 7, 7, 1]), Transf([0, 1, 2, 3, 4, 5, 6, 7]))
>>> x = Transf([1, 0, 2])
>>> y = x.copy()
>>> x is y
False
>>> x == y
True
>>> {x, y}
{Transf([1, 0, 2])}
Contents
| Class for representing transformations on up to  | |
| 
 | Copy a transformation. | 
| Returns an iterator to the images of a transformation. | |
| Increases the degree of self in-place, leaving existing values unaltered. | |
| 
 | Returns the identity transformation on N points. | 
| Replaces the contents of self by the product of x and y. | |
| 
 | Returns the number of distinct image values in a transformation. | 
| 
 | Swap with another transformation of the same type. | 
Full API
- class Transf
- __init__(self: Transf, imgs: list[int]) None
- A transformation can be constructed from a list of images, as follows: the image of the point - iunder the transformation is- imgs[i].- Parameters:
- Raises:
- LibsemigroupsError – if any value in imgs exceeds - len(imgs).
- Complexity:
- Linear in - degree().
 
 - degree(self: Transf) int
- Returns the degree of a transformation. - The degree of a transformation is the number of points used in its definition, which is equal to the size of - Transf.images.- Returns:
- The degree. 
- Return type:
 
 - images(self: Transf) collections.abc.Iterator[int]
- Returns an iterator to the images of a transformation. - A transformation is stored as a list of the images of \(\{0, 1, \ldots, n - 1\}\), i.e. \([(0)f, (1)f, \ldots, (n - 1)f]\), and this function returns an iterator yielding these values. - Returns:
- An iterator to the image values. 
- Return type:
 
 - increase_degree_by(self: Transf, m: int) Transf
- Increases the degree of self in-place, leaving existing values unaltered. 
 - static one(N: int) Transf
- Returns the identity transformation on N points. This function returns a newly constructed transformation with degree equal to N that fixes every value from - 0to N.
 - product_inplace(self: Transf, x: Transf, y: Transf) None
- Replaces the contents of self by the product of x and y.