Skip to main content

recognize_gate_pattern

Function recognize_gate_pattern 

Source
pub fn recognize_gate_pattern(expr: &Expression) -> QuantumGatePattern
Expand description

Try to recognize a quantum gate from its matrix/generator expression.

Bare Pauli/Clifford symbols (X, H, S, …) are recognized directly. Compound exp(-i θ G / 2) forms are recognized structurally via is_rotation_gate: when the generator G is (up to naming) one of the single-qubit Pauli operators, the angle is reported through the corresponding QuantumGatePattern::Rx/Ry/ Rz variant; any other recognized rotation generator is reported as a general QuantumGatePattern::Rotation with the angle in the θ slot and φ = λ = 0 (this expression language only carries a single rotation angle per generator, so the Euler φ/λ decomposition is not recoverable from a single exp(...) node).