Skip to content

Commit

Permalink
Add Pauli expansion for PhasedXZ (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
viathor committed Mar 26, 2020
1 parent ad87c57 commit 825aa57
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cirq/ops/phased_x_z_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ def _phase_by_(self, phase_turns, qubit_index) -> 'cirq.PhasedXZGate':
axis_phase_exponent=self._axis_phase_exponent +
phase_turns * 2)

def _pauli_expansion_(self) -> 'cirq.LinearDict[str]':
if protocols.is_parameterized(self):
return NotImplemented
x_angle = np.pi * self._x_exponent / 2
z_angle = np.pi * self._z_exponent / 2
axis_angle = np.pi * self._axis_phase_exponent
phase = np.exp(1j * (x_angle + z_angle))

cx = np.cos(x_angle)
sx = np.sin(x_angle)
return value.LinearDict({
'I': phase * cx * np.cos(z_angle),
'X': -1j * phase * sx * np.cos(z_angle + axis_angle),
'Y': -1j * phase * sx * np.sin(z_angle + axis_angle),
'Z': -1j * phase * cx * np.sin(z_angle),
}) # yapf: disable

def _circuit_diagram_info_(self,
args: 'cirq.CircuitDiagramInfoArgs') -> str:
"""See `cirq.SupportsCircuitDiagramInfo`."""
Expand Down

0 comments on commit 825aa57

Please sign in to comment.