[][src]Struct quantum2::other::qubit::NonEntangledQubit

pub struct NonEntangledQubit { /* fields omitted */ }

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]

impl Copy for NonEntangledQubit[src]

impl Debug for NonEntangledQubit[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]