QIntOnesComp#
qualtran.QIntOnesComp
View source on GitHub
|
Signed Integer of a given width bitsize.
Inherits From: QDType, QCDType
qualtran.QIntOnesComp(
bitsize
)
In contrast to QInt, this data type uses the ones’ complement representation for negative
integers.
Here (and throughout Qualtran), we use a big-endian bit convention. The most significant bit is at index 0.
Attributes
bitsizeThe number of qubits used to represent the integer.
num_bitsnum_cbitsNumber of classical bits required to represent a single instance of this data type.
num_qubitsNumber of qubits required to represent a single instance of this data type.
Methods#
is_symbolic
is_symbolic() -> bool
Returns True if this dtype is parameterized with symbolic objects.
to_bits
to_bits(
x: int
) -> List[int]
Yields individual bits corresponding to binary representation of x
from_bits
from_bits(
bits: Sequence[int]
) -> int
Combine individual bits to form x
get_classical_domain
get_classical_domain() -> Iterable[int]
Yields all possible classical (computational basis state) values representable by this type.
assert_valid_classical_val
assert_valid_classical_val(
val, debug_str: str = 'val'
)
Raises an exception if val is not a valid classical value for this type.
Args
valA classical value that should be in the domain of this QDType.
debug_strOptional debugging information to use in exception messages.
__ne__
__ne__(
other
)
Check equality and either forward a NotImplemented or return the result negated.
__eq__
__eq__(
other
)
Method generated by attrs for class QIntOnesComp.
View source on GitHub