Skip to main content

logical_multi_cz

Function logical_multi_cz 

Source
pub fn logical_multi_cz<W: NaturalNumber>(
    chains: &[&Gf2Chain<W>],
) -> Result<Vec<GateOp>, QuantumError>
Expand description

The logical multi-controlled Z, Table 1 row 6:

C^{m-1}Z̄(γ₁, …, γ_m) = ∏_{k₁,…,k_m} C^{m-1}Z_{i₁,…,i_m}

over the Cartesian product of the m supports.

§The reduction rule is load-bearing here

The paper defines C^{m-1}Z so that repeated indices reduce: coincident controls drop to a lower-control gate, and a control coinciding with the target drops to a single-qubit Z. Its examples are C³Z_{i,i,j,k} = C²Z_{i,j,k} and C²Z_{i,i,i} = CZ_{i,i} = Z_i. Because the supports may overlap, a raw tuple can carry repeats, so this function deduplicates each tuple before emitting it. That is the paper’s rule and also what QuantumCircuit::new requires, since it rejects a gate naming one qubit twice.

§Errors

QuantumError::DimensionMismatch if chains is empty, or if the chains do not all have the same length; QuantumError::CalculationError naming the tuple count and the cap if multi_cz_tuple_count exceeds TUPLE_ENUMERATION_CAP, before anything is allocated.