[−][src]Trait q1tsim::qustate::QuState
Trait for a quantum state
Trait QuState describes the interface for changing, measuring and monitoring the quantum state of the simulated computer.
Required methods
fn apply_gate<G: ?Sized>(&mut self, gate: &G, bits: &[usize]) -> Result<()> where
G: Gate,
G: Gate,
Apply a n-ary quantum gate gate
on the qubits from bits
in this state.
fn apply_unary_gate_all<G: ?Sized>(&mut self, gate: &G) -> Result<()> where
G: Gate,
G: Gate,
Apply a unary gate to all qubits
Apply the single-bit gate gate
to all qubits in the quantum state.
fn apply_conditional_gate<G: ?Sized>(
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
Apply a conditional n-ary quantum gate gate
, controlled by classical
bit control
, on the qubits from bits
in this state.
fn measure<R: Rng>(&mut self, qbit: usize, rng: &mut R) -> Result<Array1<u64>>
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.
fn measure_into<R: Rng>(
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
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.
fn measure_all<R: Rng>(&mut self, rng: &mut R) -> Result<Array1<u64>>
Measure all qubits
Measure all qubits in this state, and return the results. The random
number generator rng
is used for sampling.
fn measure_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
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.
fn peek_into<R: Rng>(
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
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.
fn peek_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
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.
fn reset<R: Rng>(&mut self, bit: usize, rng: &mut R) -> Result<()>
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.
fn reset_all(&mut self)
Reset all qubits
Reset all qubits in this experiment, returning the state to |00...0⟩ for all runs.
Implementors
impl QuState for StabilizerState
[src]
fn apply_gate<G: ?Sized>(&mut self, gate: &G, bits: &[usize]) -> Result<()> where
G: Gate,
[src]
G: Gate,
fn apply_unary_gate_all<G: ?Sized>(&mut self, gate: &G) -> Result<()> where
G: Gate,
[src]
G: Gate,
fn apply_conditional_gate<G: ?Sized>(
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
[src]
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
fn measure<R: Rng>(&mut self, qbit: usize, rng: &mut R) -> Result<Array1<u64>>
[src]
fn measure_into<R: Rng>(
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn measure_all<R: Rng>(&mut self, rng: &mut R) -> Result<Array1<u64>>
[src]
fn measure_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn peek_into<R: Rng>(
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn peek_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn reset<R: Rng>(&mut self, bit: usize, _rng: &mut R) -> Result<()>
[src]
fn reset_all(&mut self)
[src]
impl QuState for VectorState
[src]
fn apply_gate<G: ?Sized>(&mut self, gate: &G, bits: &[usize]) -> Result<()> where
G: Gate,
[src]
G: Gate,
fn apply_unary_gate_all<G: ?Sized>(&mut self, gate: &G) -> Result<()> where
G: Gate,
[src]
G: Gate,
fn apply_conditional_gate<G: ?Sized>(
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
[src]
&mut self,
control: &[bool],
gate: &G,
bits: &[usize]
) -> Result<()> where
G: Gate,
Apply a conditional n-ary quantum gate gate
, controlled by classical
bit control
, on the qubits from bits
in this state.
fn measure<R: Rng>(&mut self, qbit: usize, rng: &mut R) -> Result<Array1<u64>>
[src]
fn measure_into<R: Rng>(
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn measure_all<R: Rng>(&mut self, rng: &mut R) -> Result<Array1<u64>>
[src]
fn measure_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn peek_into<R: Rng>(
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&self,
qbit: usize,
cbit: usize,
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
fn peek_all_into<R: Rng>(
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>
[src]
&mut self,
cbits: &[usize],
res: &mut Array1<u64>,
rng: &mut R
) -> Result<()>