StabilizerCHForm

Struct StabilizerCHForm 

Source
pub struct StabilizerCHForm { /* private fields */ }

Implementations§

Source§

impl StabilizerCHForm

Source

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

Source

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

Source

pub fn apply_h(&mut self, qarg: usize) -> Result<()>

Applies the Hadamard gate to the qubit at index qarg.

Time complexity: O(n^2)

§Arguments
  • qarg - The index of the qubit to which the Hadamard gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_x(&mut self, qarg: usize) -> Result<()>

Applies the Pauli-X gate to the qubit at index qarg.

Time complexity: O(n)

§Arguments
  • qarg - The index of the qubit to which the Pauli-X gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_y(&mut self, qarg: usize) -> Result<()>

Applies the Pauli-Y gate to the qubit at index qarg.

Time complexity: O(n)

§Arguments
  • qarg - The index of the qubit to which the Pauli-Y gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_z(&mut self, qarg: usize) -> Result<()>

Applies the Pauli-Z gate to the qubit at index qarg.

Time complexity: O(1)

§Arguments
  • qarg - The index of the qubit to which the Pauli-Z gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_s(&mut self, qarg: usize) -> Result<()>

Applies the Phase (S) gate to the qubit at index qarg.

Time complexity: O(n)

§Arguments
  • qarg - The index of the qubit to which the Phase (S) gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_sdg(&mut self, qarg: usize) -> Result<()>

Applies the adjoint Phase (S†) gate to the qubit at index qarg.

Time complexity: O(n)

§Arguments
  • qarg - The index of the qubit to which the adjoint Phase (S†) gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_sqrt_x(&mut self, qarg: usize) -> Result<()>

Applies the √X gate to the qubit at index qarg.

Time complexity: O(n^2)

§Arguments
  • qarg - The index of the qubit to which the √X gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_sqrt_xdg(&mut self, qarg: usize) -> Result<()>

Applies the adjoint of the √X gate to the qubit at index qarg.

Time complexity: O(n^2)

§Arguments
  • qarg - The index of the qubit to which the adjoint of the √X gate is applied.
§Returns

A Result indicating success or failure.

Source

pub fn apply_cx(&mut self, control: usize, target: usize) -> Result<()>

Applies the CNOT (CX) gate with control qubit at index control and target qubit at index target.

Time complexity: O(n)

§Arguments
  • control - The index of the control qubit.
  • target - The index of the target qubit.
§Returns

A Result indicating success or failure.

Source

pub fn apply_cz(&mut self, qarg1: usize, qarg2: usize) -> Result<()>

Applies the CZ gate between qubits at indices qarg1 and qarg2.

Time complexity: O(n)

§Arguments
  • qarg1 - The index of the first qubit.
  • qarg2 - The index of the second qubit.
§Returns

A Result indicating success or failure.

Source

pub fn apply_swap(&mut self, qarg1: usize, qarg2: usize) -> Result<()>

Applies the SWAP gate between the qubits at indices qarg1 and qarg2.

Time complexity: O(n)

§Arguments
  • qarg1 - The index of the first qubit.
  • qarg2 - The index of the second qubit.
§Returns

A Result indicating success or failure.

Source

pub fn apply_gate(&mut self, gate: &CliffordGate) -> Result<()>

Applies a Clifford gate to the stabilizer state.

§Arguments
  • gate - The Clifford gate to apply.
§Returns

A Result indicating success or failure.

Source

pub fn apply_pauli(&mut self, pauli_string: &PauliString) -> Result<()>

Applies a Pauli string to the stabilizer state.

§Arguments
  • pauli_string - The Pauli string to apply.
§Returns

A Result indicating success or failure.

Source

pub fn apply_circuit(&mut self, circuit: &CliffordCircuit) -> Result<()>

Applies a Clifford circuit to the stabilizer state.

§Arguments
  • circuit - The Clifford circuit to apply.
§Returns

A Result indicating success or failure.

Source§

impl StabilizerCHForm

Source

pub fn inner_product(&self, other: &StabilizerCHForm) -> Result<Complex64>

Computes the inner product 〈self|other〉.

§Arguments
  • other - The other StabilizerCHForm to compute the inner product with.
§Returns

A Result containing the complex inner product value.

Source§

impl StabilizerCHForm

Source

pub fn kron(&self, other: &StabilizerCHForm) -> Result<StabilizerCHForm>

Computes the tensor product of this state with another: |self> ⊗ |other>.

§Arguments
  • other - The other StabilizerCHForm to tensor with.
§Returns

A Result containing the new StabilizerCHForm representing the tensor product state.

Source§

impl StabilizerCHForm

Source

pub fn measure(&mut self, qarg: usize, seed: Option<[u8; 32]>) -> Result<bool>

Measures the specified qubit in the computational basis.

§Arguments
  • qarg - The index of the qubit to measure.
§Returns

A Result containing the measurement outcome: false for |0>, true for |1>.

Source§

impl StabilizerCHForm

Source

pub fn permuted(&self, axes: &[usize]) -> Result<Self>

Returns a new StabilizerCHForm with the qubits permuted.

§Arguments
  • axes - A slice representing the new order of qubits. For n qubits, this must be a permutation of [0, 1, ..., n-1].
§Returns

A Result containing the new StabilizerCHForm with permuted qubits.

Source

pub fn permute(&mut self, axes: &[usize]) -> Result<()>

Permutes the qubits of the state in-place.

§Arguments
  • axes - A slice representing the new order of qubits. For n qubits, this must be a permutation of [0, 1, ..., n-1].
§Returns

A Result indicating success or failure.

Source§

impl StabilizerCHForm

Source

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 (false for |0>, true for |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

Source

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

Source

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

pub fn num_qubits(&self) -> usize

Returns the number of qubits in the stabilizer state.

Source

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

pub fn global_phase(&self) -> Complex64

Returns the global phase of the stabilizer state.

§Returns

A unit complex number representing the global phase.

Source

pub fn from_clifford_circuit(circuit: &CliffordCircuit) -> Result<Self>

Constructs a StabilizerCHForm from a CliffordCircuit.

§Arguments
§Returns

A Result containing the resulting StabilizerCHForm.

Trait Implementations§

Source§

impl Clone for StabilizerCHForm

Source§

fn clone(&self) -> StabilizerCHForm

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StabilizerCHForm

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

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

§

fn vzip(self) -> V