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
impl StabilizerTableau
Sourcepub fn new(n_qubits: usize) -> QuantumResult<Self>
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 +.
Sourcepub fn h(&mut self, a: usize) -> QuantumResult<()>
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].
Sourcepub fn s(&mut self, a: usize) -> QuantumResult<()>
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].
Sourcepub fn cnot(&mut self, control: usize, target: usize) -> QuantumResult<()>
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].
Sourcepub fn x(&mut self, a: usize) -> QuantumResult<()>
pub fn x(&mut self, a: usize) -> QuantumResult<()>
Apply a Pauli-X on qubit a, realized as X = H S S H.
Sourcepub fn z(&mut self, a: usize) -> QuantumResult<()>
pub fn z(&mut self, a: usize) -> QuantumResult<()>
Apply a Pauli-Z on qubit a, realized as Z = S S.
Sourcepub fn y(&mut self, a: usize) -> QuantumResult<()>
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.
Sourcepub fn is_deterministic(&self, a: usize) -> QuantumResult<bool>
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.