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]


              flowchart TD
              bloqade.pyqrack.reg.CRegister[CRegister]

              

              click bloqade.pyqrack.reg.CRegister href "" "bloqade.pyqrack.reg.CRegister"
            

Runtime representation of a classical register.

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

Measurement

Measurement(measurement_id: int = 0)

Bases: MeasurementResult, IntEnum


              flowchart TD
              bloqade.pyqrack.reg.Measurement[Measurement]
              bloqade.types.MeasurementResult[MeasurementResult]

                              bloqade.types.MeasurementResult --> bloqade.pyqrack.reg.Measurement
                


              click bloqade.pyqrack.reg.Measurement href "" "bloqade.pyqrack.reg.Measurement"
              click bloqade.types.MeasurementResult href "" "bloqade.types.MeasurementResult"
            

Enumeration of measurement results.

Source code in .venv/lib/python3.12/site-packages/bloqade/pyqrack/reg.py
15
16
17
def __init__(self, measurement_id: int = 0) -> None:
    super().__init__()
    self.measurement_id = measurement_id

PyQrackQubit dataclass

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

Bases: Qubit


              flowchart TD
              bloqade.pyqrack.reg.PyQrackQubit[PyQrackQubit]
              bloqade.types.Qubit[Qubit]

                              bloqade.types.Qubit --> bloqade.pyqrack.reg.PyQrackQubit
                


              click bloqade.pyqrack.reg.PyQrackQubit href "" "bloqade.pyqrack.reg.PyQrackQubit"
              click bloqade.types.Qubit href "" "bloqade.types.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
75
76
77
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
66
67
68
69
70
71
72
73
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