pdft.circuit.build_circuit_einsum

pdft.circuit.build_circuit_einsum#

pdft.circuit.build_circuit_einsum(gates, m, n, *, inverse)[source]#

Convert a gate sequence to (subscripts, tensors, shapes).

gates is applied in order to a circuit on m + n qubits (1-indexed). For CP gates, the 2x2 tensor shares the current wire labels of its control and target qubits and does NOT introduce new labels (the gate is diagonal).

Returns the triple needed by einsum_cache.optimize_code_cached. The returned tensor list and tensor-shape list are sorted so Hadamards come first (matching Julia’s perm_vec).

Parameters:
Return type:

tuple[str, list[Array], list[tuple[int, …]]]