pub struct SurfaceCode { /* private fields */ }Expand description
A distance-d rotated surface code with an MWPM decoder.
Implementations§
Source§impl SurfaceCode
impl SurfaceCode
Sourcepub fn new(distance: usize) -> QuantumResult<Self>
pub fn new(distance: usize) -> QuantumResult<Self>
Build a distance-d rotated surface code.
§Errors
QuantumError::InvalidParameter if distance is 0 or even.
Sourcepub fn from_config(cfg: SurfaceCodeConfig) -> QuantumResult<Self>
pub fn from_config(cfg: SurfaceCodeConfig) -> QuantumResult<Self>
Sourcepub fn num_data_qubits(&self) -> usize
pub fn num_data_qubits(&self) -> usize
Number of physical data qubits (d²).
Sourcepub fn num_stabilizers(&self) -> usize
pub fn num_stabilizers(&self) -> usize
Total number of stabilizer generators (d²−1).
Sourcepub fn num_x_stabilizers(&self) -> usize
pub fn num_x_stabilizers(&self) -> usize
Number of X-type stabilizers.
Sourcepub fn num_z_stabilizers(&self) -> usize
pub fn num_z_stabilizers(&self) -> usize
Number of Z-type stabilizers.
Sourcepub fn stabilizers(&self) -> &[Stabilizer]
pub fn stabilizers(&self) -> &[Stabilizer]
Read-only view of the stabilizer generators.
Sourcepub fn logical_x_support(&self) -> &[usize]
pub fn logical_x_support(&self) -> &[usize]
Support of the logical-X representative used by Self::logical_error.
Sourcepub fn logical_z_support(&self) -> &[usize]
pub fn logical_z_support(&self) -> &[usize]
Support of the logical-Z representative used by Self::logical_error.
Sourcepub fn syndrome(&self, error: &PauliError) -> QuantumResult<Syndrome>
pub fn syndrome(&self, error: &PauliError) -> QuantumResult<Syndrome>
Extract the stabilizer syndrome produced by a Pauli error.
A Z-type stabilizer fires when its support overlaps the X component
of the error in an odd number of qubits; an X-type stabilizer fires on
odd overlap with the Z component.
§Errors
QuantumError::DimensionMismatch if error spans the wrong number of
data qubits.
Sourcepub fn decode(&self, syndrome: &Syndrome) -> QuantumResult<PauliError>
pub fn decode(&self, syndrome: &Syndrome) -> QuantumResult<PauliError>
Decode a syndrome into a correction PauliError.
X corrections come from matching the Z-stabilizer defects; Z
corrections from the X-stabilizer defects.
§Errors
QuantumError::DimensionMismatch if syndrome has the wrong length.
Sourcepub fn residual_after_correction(
&self,
error: &PauliError,
) -> QuantumResult<PauliError>
pub fn residual_after_correction( &self, error: &PauliError, ) -> QuantumResult<PauliError>
Decode error’s syndrome and return the residual error ∘ correction.
In the Pauli frame, the decode succeeded iff the residual has no logical
component (see Self::logical_error).
§Errors
As Self::syndrome.
Sourcepub fn logical_error(&self, error: &PauliError) -> QuantumResult<(bool, bool)>
pub fn logical_error(&self, error: &PauliError) -> QuantumResult<(bool, bool)>
Whether a (residual) error implements a non-trivial logical operation,
returned as (logical_x_flipped, logical_z_flipped).
A residual X-string flips the logical state by logical-X iff it
anticommutes with the logical-Z operator, i.e. it overlaps the
logical-Z support in an odd number of qubits (and symmetrically for
the Z component against the logical-X support).
§Errors
QuantumError::DimensionMismatch if error spans the wrong number of
data qubits.
Trait Implementations§
Source§impl Clone for SurfaceCode
impl Clone for SurfaceCode
Source§fn clone(&self) -> SurfaceCode
fn clone(&self) -> SurfaceCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more