Matrix helpers

This page contains the documentation for various helper functions for manipulating Matrix objects. All these functions are contained in the submodule matrix.

Contents

matrix.period(…)

Returns the period of an ntp matrix.

matrix.row_basis(…)

Returns a row space basis of a matrix as a list of lists.

matrix.row_space_size(…)

Returns the size of the row space of a boolean matrix.

matrix.threshold(…)

Returns the threshold of a matrix over a truncated semiring.

Full API

This page contains the documentation for the matrix subpackage, that contains helper functions for the Matrix class.

matrix.period(x: Matrix) int

Returns the period of an ntp matrix. This function returns the period of the ntp matrix x using its underlying semiring.

Parameters:

x (Matrix) – the ntp matrix.

Returns:

The period of the matrix x.

Return type:

int

matrix.row_basis(x: Matrix) list[list[int | PositiveInfinity | NegativeInfinity]]

Returns a row space basis of a matrix as a list of lists. The matrix x which must be one of:

This function returns a row space basis of the matrix x as a list of lists of rows.

Parameters:

x (Matrix) – the matrix.

Returns:

A basis for the row space of x.

Return type:

list[list[int | PositiveInfinity | NegativeInfinity]]

Complexity:

\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

matrix.row_space_size(x: Matrix) int

Returns the size of the row space of a boolean matrix. This function returns the size of the row space of the boolean matrix x.

Parameters:

x (Matrix) – the matrix.

Returns:

The size of the row space of the matrix x.

Return type:

int

Complexity:

\(O(mn)\) where \(m\) is the size of the row basis of x and \(n\) is the size of the row space.

>>> from libsemigroups_pybind11 import Matrix, MatrixKind, matrix
>>> x = Matrix(MatrixKind.Boolean, [[1,  0,  0],  [0,  0,  1],  [0,  1,  0]])
>>> matrix.row_space_size(x)
7
matrix.threshold(x: Matrix) int

Returns the threshold of a matrix over a truncated semiring.

This function returns the threshold of a matrix over a truncated semiring, that is a matrix whose kind is any of:

Parameters:

x (Matrix) – the matrix.

Returns:

The threshold of x.

Return type:

int