Struct quantum::ket::Ket
[−]
[src]
pub struct Ket {
pub elements: [Complex; MAX_SIZE],
// some fields omitted
}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 2n. 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 | The ket's elements, w.r.t. the computational basis. |
Methods
impl Ket[src]
fn new(size: usize) -> Ket
Construct a new, zero-initialized ket of given size.
fn from_classical(register: &ClassicalRegister) -> Ket
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.
fn is_valid(&self) -> bool
Is this structure a valid ket?
fn is_classical(&self) -> bool
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.
fn size(register_width: usize) -> usize
Compute a ket's size from the register width.
fn apply(&mut self, gate: Gate)
Apply a quantum gate to this ket, mutating its state.
Trait Implementations
Derived Implementations
impl PartialEq for Ket[src]
fn eq(&self, __arg_0: &Ket) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Ket) -> bool
This method tests for !=.
impl Debug for Ket[src]
impl Copy for Ket[src]
impl Clone for Ket[src]
fn clone(&self) -> Ket
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more