Struct quantum::computer::QuantumComputer
[−]
[src]
pub struct QuantumComputer { // some 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]
fn new(width: usize) -> QuantumComputer
Construct a new quantum computer with register of given width
.
fn initialize(&mut self, value: u32)
Initialize the quantum register qubits to a certian classical integer state.
Panics
We panic if the state is anything other than State::Initializing
.
fn apply(&mut self, gate: Gate)
Apply a quantum gate to the quantum register qubits.
Panics
We panic if the state is anything other than State::Running
.
fn collapse(&mut self)
Collapse the quantum register to a classical state.
Panics
We panic if the state is anything other than State::Running
.
fn reset(&mut self)
Reset the quantum register, ready to be initialized again.
Panics
We panic if the state is anything other than State::Collapsed
.
fn value(&self) -> u32
Read the collapsed register qubits as an integer.
Panics
We panic if the state is anything other than State::Collapsed
.
fn probabilities(&self) -> Vec<f64>
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.