qldpc.codes.classical
Classical error-correcting codes.
Classes
Classical BCH (Bose-Chaudhuri-Hocquenghem) code. |
|
Classical cyclic code. |
|
Classical extended Hamming code: the ordinary Hamming code with an extra parity bit. |
|
Classical binary [23, 12, 7] Golay code. |
|
Classical Hamming code. |
|
Classical Reed-Muller code. |
|
Classical Reed-Solomon code. |
|
Classical repetition code: the |
|
Classical ring code: repetition code with periodic boundary conditions. |
|
Classical simplex code: the dual of the Hamming code. |
|
Classical Tanner code. |
Module Contents
- class qldpc.codes.classical.BCHCode(length: int, dimension: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical BCH (Bose-Chaudhuri-Hocquenghem) code.
Source: https://mhostetter.github.io/galois/latest/api/galois.BCH
References:
- class qldpc.codes.classical.CyclicCode(bits: int, poly: sympy.Basic, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical cyclic code.
A CyclicCode is determined by an integer block length and an integer polynomial in one variable. The parity check matrix of a CyclicCode is obtained by interpreting the polynomial as an element of a cyclic group algebra, and lifting this polynomial to a square matrix. The multiplicative identity and the generator of the group correspond, respectively, to the identity and shift matrices.
The CyclicCode with polynomial
1 - xis a RingCode.References:
- class qldpc.codes.classical.ExtendedHammingCode(size: int)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical extended Hamming code: the ordinary Hamming code with an extra parity bit.
The extended Hamming code of size m is also equal to
ReedMullerCode(m - 2, m).References:
- class qldpc.codes.classical.GolayCode[source]
Bases:
CyclicCodeClassical binary [23, 12, 7] Golay code.
A famous “perfect” cyclic code: every 23-bit word lies within distance 3 of a unique codeword, so it corrects any 3 bit-flip errors. As a cyclic code, its codewords are the multiples (mod
x^23 - 1) of the Golay generator polynomialg(x), a degree-11 factor ofx^23 - 1.The parity checks are the cyclic shifts of the weight-8 polynomial
h(x) = (x + 1) g(x), which generates the dual codeG^perp = [23, 11, 8].References:
- class qldpc.codes.classical.HammingCode(size: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical Hamming code.
When working over the binary field (0s and 1s), the parity check matrix of the HammingCode is built by stacking together (as columns) all nonzero bitstrings. More generally, the parity check matrix is built from a maximal set of linearly independent nonzero vectors over a finite field; equivalently, from all vectors whose first nonzero element is a 1.
References:
- class qldpc.codes.classical.ReedMullerCode(order: int, size: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical Reed-Muller code.
A Reed-Muller code with order r and size m, denoted
RM(r, m), has code parameters[2**m, k, 2**(m-r)]where
k = sum_(j = 0)^r (m choose j).References:
- static get_generator(order: int, size: int) numpy.typing.NDArray[numpy.int_][source]
Get the generator matrix for the specified Reed-Muller code.
- property order: int
The order parameter of this code.
- property size: int
The size parameter of this code.
- class qldpc.codes.classical.ReedSolomonCode(bits: int, dimension: int)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical Reed-Solomon code.
Source: https://mhostetter.github.io/galois/latest/api/galois.ReedSolomon
References:
- class qldpc.codes.classical.RepetitionCode(bits: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical repetition code: the
[n, 1, n]code whose code words are constant vectors.References:
- class qldpc.codes.classical.RingCode(bits: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical ring code: repetition code with periodic boundary conditions.
The periodic boundary adds one (redundant) parity check, so a RingCode has the same code words as a RepetitionCode of the same block length, and hence the same
[n, 1, n]parameters.References:
- class qldpc.codes.classical.SimplexCode(dim: int, field: int | type[galois.FieldArray] | None = None)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical simplex code: the dual of the Hamming code.
A simplex code of dimension k over a field of order q has code parameters
[(q**k - 1) / (q - 1), k, q ** (k - 1)].Its generator matrix has one column for each point of the projective space
PG(k - 1, q), that is, one representative of each family of nonzero vectors ofF_q**kthat are scalar multiples of one another. Those columns are precisely the parity checks of a Hamming code of the same rank, which is what makes a simplex code the dual of a Hamming code.Over the binary field the scalar multiples of a nonzero vector are just the vector itself, so the block length is
2**k - 1and the code has a cyclic presentation: its parity checks are the cyclic shifts of a three-term polynomial, and therefore all have weight 3. That presentation is used here for binary codes, since low-weight parity checks are what make simplex codes attractive as the building blocks of a SHYPSCode. It does not carry over toq > 2, where a cyclic code of lengthq**k - 1would instead be the(q - 1)-fold repetition of the simplex code.Over the binary field the automorphism group of this code is the general linear group
GL(k, 2).References:
- static get_defining_polynomial(dim: int, field: int | type[galois.FieldArray] | None = None) galois.Poly[source]
The polynomial defining the cyclic presentation of a simplex code.
The cyclic code of length
field.order**dim - 1with this check polynomial is a simplex code whenfield.order == 2, and the(field.order - 1)-fold repetition of one otherwise.Returns a three-term polynomial of the form
h(x) = 1 + a * x**c + b * x**d, wherethe coefficients a and b are elements of a finite field,
the exponents c and d are integers, and
gcd(h(x), x ** (field**dim - 1) - 1)is a primitive polynomial of degree dim.
A dimension of at least 2 is required: a one-dimensional simplex code has block length
field.order - 1 == 1, for which no nontrivial check polynomial exists.
- class qldpc.codes.classical.TannerCode(subgraph: qldpc._util.networkx.Graph, subcode: qldpc.codes.common.ClassicalCode)[source]
Bases:
qldpc.codes.common.ClassicalCodeClassical Tanner code.
A Tanner code
T(G,C)is constructed from: [1] A bipartite “half-regular” graph G. That is, a graph…… with two sets of nodes, V and W. … in which all nodes in V have degree n.
[2] A classical code C on n bits.
For convenience, we make G directed, with edges directed from V to W. The node sets V and W can then be identified, respectively, by the sources and sinks of G.
The Tanner code
T(G,C)is defined on|W|bits. A|W|-bit string x is a code word ofT(G,C)iff, for every node v in V, the bits of x incident to v are a code word of C.This construction requires an ordering of the edges E(v) adjacent to each vertex v. This class sorts E(v) by the value of the “sort” attribute attached to each edge. If there is no “sort” attribute, its value is treated as the corresponding neighbor of v.
Tanner codes can similarly be defined on regular (undirected) graphs
G' = (V',E')by placing checks on V’ and bits on E’.Notes:
If the subcode C has m checks, its parity matrix has shape
(m,n).The code
T(G,C)has|W|bits and|V|mchecks.
References:
- static as_directed_subgraph(subgraph: qldpc._util.networkx.Graph) qldpc._util.networkx.DiGraph[source]
Convert an undirected graph for a Tanner code into a directed graph for the same code.
- subcode: qldpc.codes.common.ClassicalCode
- subgraph: qldpc._util.networkx.DiGraph