Skip to main content

StabilizerTableau

Struct StabilizerTableau 

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

CHP stabilizer tableau for poly-time Clifford-circuit simulation.

The x and z fields are flat row-major buffers of length (2n + 1) * n; element (row, col) lives at row * n + col. The phase buffer r has length 2n + 1.

Implementations§

Source§

impl StabilizerTableau

Source

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

Build the tableau for the computational-basis state |0…0⟩.

Destabilizers are initialized to X_i (row i, i < n) and stabilizers to Z_i (row n + i); all phases are +.

Source

pub fn n_qubits(&self) -> usize

Number of qubits the tableau tracks.

Source

pub fn h(&mut self, a: usize) -> QuantumResult<()>

Apply a Hadamard on qubit a.

For each row i: r[i] ^= x[i][a] & z[i][a] then swap x[i][a], z[i][a].

Source

pub fn s(&mut self, a: usize) -> QuantumResult<()>

Apply a phase gate S on qubit a.

For each row i: r[i] ^= x[i][a] & z[i][a] then z[i][a] ^= x[i][a].

Source

pub fn cnot(&mut self, control: usize, target: usize) -> QuantumResult<()>

Apply a controlled-NOT with the given control and target qubits.

For each row i: r[i] ^= x[i][c] & z[i][t] & (x[i][t] ^ z[i][c] ^ true), x[i][t] ^= x[i][c], z[i][c] ^= z[i][t].

Source

pub fn x(&mut self, a: usize) -> QuantumResult<()>

Apply a Pauli-X on qubit a, realized as X = H S S H.

Source

pub fn z(&mut self, a: usize) -> QuantumResult<()>

Apply a Pauli-Z on qubit a, realized as Z = S S.

Source

pub fn y(&mut self, a: usize) -> QuantumResult<()>

Apply a Pauli-Y on qubit a.

Y = i·X·Z; applying Z then X realizes Y up to a global phase, which is unobservable in the stabilizer formalism.

Source

pub fn is_deterministic(&self, a: usize) -> QuantumResult<bool>

Whether a Z-basis measurement of qubit a is deterministic.

The outcome is random iff some stabilizer generator anticommutes with Z_a, i.e. some row p in n..2n has x[p][a] == true.

Source

pub fn measure(&mut self, a: usize, rng: &mut LcgRng) -> QuantumResult<bool>

Perform a Z-basis measurement of qubit a, collapsing the tableau and returning the outcome (true = |1⟩).

Trait Implementations§

Source§

impl Clone for StabilizerTableau

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 StabilizerTableau

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.