[][src]Struct quantum2::registers::ClassicalRegister

pub struct ClassicalRegister { /* fields omitted */ }

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]

impl Debug for ClassicalRegister[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, 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]