pdft.circuit.Program#

class pdft.circuit.Program(m, n, steps, slot)[source]#

Bases: object

The 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. steps is the gate sequence in temporal order. slot[i] is the position of step i’s tensor in the tensor list a basis stores, which is sorted Hadamards-first to match Julia’s perm_vec; the sort is decided once, from the initial tensor values, by compile_program.

Parameters:
__init__(m, n, steps, slot)#
Parameters:
Return type:

None

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

sorted_steps

(kind, qubits) of each tensor, in the order the tensor list stores them.

m

n

steps

slot

m: int#
n: int#
steps: tuple[tuple[str, tuple[int, ...]], ...]#
slot: tuple[int, ...]#
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.

kind is one of GATE_KINDS. register is "row" (every qubit of the gate is one of 1..m), "column" (m+1..m+n) or "both" (a gate that couples the two). The result is sorted, ready to be passed as frozen_indices or to index a parameter view: program.tensor_indices(kind="H") freezes every one-qubit gate.

Parameters:
  • kind (str | None)

  • register (str | None)

Return type:

list[int]