Skip to main content

q_rust/ir/
operations.rs

1use super::gates::GateType;
2
3/// Represents a single operation in the quantum circuit.
4///
5/// Operations can be quantum gates, measurements, resets, or barriers.
6#[derive(Debug, Clone, PartialEq)]
7pub enum Operation {
8    /// A quantum gate application.
9    Gate {
10        /// Type of the gate (e.g., H, CX).
11        name: GateType,
12        /// Indices of the qubits involved.
13        qubits: Vec<usize>,
14        /// Parameters for the gate (if any).
15        params: Vec<f64>,
16    },
17    /// A measurement operation.
18    Measure {
19        /// Index of the qubit to measure.
20        qubit: usize,
21        /// Index of the classical bit to store the result.
22        cbit: usize,
23    },
24    /// Reset a qubit to the |0> state.
25    Reset {
26        /// Index of the qubit to reset.
27        qubit: usize,
28    },
29    /// A barrier to prevent optimizations across a boundary.
30    Barrier {
31        /// Indices of the qubits involved in the barrier.
32        qubits: Vec<usize>,
33    },
34}