pub struct StateVector { /* private fields */ }
Expand description
Represent the state vector of a quantum system simulation.
Implementations§
Source§impl StateVector
impl StateVector
Sourcepub fn new(qubit_width: usize) -> Self
pub fn new(qubit_width: usize) -> Self
Create a new state-vector with of length 2 to the qubit_width
power
and all the amplitude concentrated in the all-zeroes outcome.
Sourcepub fn as_complex_bases(&self) -> &[Complex] ⓘ
pub fn as_complex_bases(&self) -> &[Complex] ⓘ
Return the amplitudes corresponding to the bases of the system.
Sourcepub fn qubit_width(&self) -> usize
pub fn qubit_width(&self) -> usize
Return the 2-base logarithm of the number of amplitudes representing the number of qubits in the system.
Sourcepub fn from_complex_bases(bases: Vec<Complex>) -> Self
pub fn from_complex_bases(bases: Vec<Complex>) -> Self
Create a new state-vector from a vector of complex numbers representing amplitudes. It does not check the length of the vector is a power of two, not the norm of the vector is 1.
Sourcepub fn cnot(&mut self, control: usize, target: usize)
pub fn cnot(&mut self, control: usize, target: usize)
Apply a controlled not operation on qubit target
.
Sourcepub fn u(&mut self, theta: f64, phi: f64, lambda: f64, target: usize)
pub fn u(&mut self, theta: f64, phi: f64, lambda: f64, target: usize)
Apply a general rotation on target
qubit, specified as
RZ(phi
)RY(theta
)RZ(lambda
).
Sourcepub fn measure(&mut self, target: usize) -> bool
pub fn measure(&mut self, target: usize) -> bool
Perform a measurement on the Z-axis of the quantum state on target
qubit.
Sourcepub fn probabilities(&self) -> Vec<f64>
pub fn probabilities(&self) -> Vec<f64>
Return the probabilities associated to the amplitudes in the state-vector.
Trait Implementations§
Source§impl<'a> ApproxEq for &'a StateVector
impl<'a> ApproxEq for &'a StateVector
Source§type Margin = F64Margin
type Margin = F64Margin
Default
so that
approx_eq()
can be called on unknown types.Source§impl Clone for StateVector
impl Clone for StateVector
Source§fn clone(&self) -> StateVector
fn clone(&self) -> StateVector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more