quri_parts.core.utils.binary_field module#

class quri_parts.core.utils.binary_field.BinaryArray(iter: Iterable[int | bool])#

Bases: Sequence[int]

Array with elements in the binary field.

+, * and @ operators are defined. + and * perform element wise addition and multiplication respectively, returning a BinaryArray. @ performs binary inner product between two BinaryArray, returning either 0 or 1.

property binary: int#

Binary representation of the array.

class quri_parts.core.utils.binary_field.BinaryMatrix(iter: Iterable[Iterable[bool | int]])#

Bases: Iterable[BinaryArray], Sized

Matrix with elements in the binary field.

@ operator is defined as matrix multiplication (in the binary field). It can be applied to either of a BinaryMatrix or BinaryArray.

transpose() BinaryMatrix#

Returns a transposed matrix.

quri_parts.core.utils.binary_field.hstack(a: BinaryMatrix, b: BinaryMatrix) BinaryMatrix#
quri_parts.core.utils.binary_field.vstack(a: BinaryMatrix, b: BinaryMatrix) BinaryMatrix#
quri_parts.core.utils.binary_field.inverse(mat: BinaryMatrix) BinaryMatrix#

Returns an inverse of the matrix.