[−][src]Struct quantum2::registers::ClassicalRegister
Represents a non-quantum register of width()
bits.
We store this inefficiently for clarity.
Methods
impl ClassicalRegister
[src]
pub fn new(bits: Vec<u8>) -> ClassicalRegister
[src]
Construct a new non-quantum register, given a vector of ones and zeroes.
The width is automatically determined from the vector.
pub fn from_state(width: usize, state: u32) -> ClassicalRegister
[src]
Construct a new non-quantum register, given a state
.
See the state()
method documentation for details of the encoding.
Panics
We assert that the state is valid for the given width.
pub fn from_int(width: usize, int: u32) -> ClassicalRegister
[src]
Construct a new non-quantum register, given an unsigned integer.
See the state()
method documentation for details of the encoding.
Panics
We assert that the integer is valid for the width.
pub fn zeroed(width: usize) -> ClassicalRegister
[src]
Construct zero-initialized non-quantum register of given width
.
pub fn width(&self) -> usize
[src]
Compute the register's width
.
pub fn state(&self) -> u32
[src]
Compute the current state
of the register.
The state
is an integer which uniquely specifies all register bits (for a
given width). It does this in the obvious way, by enumerating all 2^n bit
strings in the reversed lexicographic order, and assigning each string an index.
This is equivalent to interpreting the register as an integer with the leftmost bit of least significance.
Panics
This only works for registers of width <= 32
.
pub fn to_int(&self) -> u32
[src]
Return the integer represented by this register.
See the state()
method documentation for details of the encoding.
Trait Implementations
impl Eq for ClassicalRegister
[src]
impl PartialEq<ClassicalRegister> for ClassicalRegister
[src]
fn eq(&self, other: &ClassicalRegister) -> bool
[src]
fn ne(&self, other: &ClassicalRegister) -> bool
[src]
impl Debug for ClassicalRegister
[src]
Auto Trait Implementations
impl Send for ClassicalRegister
impl Sync for ClassicalRegister
impl Unpin for ClassicalRegister
impl UnwindSafe for ClassicalRegister
impl RefUnwindSafe for ClassicalRegister
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, 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,