[−][src]Struct quantum2::ket::Ket
A ket describes the state of a quantum register.
We choose to always use kets as coefficients for linear combinations of
the computational basis. A register of width n
corresponds to a ket
of size 2^n. Theoretically, the sum of the square coefficient moduli
must equal 1
.
We store the elements (left-aligned) in an array of size MAX_SIZE
, with
the unused slots set to zero.
See Wikipedia for more information.
Fields
elements: [Complex; 32]
The ket's elements, w.r.t. the computational basis.
Methods
impl Ket
[src]
pub fn new(size: usize) -> Ket
[src]
Construct a new, zero-initialized ket of given size.
pub fn from_classical(register: &ClassicalRegister) -> Ket
[src]
Generate a ket from a classical register.
This ket encodes a single basis vector, and is used for initializing a quantum register to an initial (classical) state.
pub fn is_valid(&self) -> bool
[src]
Is this structure a valid ket?
pub fn is_classical(&self) -> bool
[src]
Determine whether this ket represents a classically possible state.
This is true iff. the ket encodes a single basis vector, meaning that
precisely one slot will have value 1
, and all others 0
.
pub fn size(register_width: usize) -> usize
[src]
Compute a ket's size from the register width.
pub fn apply(&mut self, gate: Gate)
[src]
Apply a quantum gate to this ket, mutating its state.
Trait Implementations
impl Clone for Ket
[src]
impl Copy for Ket
[src]
impl PartialEq<Ket> for Ket
[src]
impl Debug for Ket
[src]
Auto Trait Implementations
impl Send for Ket
impl Sync for Ket
impl Unpin for Ket
impl UnwindSafe for Ket
impl RefUnwindSafe for Ket
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,