uniqc.circuit_builder.qubit module#

Named quantum register and qubit types.

This module provides: - Qubit: Named reference to a single qubit within a register - QReg: Named quantum register with indexing and slicing support - QRegSlice: Slice view of a QReg for multi-qubit operations

Example usage:

qr = QReg(name="a", size=4, base_index=0)
q0 = qr[0]           # Qubit(name="a[0]", index=0, base_index=0)
q_slice = qr[1:3]    # QRegSlice with qubits at indices 1, 2
int(q0)              # 0 (physical qubit index)
int(qr[2])           # 2
class uniqc.circuit_builder.qubit.QReg(name, size, base_index=0)[source]#

Bases: object

Named quantum register with indexing and slicing support.

QReg provides named access to qubits within a circuit, supporting integer indexing, negative indexing, and slicing.

Variables:
  • name – Name of the register

  • size – Number of qubits in the register

  • base_index – Starting physical qubit index (set when mapped to circuit)

Parameters:

Example

>>> qr = QReg(name="a", size=4, base_index=0)
>>> qr[0]
Qubit('a[0]', index=0, base_index=0)
>>> qr[1:3]
QRegSlice(a[1, 2])
>>> len(qr)
4
property base_index: int#
property name: str#
property qubits: list[Qubit]#

Return list of all Qubit objects in this register.

property size: int#
class uniqc.circuit_builder.qubit.QRegSlice(register, indices)[source]#

Bases: object

Slice view of a QReg for multi-qubit operations.

This class provides iteration and indexing over a subset of qubits from a parent register.

Variables:
  • register – Parent QReg

  • indices – List of indices within the parent register

Parameters:
property indices: list[int]#
property register: QReg#
class uniqc.circuit_builder.qubit.Qubit(name, index, base_index)[source]#

Bases: object

Named reference to a single qubit within a quantum register.

Variables:
  • name (str) – Full name of the qubit, e.g., “a[0]”

  • index (int) – Index within the parent register

  • base_index (int) – Starting physical qubit index for the parent register

Parameters:

Example

>>> q = Qubit(name="a[2]", index=2, base_index=10)
>>> int(q)
12
base_index: int#
index: int#
name: str#