mqt.qecc.codes.core.css_code¶
Class for representing quantum error correction codes.
Exceptions¶
Raised when the CSS code is invalid. |
Classes¶
A class for representing CSS codes. |
Module Contents¶
- class CSSCode(Hx: numpy.typing.NDArray[numpy.int8] | None = None, Hz: numpy.typing.NDArray[numpy.int8] | None = None, distance: int | None = None, x_distance: int | None = None, z_distance: int | None = None, n: int | None = None, Lx: numpy.typing.NDArray[numpy.int8] | None = None, Lz: numpy.typing.NDArray[numpy.int8] | None = None)[source]¶
Bases:
mqt.qecc.codes.core.stabilizer_code.StabilizerCodeA class for representing CSS codes.
- property Hx: numpy.typing.NDArray[numpy.int8]¶
The X-check matrix as a view into the stabilizer generators.
- property Hz: numpy.typing.NDArray[numpy.int8]¶
The Z-check matrix as a view into the stabilizer generators.
- property Lx: numpy.typing.NDArray[numpy.int8]¶
The logical X matrix as a view into the logical X operators.
- property Lz: numpy.typing.NDArray[numpy.int8]¶
The logical Z matrix as a view into the logical Z operators.
- get_x_syndrome(error: numpy.typing.NDArray[numpy.int8]) numpy.typing.NDArray[numpy.int8][source]¶
Compute the x syndrome of the error.
- get_z_syndrome(error: numpy.typing.NDArray[numpy.int8]) numpy.typing.NDArray[numpy.int8][source]¶
Compute the z syndrome of the error.
- check_if_logical_x_error(residual: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if the residual X error acts as a logical operator (anticommutes with some Z logical).
- check_if_x_stabilizer(pauli: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if the X-type Pauli (given by its support) is an X stabilizer.
- check_if_logical_z_error(residual: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if the residual Z error acts as a logical operator (anticommutes with some X logical).
- check_if_z_stabilizer(pauli: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if the Z-type Pauli (given by its support) is a Z stabilizer.
- stabilizer_eq_x_error(error_1: numpy.typing.NDArray[numpy.int8], error_2: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if two X errors are in the same coset of the X stabilizers.
- stabilizer_eq_z_error(error_1: numpy.typing.NDArray[numpy.int8], error_2: numpy.typing.NDArray[numpy.int8]) bool[source]¶
Check if two Z errors are in the same coset of the Z stabilizers.
- static from_code_name(code_name: str) CSSCode[source]¶
Return CSSCode object for a known code.
The following codes are supported: - [[7, 1, 3]] Steane ("Steane") - [[15, 1, 3]] tetrahedral code ("Tetrahedral") - [[9, 1, 3]] Shore code ("Shor") - [[12, 2, 4]] Carbon Code ("Carbon") - [[23, 1, 7]] golay code ("Golay")
- Parameters:
code_name – The name of the code.
- classmethod from_file(file_path: str | Path) CSSCode[source]¶
Load a CSS code from a file.
The file can contain either: 1. Pauli string format - X and Z stabilizers as Pauli strings 2. Binary matrix format - X stabilizers followed by empty line, then Z stabilizers
For Pauli string format (Steane code example): XIIXXXI IXIIXXX IIXXIXX ZIIZZZI IZIIZZZ IIZZIZZ
For binary matrix format (space-separated): 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 0 1 1
1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 1 0 1 1
For list notation format: [[1,0,0,1,1,1,0],
[0,1,0,0,1,1,1], [0,0,1,1,0,1,1]]
- [[1,0,0,1,1,1,0],
[0,1,0,0,1,1,1], [0,0,1,1,0,1,1]]
For numpy array notation: [[1 0 0 1 1 1 0]
[0 1 0 0 1 1 1] [0 0 1 1 0 1 1]]
- [[1 0 0 1 1 1 0]
[0 1 0 0 1 1 1] [0 0 1 1 0 1 1]]
- Parameters:
file_path – The path to the file containing the code.
- Returns:
The CSS code.
- Return type:
- exception InvalidCSSCodeError[source]¶
Bases:
ValueErrorRaised when the CSS code is invalid.