Skip to content

Reg

CBitRef dataclass

CBitRef(ref: CRegister, pos: int)

Object representing a reference to a classical bit.

pos instance-attribute

pos: int

The position of this bit in the classical register.

ref instance-attribute

ref: CRegister

The classical register that is holding this bit.

CRegister

CRegister(size: int)

Bases: list[Measurement]

Runtime representation of a classical register.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/reg.py
22
23
def __init__(self, size: int):
    super().__init__(Measurement.Zero for _ in range(size))

Measurement

Bases: IntEnum

Enumeration of measurement results.

PyQrackQubit dataclass

PyQrackQubit(
    addr: int, sim_reg: QrackSimulator, state: QubitState
)

Bases: Qubit

The runtime representation of a qubit reference.

addr instance-attribute

addr: int

The address of this qubit in the quantum register.

sim_reg instance-attribute

sim_reg: QrackSimulator

The register of the simulator.

state instance-attribute

state: QubitState

The state of the qubit (active/lost)

drop

drop()

Drop the qubit in-place.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/reg.py
70
71
72
def drop(self):
    """Drop the qubit in-place."""
    self.state = QubitState.Lost

is_active

is_active() -> bool

Check if the qubit is active.

Returns True if the qubit is active, False otherwise.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/reg.py
61
62
63
64
65
66
67
68
def is_active(self) -> bool:
    """Check if the qubit is active.

    Returns
        True if the qubit is active, False otherwise.

    """
    return self.state is QubitState.Active