qldpc.codes.distance
Methods for computing the (exact) distance of error-correcting codes.
Functions
|
Distance of a classical linear binary code. |
|
Distance of a binary quantum code. |
Module Contents
- qldpc.codes.distance.get_distance_classical(generators: numpy.typing.ArrayLike, *, cutoff: int = 1, block_size: int = 15, use_numba: bool = False) int[source]
Distance of a classical linear binary code.
- Parameters:
generators – The generator matrix of the classical code whose distance we want to compute. Its rows must be linearly independent; otherwise a nonzero combination of rows can be the zero vector, and the returned value is not a true distance (in exact mode,
cutoff=0, it is0).cutoff – Exit early and return once an upper bound on distance falls to or below this cutoff.
block_size – Vectorize distance calculations over batches of size
2**block_size.use_numba – Use numba to (maybe) speed up calculations.
- Returns:
The minimum Hamming distance between different code words, or equivalently the minimum Hamming weight of a nontrivial code word.
- qldpc.codes.distance.get_distance_quantum(logical_ops: numpy.typing.ArrayLike, stabilizers: numpy.typing.ArrayLike, *, cutoff: int = 1, block_size: int = 15, use_numba: bool = False, homogeneous: bool = False) int[source]
Distance of a binary quantum code.
- Parameters:
logical_ops – A matrix whose rows represent logical operators of the code. These rows must be linearly independent modulo the stabilizers; otherwise a nonzero combination of them can be a stabilizer (weight
0modulo stabilizers), and the returned value is not a true distance (in exact mode,cutoff=0, it is0).stabilizers – A matrix whose rows represent stabilizers of the code.
cutoff – Exit early and return once an upper bound on distance falls to or below this cutoff.
block_size – Vectorize distance calculations over batches of size
2**block_size.use_numba – Use numba to (maybe) speed up calculations.
homogeneous – If True, all Pauli strings (represented by rows of logical_ops and stabilizers) are assumed to have the same homogeneous (X or Z) type. If False, Pauli strings may have mixed (X, Y, or Z) support on different qubits.
- Returns:
The exact minimum weight of a nontrivial logical operator in
logical_opsmodulo stabilizers (the code distance). As an optimization, as soon as the lightest operator seen so far has weight<= cutoffthe search stops early and returns that weight – an upper bound on the true distance, in[distance, cutoff]. With the defaultcutoff=1this still returns the exact distance for every valid input (an early return can exceed the distance only whencutoff >= 2). Passcutoff=0to disable the early exit and force the exact minimum.
More specifically, if homogeneous is True, then:
(a) each Pauli string is represented by a binary vector of length equal to the number of data qubits in a code, indicating the nontrivial support of the Pauli string; and (b) the weight of a Pauli string is the Hamming weight of the corresponding bitstring.
If homogeneous is False, then:
(a) each Pauli string is represented by a symplectic binary vector (of length 2 * data qubits) with the first and second halves indicating the X and Z Pauli support; and (b) the weight of a Pauli string is the symplectic weight of the corresponding bitstring.