Skip to main content

SurfaceCode

Struct SurfaceCode 

Source
pub struct SurfaceCode { /* private fields */ }
Expand description

A distance-d rotated surface code with an MWPM decoder.

Implementations§

Source§

impl SurfaceCode

Source

pub fn new(distance: usize) -> QuantumResult<Self>

Build a distance-d rotated surface code.

§Errors

QuantumError::InvalidParameter if distance is 0 or even.

Source

pub fn from_config(cfg: SurfaceCodeConfig) -> QuantumResult<Self>

Build from a SurfaceCodeConfig.

§Errors

As SurfaceCode::new.

Source

pub fn distance(&self) -> usize

Code distance d.

Source

pub fn num_data_qubits(&self) -> usize

Number of physical data qubits (d²).

Source

pub fn num_stabilizers(&self) -> usize

Total number of stabilizer generators (d²−1).

Source

pub fn num_x_stabilizers(&self) -> usize

Number of X-type stabilizers.

Source

pub fn num_z_stabilizers(&self) -> usize

Number of Z-type stabilizers.

Source

pub fn stabilizers(&self) -> &[Stabilizer]

Read-only view of the stabilizer generators.

Source

pub fn logical_x_support(&self) -> &[usize]

Support of the logical-X representative used by Self::logical_error.

Source

pub fn logical_z_support(&self) -> &[usize]

Support of the logical-Z representative used by Self::logical_error.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SurfaceCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.