@@ -179,35 +179,38 @@ def __pow__(self, power):
179179class MSGate (cirq .Gate ):
180180 r"""The Mølmer–Sørensen (MS) gate is a two qubit gate native to trapped ions.
181181
182- The unitary matrix of this gate for parameters $\phi_0$ and $\phi_1$ is
182+ The unitary matrix of this gate for parameters $\phi_0$, $\phi_1$ and $\theta is
183183
184184 $$
185- \frac{1}{\sqrt{2}}
186185 \begin{bmatrix}
187- 1 & 0 & 0 & -ie ^{-i2 \pi(\phi_0+\phi_1)} \\
188- 0 & 1 & -ie ^{-i2 \pi(\phi_0-\phi_1)} & 0 \\
189- 0 & -ie^{i2 \pi(\phi_0-\phi_1)} & 1 & 0 \\
190- -ie^{i2 \pi(\phi_0+\phi_1)} & 0 & 0 & 1 \\
186+ cos{\theta} & 0 & 0 & -i*e ^{-i*2* \pi(\phi_0+\phi_1)}*sin{\theta } \\
187+ 0 & cos{\theta} & -i*e ^{-i*2* \pi(\phi_0-\phi_1)}*sin{\theta } & 0 \\
188+ 0 & -i*e^{i*2* \pi(\phi_0-\phi_1)}*sin(\theta) & cos{\theta} & 0 \\
189+ -i*e^{i*2* \pi(\phi_0+\phi_1)}*sin{\theta} & 0 & 0 & cos{\theta}
191190 \end{bmatrix}
192191 $$
193192
194193 See [IonQ best practices](https://ionq.com/docs/getting-started-with-native-gates){:external}.
195194 """
196195
197- def __init__ (self , * , phi0 , phi1 ):
196+ def __init__ (self , * , phi0 , phi1 , theta = 0.25 ):
198197 self .phi0 = phi0
199198 self .phi1 = phi1
199+ self .theta = theta
200200
201201 def _unitary_ (self ) -> np .ndarray :
202- diag = 1 / math . sqrt ( 2 )
202+ theta = self . theta
203203 phi0 = self .phi0
204204 phi1 = self .phi1
205+ diag = np .cos (2 * math .pi * theta )
206+ sin = np .sin (2 * math .pi * theta )
207+
205208 return np .array (
206209 [
207- [diag , 0 , 0 , diag * - 1j * cmath .exp (- 1j * 2 * math .pi * (phi0 + phi1 ))],
208- [0 , diag , diag * - 1j * cmath .exp (- 1j * 2 * math .pi * (phi0 - phi1 )), 0 ],
209- [0 , diag * - 1j * cmath .exp (1j * 2 * math .pi * (phi0 - phi1 )), diag , 0 ],
210- [diag * - 1j * cmath .exp (1j * 2 * math .pi * (phi0 + phi1 )), 0 , 0 , diag ],
210+ [diag , 0 , 0 , sin * - 1j * cmath .exp (- 1j * 2 * math .pi * (phi0 + phi1 ))],
211+ [0 , diag , sin * - 1j * cmath .exp (- 1j * 2 * math .pi * (phi0 - phi1 )), 0 ],
212+ [0 , sin * - 1j * cmath .exp (1j * 2 * math .pi * (phi0 - phi1 )), diag , 0 ],
213+ [sin * - 1j * cmath .exp (1j * 2 * math .pi * (phi0 + phi1 )), 0 , 0 , diag ],
211214 ]
212215 )
213216
@@ -232,7 +235,7 @@ def __repr__(self) -> str:
232235 return f'cirq_ionq.MSGate(phi0={ self .phi0 !r} , phi1={ self .phi1 !r} )'
233236
234237 def _json_dict_ (self ) -> Dict [str , Any ]:
235- return cirq .obj_to_dict_helper (self , ['phi0' , 'phi1' ])
238+ return cirq .obj_to_dict_helper (self , ['phi0' , 'phi1' , 'theta' ])
236239
237240 def _value_equality_values_ (self ) -> Any :
238241 return (self .phi0 , self .phi1 )
0 commit comments