[][src]Struct q1tsim::qustate::QuState

pub struct QuState { /* fields omitted */ }

Quantum state.

Struct Qustate represents the quantum experiment. It consists of a series of quantum states, combined with the number of times this state occurs in the experiment. Each quantum state is a (normalized) superposition of basis states, ∑iai|i⟩, where each basis function |i⟩ is a Kronecker product of quantum bits.

Methods

impl QuState[src]

pub fn new(nr_bits: usize, nr_shots: usize) -> Self[src]

Create a new qustate of nr_bits qubits, all initialized to |0⟩, which will be measured nr_shots times.

pub fn from_qubit_coefs(bit_coefs: &[Complex64], nr_shots: usize) -> Self[src]

Create a new qustate from qubit coefficients.

Create a new qustate as a direct product of qubits, where the coefficients of the |0⟩ and |1⟩ states in the qubits are given in bit_coefs. This array must be of size 2*n, where n is the number of qubits in the system. The state will be evaluated in nr_shots separate runs.

pub fn nr_bits(&self) -> usize[src]

Return the number of qubits in this state

pub fn apply_gate<G: ?Sized>(&mut self, gate: &G, bits: &[usize]) where
    G: Gate
[src]

Apply a n-ary quantum gate gate on the qubits from bits in this state.

pub fn apply_unary_gate_all<G>(&mut self, gate: &G) where
    G: Gate
[src]

pub fn apply_conditional_gate<G: ?Sized>(
    &mut self,
    control: &[bool],
    gate: &G,
    bits: &[usize]
) where
    G: Gate
[src]

Apply a conditional n-ary quantum gate gate, controlled by classical bit control, on the qubits from bits in this state.

pub fn measure<R: Rng>(&mut self, qbit: usize, rng: &mut R) -> Array1<u64>[src]

Measure a qubit.

Perform a measurement on qubit qbit in the state. Measurement is done in the z-basis. The random number generator rng is used for sampling. The result is returned as an array containing the measurement result for each run.

pub fn measure_into<R: Rng>(
    &mut self,
    qbit: usize,
    cbit: usize,
    res: &mut Array1<u64>,
    rng: &mut R
)
[src]

Measure a qubit.

Perform a measurement on qubit qbit in the state to classical bit cbit in res, which should be an array of sufficient length to store results for the total number of runs in the state. Measurement is done in the z-basis. The random number generator rng is used for sampling.

pub fn peek_into<R: Rng>(
    &mut self,
    qbit: usize,
    cbit: usize,
    res: &mut Array1<u64>,
    rng: &mut R
)
[src]

Measure a qubit.

Perform a measurement on qubit qbit in the state to bit cbit in res, without affecting the quantum state, i.e. the wave function is not collapsed. The output array res should be of sufficient length to store results for the total number of runs in the state. Measurement is done in the z-basis. The random number generator rng is used for sampling. NOTE: this is not a physical process, and impossible to reproduce on a real quantum computer.

pub fn measure_all<R: Rng>(&mut self, rng: &mut R) -> Array1<u64>[src]

Measure all qubits

Measure all qubits in this state, and return the results. The random number generator rng is used for sampling.

pub fn measure_all_into<R: Rng>(
    &mut self,
    cbits: &[usize],
    res: &mut Array1<u64>,
    rng: &mut R
)
[src]

Measure all qubits

Measure all qubits in this state, and store the results in res, which should be of sufficient length to hold results for the number of runs in this state. The first qubit measured is stored at the bit position indicated by the first element of cbits, and so on. The random number generator rng is used for sampling.

pub fn peek_all_into<R: Rng>(
    &mut self,
    cbits: &[usize],
    res: &mut Array1<u64>,
    rng: &mut R
)
[src]

Measure all qubits

Measure all qubits in this state without affecting the quantum state, i.e. without collapsing the wave function. The measurement results are stored in res, which must be of sufficient length to hold results for the total number of runs in the state. The first qubit measured is stored at the bit position indicated by the first element of cbits, and so on. The random number generator rng is used for sampling. NOTE: this is not a physical process, and impossible to reproduce on a real quantum computer.

pub fn reset<R: Rng>(&mut self, bit: usize, rng: &mut R)[src]

Reset a qubit

Reset the qubit with index bit to zero. This is done by measuring the bit, and rotating it back to zero if the result is 1. The random number generator rng is used for sampling in the measurement.

pub fn reset_all(&mut self)[src]

Reset all qubits

Reset all qubits in this experiment, returning the state to |00...0⟩ for all runs.

Trait Implementations

impl Debug for QuState[src]

Auto Trait Implementations

impl Send for QuState

impl Sync for QuState

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.