pub struct StabilizerCHForm { /* private fields */ }Implementations§
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn discard(&mut self, qarg: usize) -> Result<()>
pub fn discard(&mut self, qarg: usize) -> Result<()>
Discards the specified qubit from the state.
NOTE: This function assumes that the qubit qarg has already been
projected onto the |0> state. You need to project the qubit onto |0> before
calling this function. If this is not the case, the behavior is undefined.
§Arguments
qarg- The index of the qubit to discard.
§Errors
Returns an Error if the qubit index is out of bounds. Note that
this function does not check if the qubit is properly projected onto |0>.
Sourcepub fn discarded(&self, qarg: usize) -> Result<StabilizerCHForm>
pub fn discarded(&self, qarg: usize) -> Result<StabilizerCHForm>
Returns a new StabilizerCHForm with the specified qubit discarded.
NOTE: This function assumes that the qubit qarg has already been
projected onto the |0> state. You need to project the qubit onto |0> before
calling this function. If this is not the case, the behavior is undefined.
§Arguments
qarg- The index of the qubit to discard.
§Returns
A Result containing the new StabilizerCHForm with the specified qubit discarded.
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn apply_sqrt_x(&mut self, qarg: usize) -> Result<()>
pub fn apply_sqrt_x(&mut self, qarg: usize) -> Result<()>
Sourcepub fn apply_sqrt_xdg(&mut self, qarg: usize) -> Result<()>
pub fn apply_sqrt_xdg(&mut self, qarg: usize) -> Result<()>
Sourcepub fn apply_gate(&mut self, gate: &CliffordGate) -> Result<()>
pub fn apply_gate(&mut self, gate: &CliffordGate) -> Result<()>
Sourcepub fn apply_pauli(&mut self, pauli_string: &PauliString) -> Result<()>
pub fn apply_pauli(&mut self, pauli_string: &PauliString) -> Result<()>
Sourcepub fn apply_circuit(&mut self, circuit: &CliffordCircuit) -> Result<()>
pub fn apply_circuit(&mut self, circuit: &CliffordCircuit) -> Result<()>
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn inner_product(&self, other: &StabilizerCHForm) -> Result<Complex64>
pub fn inner_product(&self, other: &StabilizerCHForm) -> Result<Complex64>
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn kron(&self, other: &StabilizerCHForm) -> Result<StabilizerCHForm>
pub fn kron(&self, other: &StabilizerCHForm) -> Result<StabilizerCHForm>
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn project(&mut self, qarg: usize, outcome: bool) -> Result<bool>
pub fn project(&mut self, qarg: usize, outcome: bool) -> Result<bool>
Projects a qubit onto a computational basis state (|0> or |1>).
This operation modifies the stabilizer state in place.
In a stabilizer state, measuring a qubit in the computational basis yields either a
deterministic outcome (|0> or |1>) or a perfectly random one (50% probability for each).
This function attempts to force the qubit into the specified outcome, succeeding if the
projection is physically possible.
§Arguments
qarg: The index of the qubit to project.outcome: The desired basis state to project onto (falsefor|0>,truefor|1>).
§Returns
A Result indicating the outcome of the projection:
Ok(true)if the projection was deterministic. This means the qubit was already in the desired state. The stabilizer state is unchanged.Ok(false)if the projection was non-deterministic (probabilistic). This means the qubit was in a superposition and has now been collapsed to the desired state. The stabilizer state has been updated.
§Errors
Returns an ChFormError if the projection is impossible. This occurs when the qubit has a
deterministic value that is orthogonal to the desired outcome (e.g., attempting to
project a qubit in state |0> onto |1>).
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn to_statevector(&self) -> Result<Array1<Complex64>>
pub fn to_statevector(&self) -> Result<Array1<Complex64>>
Represents this state as a statevector.
NOTE:
- This implementation iterates over all 2^n basis states. This functionality is mainly for testing and debugging purposes.
- Uses little-endian convention for basis states.
Source§impl StabilizerCHForm
impl StabilizerCHForm
Sourcepub fn new(n: usize) -> Result<Self>
pub fn new(n: usize) -> Result<Self>
Creates a new StabilizerCHForm representing the |0…0> state for n qubits.
§Arguments
n- The number of qubits.
Sourcepub fn num_qubits(&self) -> usize
pub fn num_qubits(&self) -> usize
Returns the number of qubits in the stabilizer state.
Sourcepub fn set_global_phase(&mut self, phase: Complex64)
pub fn set_global_phase(&mut self, phase: Complex64)
Sets the global phase of the stabilizer state.
§Arguments
phase- A unit complex number representing the desired global phase.
Sourcepub fn global_phase(&self) -> Complex64
pub fn global_phase(&self) -> Complex64
Returns the global phase of the stabilizer state.
§Returns
A unit complex number representing the global phase.
Sourcepub fn from_clifford_circuit(circuit: &CliffordCircuit) -> Result<Self>
pub fn from_clifford_circuit(circuit: &CliffordCircuit) -> Result<Self>
Constructs a StabilizerCHForm from a CliffordCircuit.
§Arguments
circuit- TheCliffordCircuitto convert.
§Returns
A Result containing the resulting StabilizerCHForm.
Trait Implementations§
Source§impl Clone for StabilizerCHForm
impl Clone for StabilizerCHForm
Source§fn clone(&self) -> StabilizerCHForm
fn clone(&self) -> StabilizerCHForm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more