qldpc.abstract.linalg

Module for linear algebra with matrices over rings and bimodules.

!!! WARNINGS !!!

This module does not promise to be performant. If you need to do heavy numerical abstract algebra, you’re probably better served by GAP or MAGMA (or maybe SageMath).

Functions

block_diag(→ qldpc.abstract.rings.RingArray)

Stack the two matrices into a block-diagonal matrix.

get_bimodule(→ qldpc.abstract.rings.GroupRing)

Map a group algebra F[G] to its induced bimodule F[G ⨂ G].

get_howell_dual(→ qldpc.abstract.rings.RingArray)

Build the "dual" of a matrix in Howell normal form.

kron(→ qldpc.abstract.rings.RingArray)

Take the Kronecker product of two matrices over a ring.

matmul(→ qldpc.abstract.rings.RingArray)

Multiply two matrices over a ring.

Module Contents

qldpc.abstract.linalg.block_diag(matrix_a: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_], matrix_b: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_]) → qldpc.abstract.rings.RingArray[source]

Stack the two matrices into a block-diagonal matrix.

qldpc.abstract.linalg.get_bimodule(ring: qldpc.abstract.rings.GroupRing) → qldpc.abstract.rings.GroupRing[source]

Map a group algebra F[G] to its induced bimodule F[G ⨂ G].

Elements r ⨂ s ∈ F[G ⨂ G] of the bimodule act on elements of the base ring as:

(r ⨂ s)(t) = r·t·s⁻¹.

(The right sector lifts to an anti-representation of the inverse, hence s⁻¹ rather than s.)

When lifting a RingArray matrix over a bimodule, the “left” entries of G ⨂ G get lifted to an ordinary representation, while the “right” entries get lifted to an anti-representation.

qldpc.abstract.linalg.get_howell_dual(matrix_hnf: qldpc.abstract.rings.RingArray, *, transformer: qldpc.abstract.wedderburn_artin.WedderburnArtinTransformer | None = None, right: bool | None = None, skip_validation: bool | None = None) → qldpc.abstract.rings.RingArray[source]

Build the “dual” of a matrix in Howell normal form.

The dual matrix provides a pseudoinverse of matrix_hnf in the following sense. Below, @ denotes the orientation-aware product abstract.matmul(..., right=right) (ordinary matrix multiplication when right=False). If

D = matrix_hnf @ dual_matrix.T,

then

  1. D is diagonal,

  2. D @ matrix_hnf = matrix_hnf,

  3. D.T @ dual_matrix = dual_matrix, and

  4. D = transformer.transpose_array(D).

Note that we have two different notions of a transpose at play:

  1. D.T…

    1. swaps the matrix indices of D, and

    2. takes group members g -> ~g = g**-1, which transposes their regular representation.

  2. transformer.transpose_array(D)…

    1. swaps the matrix indices of D (identically to D.T), and

    2. for each entry of D, transposes its matrix representation within each Wedderburn-Artin component of the ring.

The transformer must be the one used to build matrix_hnf, since the dual is built in that transformer’s basis. By default it is read from matrix_hnf (the transformer recorded when the Howell form was built).

Likewise, the right flag must match the orientation used to build matrix_hnf (the right passed to null_space/howell_normal_form_semisimple). For a non-commutative ring the dual is orientation-specific: the dual built for the wrong orientation does not satisfy it. By default (right=None) it is read from matrix_hnf, like transformer; an explicit value is cross-checked against what matrix_hnf was built with.

skip_validation controls whether the returned dual is checked against properties 1-4:

  • False: always check, raising an error if the dual is not valid.

  • True: never check (fastest; trusts that matrix_hnf is a Howell form and that right matches its orientation).

  • None (default): if matrix_hnf carries Howell-form provenance (attached by howell_normal_form_semisimple/howell_normal_form_poly), trust it – but raise an error if its recorded orientation disagrees with right. Otherwise, check as for False.

WARNINGS: Any transformer passed in must be the one used to build matrix_hnf; otherwise the dual is built in the wrong basis and may be wrong. By default the transformer recorded on matrix_hnf is used. Separately, with skip_validation=True this method verifies nothing else: it trusts that matrix_hnf is in Howell normal form and that right matches the orientation used to build it, so a wrong right may raise an error but may also silently return a wrong dual.

qldpc.abstract.linalg.kron(matrix_a: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_], matrix_b: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_]) → qldpc.abstract.rings.RingArray[source]

Take the Kronecker product of two matrices over a ring.

If the base ring R is commutative, this is the ordinary Kronecker product. Otherwise, matrix entries of the Kronecker product live in the bimodule of R. See get_bimodule for additional information.

qldpc.abstract.linalg.matmul(matrix_a: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_], matrix_b: qldpc.abstract.rings.RingArray | numpy.typing.NDArray[numpy.int_], *, right: bool = False) → qldpc.abstract.rings.RingArray[source]

Multiply two matrices over a ring.

This method exists to handle two different cases: 1. ‘right is False’ (default): Ordinary matrix multiplication, or simply ‘matrix_a @ matrix_b’. 2. ‘right is True’: matrix multiplication with a reversed order of multiplication in the ring.