Skip to main content

apply_gate

Function apply_gate 

Source
pub fn apply_gate(
    state: &mut Array1<Complex64>,
    gate: &dyn GateOp,
) -> QuantRS2Result<()>
Expand description

Apply a single one- or two-qubit gate to state in place.

The gate’s dense matrix (row-major, 2^k × 2^k for a k-qubit gate) is applied to the sub-amplitudes selected by the gate’s target qubits. Only one- and two-qubit gates are supported; larger gates return an honest error rather than silently leaving the state unchanged.