QCDType#

qualtran.QCDType

The abstract interface for quantum/classical quantum computing data types.

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#

get_classical_domain

View source

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

to_bits

View source

Yields individual bits corresponding to binary representation of x

to_bits_array

View source

Yields an NDArray of bits corresponding to binary representations of the input elements.

Often, converting an array can be performed faster than converting each element individually. This operation accepts any NDArray of values, and the output array satisfies output_shape = input_shape + (self.bitsize,).

from_bits

View source

Combine individual bits to form x

from_bits_array

View source

Combine individual bits to form classical values.

Often, converting an array can be performed faster than converting each element individually. This operation accepts any NDArray of bits such that the last dimension equals self.bitsize, and the output array satisfies output_shape = input_shape[:-1].

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.

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.

is_symbolic

View source

Returns True if this dtype is parameterized with symbolic objects.

iteration_length_or_zero

View source

Safe version of iteration length.

Returns the iteration_length if the type has it or else zero.