[−][src]Struct quantum2::other::qubit::NonEntangledQubit
Represents a single (pure, not entangled) qubit state of the form a|0> + b|1>
.
The qubit is the linear superposition of the computational basis of |0>_ and _|1>
.
We encode the complex coeffients as tuples of their real and imaginary parts, each represented as a 64-bit floating points. This gives high accuracy, while allowing word-size arithmetic on 64-bit systems.
The theoretical state should always satisfy the equations:
a = a_re + i * a_im
b = b_re + i * b_im
1 = |a|^2+ |b|^2
This representation of that state should approximately satisfy them, subject to floating point imprecision.
Methods
impl NonEntangledQubit
[src]
pub fn new(a_re: f64, a_im: f64, b_re: f64, b_im: f64) -> NonEntangledQubit
[src]
Safely construct a qubit, given the real and imaginary parts of both coefficients.
This function validates that the given state is possible.
pub fn validate(&self) -> bool
[src]
Validate that this qubit's state is possible.
In our imperfect floating point model, this means computing |a|^2+ |b|^2
and
comparing it to 1
with some leeway.
That leeway is arbitrarily chosen as 10 units of least precision.
Trait Implementations
impl Clone for NonEntangledQubit
[src]
fn clone(&self) -> NonEntangledQubit
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for NonEntangledQubit
[src]
impl Debug for NonEntangledQubit
[src]
Auto Trait Implementations
impl Send for NonEntangledQubit
impl Sync for NonEntangledQubit
impl Unpin for NonEntangledQubit
impl UnwindSafe for NonEntangledQubit
impl RefUnwindSafe for NonEntangledQubit
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut 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,