BMat8

Class for fast boolean matrices of dimension up to 8 x 8

The functions for these small matrices over the boolean semiring are more optimised than the generic methods for boolean matrices. Note that all BMat8 are represented internally as an 8 x 8 matrix; any entries not defined by the user are taken to be 0. This does not affect the results of any calculations.

BMat8 objects can be constructed using:

  1. No parameters (uninitialized)

  2. An integer (the binary representation of which corresponds to the matrix)

  3. A list of n lists of truthy or falsy values, each sublist must have length n also.

See the libsemigroups documentation for further details.

class BMat8(*args, **kwargs)

Overloaded function.

  1. __init__(self: _libsemigroups_pybind11.BMat8) -> None

    Returns an uninitialised BMat8.

  2. __init__(self: _libsemigroups_pybind11.BMat8, arg0: int) -> None

  3. __init__(self: _libsemigroups_pybind11.BMat8, arg0: _libsemigroups_pybind11.BMat8) -> None

  4. __init__(self: _libsemigroups_pybind11.BMat8, arg0: List[List[bool]]) -> None

col_space_basis(self: _libsemigroups_pybind11.BMat8) _libsemigroups_pybind11.BMat8

This method returns a BMat8 whose non-zero columns form a basis for the column space of self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.col_space_basis()
10000000
01000000
00000000
00000000
00000000
00000000
00000000
00000000
column_space_size(self: _libsemigroups_pybind11.BMat8) int

Returns the size of the row space of self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.column_space_size()
4
get(self: _libsemigroups_pybind11.BMat8, i: int, j: int) bool

Returns the entry in the (i, j)th position.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.get(0, 1)
True
>>> x.get(1, 1)
False
is_regular_element(self: _libsemigroups_pybind11.BMat8) bool

Check whether self is a regular element of the full boolean matrix monoid of appropriate dimension.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.is_regular_element()
True
minimum_dim(self: _libsemigroups_pybind11.BMat8) int

This method returns the maximal i such that row i or column i contains a 1.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.minimum_dim()
2
number_of_cols(self: _libsemigroups_pybind11.BMat8) int

Returns the number of non-zero columns in self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.number_of_cols()
2
number_of_rows(self: _libsemigroups_pybind11.BMat8) int

Returns the number of non-zero rows in self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.number_of_rows()
2
one(self: int) _libsemigroups_pybind11.BMat8

This method returns the BMat8 with the first dim entries in the main diagonal equal to 1 and every other value equal to 0.

>>> from libsemigroups_pybind11 import BMat8
>>> BMat8.one(4)
10000000
01000000
00100000
00010000
00000000
00000000
00000000
00000000
static random(*args, **kwargs)

Overloaded function.

  1. random() -> _libsemigroups_pybind11.BMat8

  2. random(arg0: int) -> _libsemigroups_pybind11.BMat8

row_space_basis(self: _libsemigroups_pybind11.BMat8) _libsemigroups_pybind11.BMat8

This method returns a BMat8 whose non-zero rows form a basis for the row space of self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.row_space_basis()
10000000
01000000
00000000
00000000
00000000
00000000
00000000
00000000
row_space_size(self: _libsemigroups_pybind11.BMat8) int

Returns the size of the row space of self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.row_space_size()
4
rows(self: _libsemigroups_pybind11.BMat8) List[int]

This method returns a list of integers representing the rows of self. The list will always be of length 8, even if self was constructed with fewer rows.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.rows()
[64, 128, 0, 0, 0, 0, 0, 0]
set(self: _libsemigroups_pybind11.BMat8, i: int, j: int, val: bool) None

Sets the (i, j)th entry to val.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.set(1,1,1)
>>> x
01000000
11000000
00000000
00000000
00000000
00000000
00000000
00000000
swap(self: _libsemigroups_pybind11.BMat8, other: _libsemigroups_pybind11.BMat8) None

Swaps the contents of self and other.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> y = BMat8([[1, 1], [0, 0]])
>>> BMat8.swap(x,y)
>>> x
11000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000

>>> y
01000000
10000000
00000000
00000000
00000000
00000000
00000000
00000000
to_int(self: _libsemigroups_pybind11.BMat8) int

Returns the integer representation of the BMat8, that is an integer obtained by interpreting an 8 x 8 BMat8 as a sequence of 64 bits (reading rows left to right, from top to bottom) and then realising this sequence as an integer.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[0, 1], [1, 0]])
>>> x.to_int()
4647714815446351872
transpose(self: _libsemigroups_pybind11.BMat8) _libsemigroups_pybind11.BMat8

Returns the transpose of self.

>>> from libsemigroups_pybind11 import BMat8
>>> x = BMat8([[1, 0], [1, 0]])
>>> x.transpose()
11000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000