Skip to main content

apply_gate_sequence_batch

Function apply_gate_sequence_batch 

Source
pub fn apply_gate_sequence_batch(
    batch: &mut BatchStateVector,
    gates: &[(Box<dyn GateOp>, Vec<QubitId>)],
) -> QuantRS2Result<()>
Expand description

Apply multiple gates to a batch using SciRS2 batch operations.

Common fixed (non-parameterized) gates — Hadamard, Paulis, S/T, CNOT, CZ, SWAP, … — are detected by name (see [is_fixed_single_qubit_gate] / [is_fixed_two_qubit_gate]) and their compiled matrices are cached for the duration of the sequence. Repeated-gate patterns such as CNOT chains or Hadamard layers therefore compile their matrix exactly once instead of on every occurrence. Parameterized gates (RX/RY/RZ/U/…) are recompiled per call, because two instances sharing a name may carry different angles.