Skip to main content

PauliFrame

Struct PauliFrame 

Source
pub struct PauliFrame {
    pub x_frame: Vec<bool>,
    pub z_frame: Vec<bool>,
}
Expand description

Classical Pauli frame tracker for fault-tolerant circuits.

Tracks accumulated X and Z corrections that would be needed to map the current (potentially corrupted) state back to the ideal state. Gates commuted through are tracked symbolically rather than applied.

Fields§

§x_frame: Vec<bool>

X component of the accumulated frame (true = X or Y on that qubit)

§z_frame: Vec<bool>

Z component of the accumulated frame (true = Z or Y on that qubit)

Implementations§

Source§

impl PauliFrame

Source

pub fn new(n_qubits: usize) -> Self

Create a new all-identity Pauli frame for n_qubits qubits.

Source

pub fn n_qubits(&self) -> usize

Number of qubits tracked in this frame.

Source

pub fn apply_pauli_string(&mut self, ps: &PauliString)

Apply a PauliString correction to the frame (XOR into the frame).

I → no change X → flip x_frame Z → flip z_frame Y → flip both x_frame and z_frame

Source

pub fn commute_through_h(&mut self, qubit: usize)

Propagate the Pauli frame through a Hadamard gate on qubit.

H conjugation rule: H X H† = Z, H Z H† = X. Therefore X and Z components are swapped.

Source

pub fn commute_through_s(&mut self, qubit: usize)

Propagate the Pauli frame through an S gate on qubit.

S conjugation rule: S X S† = Y = iXZ, S Z S† = Z. Effect on frame: X → X (x stays), Z component gains x_frame (Z gets +x). If x was true: Z also becomes true (X → Y, so Z component added). If x was false: nothing changes for Z.

Source

pub fn commute_through_cnot(&mut self, ctrl: usize, tgt: usize)

Propagate the Pauli frame through a CNOT gate.

CNOT conjugation rules:

  • CNOT (X_c ⊗ I) CNOT† = X_c ⊗ X_t (X propagates forward from ctrl to tgt)
  • CNOT (I ⊗ X_t) CNOT† = I ⊗ X_t (X on target unchanged)
  • CNOT (Z_c ⊗ I) CNOT† = Z_c ⊗ I (Z on ctrl unchanged)
  • CNOT (I ⊗ Z_t) CNOT† = Z_c ⊗ Z_t (Z propagates backward from tgt to ctrl)
Source

pub fn measure_logical_x(&self, logical_x_qubits: &[usize]) -> bool

Measure the logical X operator.

Returns true if the accumulated frame has a logical-Z error (i.e., the Z-frame parity is odd over the logical-X support qubits).

logical_x_qubits: the data qubit indices forming the logical X string.

Source

pub fn measure_logical_z(&self, logical_z_qubits: &[usize]) -> bool

Measure the logical Z operator.

Returns true if the accumulated frame has a logical-X error (i.e., the X-frame parity is odd over the logical-Z support qubits).

logical_z_qubits: the data qubit indices forming the logical Z string.

Source

pub fn merge(&mut self, other: &PauliFrame)

Merge another frame into this one (XOR both x and z components).

Source

pub fn is_identity(&self) -> bool

Returns true if this frame represents the identity (no corrections needed).

Trait Implementations§

Source§

impl Clone for PauliFrame

Source§

fn clone(&self) -> PauliFrame

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 PauliFrame

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PauliFrame

Source§

fn default() -> PauliFrame

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V