mimiqcircuits.decomposition.rules.special_angle¶
Special angle rewrite rule for Clifford+T decomposition.
Classes
|
Rewrite rule for decomposing rotations with special angles to Clifford+T. |
- class mimiqcircuits.decomposition.rules.special_angle.SpecialAngleRewrite(only_cliffords=False)[source]¶
Bases:
RewriteRuleRewrite rule for decomposing rotations with special angles to Clifford+T.
Decomposes single-qubit rotations whose angle is a multiple of pi/4 into explicit Clifford or Clifford+T gates.
This rule only matches rotations with angles k*pi/4 (or k*pi/2 in Clifford-only mode). Generic rotations with arbitrary angles are not matched.
- Parameters:
only_cliffords (bool) – If True, only match angles k*pi/2 (Clifford gates only). If False (default), match angles k*pi/4 (Clifford+T).
- Supported operations:
GateRX(theta)where theta = k*pi/4GateRY(theta)where theta = k*pi/4GateRZ(lambda)where lambda = k*pi/4
Example
>>> from mimiqcircuits import GateRZ >>> from mimiqcircuits.decomposition import SpecialAngleRewrite >>> from symengine import pi >>> rule = SpecialAngleRewrite() >>> rule.matches(GateRZ(pi/4)) # True, decomposes to T True >>> rule.matches(GateRZ(0.123)) # False, not a special angle False
- decompose_step(op, qubits, bits, zvars)[source]¶
Decompose the rotation to Clifford+T gates.
- Parameters:
- Returns:
A Circuit containing the decomposed instructions.
- Raises:
DecompositionError – If the operation cannot be decomposed.
- Return type:
- __init__(only_cliffords=False)¶