pdft.circuit.Program#
- class pdft.circuit.Program(m, n, steps, slot)[source]#
Bases:
objectThe structure of a circuit: which gate acts on which qubits, in what order.
It holds no tensor values, so it is hashable and can be a static argument of a jitted function: every basis with the same program shares one compiled applier.
stepsis the gate sequence in temporal order.slot[i]is the position of stepi’s tensor in the tensor list a basis stores, which is sorted Hadamards-first to match Julia’sperm_vec; the sort is decided once, from the initial tensor values, bycompile_program.- __init__(m, n, steps, slot)#
Methods
__init__(m, n, steps, slot)tensor_indices([kind, register])Positions in the stored tensor list of the gates of one kind, on one register, or both.
Attributes
(kind, qubits)of each tensor, in the order the tensor list stores them.- property sorted_steps: tuple[tuple[str, tuple[int, ...]], ...]#
(kind, qubits)of each tensor, in the order the tensor list stores them.
- tensor_indices(kind=None, register=None)[source]#
Positions in the stored tensor list of the gates of one kind, on one register, or both.
kindis one ofGATE_KINDS.registeris"row"(every qubit of the gate is one of1..m),"column"(m+1..m+n) or"both"(a gate that couples the two). The result is sorted, ready to be passed asfrozen_indicesor to index a parameter view:program.tensor_indices(kind="H")freezes every one-qubit gate.