[−][src]Struct quantum2::computer::QuantumComputer
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
Auto Trait Implementations
impl Send for QuantumComputer
impl !Sync for QuantumComputer
impl Unpin for QuantumComputer
impl UnwindSafe for QuantumComputer
impl !RefUnwindSafe for QuantumComputer
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,