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
impl PauliFrame
Sourcepub fn apply_pauli_string(&mut self, ps: &PauliString)
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
Sourcepub fn commute_through_h(&mut self, qubit: usize)
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.
Sourcepub fn commute_through_s(&mut self, qubit: usize)
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.
Sourcepub fn commute_through_cnot(&mut self, ctrl: usize, tgt: usize)
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)
Sourcepub fn measure_logical_x(&self, logical_x_qubits: &[usize]) -> bool
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.
Sourcepub fn measure_logical_z(&self, logical_z_qubits: &[usize]) -> bool
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.
Sourcepub fn merge(&mut self, other: &PauliFrame)
pub fn merge(&mut self, other: &PauliFrame)
Merge another frame into this one (XOR both x and z components).
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true if this frame represents the identity (no corrections needed).
Trait Implementations§
Source§impl Clone for PauliFrame
impl Clone for PauliFrame
Source§fn clone(&self) -> PauliFrame
fn clone(&self) -> PauliFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PauliFrame
impl Debug for PauliFrame
Source§impl Default for PauliFrame
impl Default for PauliFrame
Source§fn default() -> PauliFrame
fn default() -> PauliFrame
Auto Trait Implementations§
impl Freeze for PauliFrame
impl RefUnwindSafe for PauliFrame
impl Send for PauliFrame
impl Sync for PauliFrame
impl Unpin for PauliFrame
impl UnsafeUnpin for PauliFrame
impl UnwindSafe for PauliFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.