Skip to content

Commit

Permalink
Add default decompositions for XXPowGate and YYPowGate which term…
Browse files Browse the repository at this point in the history
…inate in `CZPowGate`. (quantumlib#4862)

Part of quantumlib#4858

Decompositions are tested as part of `assert_eigengate_implements_consistent_protocols`, which is already tested for both gates.
  • Loading branch information
tanujkhattar authored and rht committed May 1, 2023
1 parent e2e38dc commit 6d8434a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cirq-core/cirq/ops/parity_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ def _decompose_into_clifford_with_qubits_(self, qubits):
]
return NotImplemented

def _decompose_(self, qubits: Tuple['cirq.Qid', ...]) -> 'cirq.OP_TREE':
yield common_gates.YPowGate(exponent=-0.5).on_each(*qubits)
yield ZZPowGate(exponent=self.exponent, global_shift=self.global_shift)(*qubits)
yield common_gates.YPowGate(exponent=0.5).on_each(*qubits)

def _circuit_diagram_info_(
self, args: 'cirq.CircuitDiagramInfoArgs'
) -> Union[str, 'protocols.CircuitDiagramInfo']:
Expand Down Expand Up @@ -216,6 +221,11 @@ def _decompose_into_clifford_with_qubits_(self, qubits):
]
return NotImplemented

def _decompose_(self, qubits: Tuple['cirq.Qid', ...]) -> 'cirq.OP_TREE':
yield common_gates.XPowGate(exponent=0.5).on_each(*qubits)
yield ZZPowGate(exponent=self.exponent, global_shift=self.global_shift)(*qubits)
yield common_gates.XPowGate(exponent=-0.5).on_each(*qubits)

def _circuit_diagram_info_(
self, args: 'cirq.CircuitDiagramInfoArgs'
) -> 'cirq.CircuitDiagramInfo':
Expand Down

0 comments on commit 6d8434a

Please sign in to comment.