[][src]Struct quantum2::computer::QuantumComputer

pub struct QuantumComputer { /* fields omitted */ }

Represents a quantum computer of one register.

This is essentially a wrapping around a quantum register with convenience methods to run algorithms, log and read results.

Methods

impl QuantumComputer[src]

pub fn new(width: usize) -> QuantumComputer[src]

Construct a new quantum computer with register of given width.

pub fn initialize(&mut self, value: u32)[src]

Initialize the quantum register qubits to a certian classical integer state.

Panics

We panic if the state is anything other than State::Initializing.

pub fn apply(&mut self, gate: Gate)[src]

Apply a quantum gate to the quantum register qubits.

Panics

We panic if the state is anything other than State::Running.

pub fn collapse(&mut self)[src]

Collapse the quantum register to a classical state.

Panics

We panic if the state is anything other than State::Running.

pub fn reset(&mut self)[src]

Reset the quantum register, ready to be initialized again.

Panics

We panic if the state is anything other than State::Collapsed.

pub fn value(&self) -> u32[src]

Read the collapsed register qubits as an integer.

Panics

We panic if the state is anything other than State::Collapsed.

pub fn probabilities(&self) -> Vec<f64>[src]

Compute the probabilities of each register state without collapsing.

This function is intended for test purposes.

We return a vector of probabilities mirroring a ket, but without trailing zeroes.

Trait Implementations

impl Debug for QuantumComputer[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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