BQUInt#

qualtran.BQUInt

Unsigned integer whose values are bounded within a range.

Inherits From: QDType, QCDType

LCU methods often make use of coherent for-loops via UnaryIteration, iterating over a range of values stored as a superposition over the SELECT register. Such (nested) coherent for-loops can be represented using a Tuple[Register(dtype=BQUInt), ...] where the i’th entry stores the bitsize and iteration length of i’th nested for-loop.

One useful feature when processing such nested for-loops is to flatten out a composite index, represented by a tuple of indices (i, j, …), one for each selection register into a single integer that can be used to index a flat target register. An example of such a mapping function is described in Eq.45 of https://arxiv.org/abs/1805.03662. A general version of this mapping function can be implemented using numpy.ravel_multi_index and numpy.unravel_index.

bitsize

The number of qubits used to represent the integer.

iteration_length

The length of the iteration range.

num_bits

 

num_cbits

Number of classical bits required to represent a single instance of this data type.

num_qubits

Number of qubits required to represent a single instance of this data type.

Methods#

is_symbolic

View source

Returns True if this dtype is parameterized with symbolic objects.

get_classical_domain

View source

Yields all possible classical (computational basis state) values representable by this type.

assert_valid_classical_val

View source

Raises an exception if val is not a valid classical value for this type.

Args

val

A classical value that should be in the domain of this QDType.

debug_str

Optional debugging information to use in exception messages.

to_bits

View source

Yields individual bits corresponding to binary representation of x

from_bits

View source

Combine individual bits to form x

assert_valid_classical_val_array

View source

Raises an exception if val_array is not a valid array of classical values for this type.

Often, validation on an array can be performed faster than validating each element individually.

Args

val_array

A numpy array of classical values. Each value should be in the domain of this QDType.

debug_str

Optional debugging information to use in exception messages.

__ne__

Check equality and either forward a NotImplemented or return the result negated.

__eq__

Method generated by attrs for class BQUInt.