Struct quantum::registers::ClassicalRegister [] [src]

pub struct ClassicalRegister {
    // some fields omitted
}

Represents a non-quantum register of width() bits.

We store this inefficiently for clarity.

Methods

impl ClassicalRegister
[src]

fn new(bits: Vec<u8>) -> ClassicalRegister

Construct a new non-quantum register, given a vector of ones and zeroes.

The width is automatically determined from the vector.

fn from_state(width: usize, state: u32) -> ClassicalRegister

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.

fn from_int(width: usize, int: u32) -> ClassicalRegister

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.

fn zeroed(width: usize) -> ClassicalRegister

Construct zero-initialized non-quantum register of given width.

fn width(&self) -> usize

Compute the register's width.

fn state(&self) -> u32

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 2n 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.

fn to_int(&self) -> u32

Return the integer represented by this register.

See the state() method documentation for details of the encoding.

Trait Implementations

Derived Implementations

impl PartialEq for ClassicalRegister
[src]

fn eq(&self, __arg_0: &ClassicalRegister) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &ClassicalRegister) -> bool

This method tests for !=.

impl Eq for ClassicalRegister
[src]

impl Debug for ClassicalRegister
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.