bitgauss documentation

This package consists of Python bindings for the bitgauss library, which is a Rust library for fast linear algebraic operations over the 2-element field using bit matrices.

class bitgauss.BitMatrix(rows, cols)
bit(i, j)

Gets the bit at position (i, j)

static build(rows, cols, func)

Builds a BitMatrix from a Python function that determines the value of each bit

cols

Returns the number of logical columns in the matrix

copy()

Returns a copy of the matrix

static from_int_list(data)

Create matrix from a list of lists of integers (0 or 1)

static from_list(data)

Create matrix from a list of lists of bools

gauss(full=False)

Performs gaussian elimination

graphic_form()

Returns a matrix with the same rowspace as this one in which every column has Hamming weight at most 2, or None if no such matrix exists (i.e. the binary matroid represented by the columns is not graphic). Uses the Bixby-Wagner graph-realization algorithm.

graphic_form_partial()

Like graphic_form, but always returns a matrix with the same rowspace, together with the sorted list of columns whose Hamming weight could not be reduced to at most 2 (empty exactly when graphic_form succeeds)

hstack(other)

Horizontally stacks this matrix with another one and returns the result

static identity(size)

Creates a new identity BitMatrix of size size x size

inverse()

Computes the inverse of an invertible matrix

is_zero()

Checks if the matrix consists of all zero bits

matmul(other)

Matrix multiplication method (alternative to operators) Supports both matrix-matrix and matrix-vector multiplication

matvec(vector)

Matrix-vector multiplication with BitVector

nullspace()

Computes a basis for the nullspace of the matrix

static random(rows, cols, seed=None)

Creates a new random BitMatrix of size rows x cols

static random_invertible(size, seed=None)

Creates a new random invertible BitMatrix of size size x size

rank()

Computes the rank of the matrix using gaussian elimination

rows

Returns the number of logical rows in the matrix

set_bit(i, j, b)

Sets the bit at position (i, j) to b

to_int_list()

Convert matrix to a list of lists of integers (0 or 1)

to_list()

Convert matrix to a list of lists of bools

transpose_inplace()

Transposes the matrix in place

transposed()

Returns a transposed copy of the matrix

vstack(other)

Vertically stacks this matrix with another one and returns the result

static zeros(rows, cols)

Creates a new BitMatrix of size rows x cols with all bits set to 0