@@ -68,26 +68,23 @@ def _pi(rads):
68
68
69
69
@value .value_equality
70
70
class XPowGate (eigen_gate .EigenGate ):
71
- """A gate that rotates around the X axis of the Bloch sphere.
71
+ r """A gate that rotates around the X axis of the Bloch sphere.
72
72
73
- The unitary matrix of ``XPowGate(exponent=t)`` is:
74
-
75
- [[g·c, -i·g·s],
76
- [-i·g·s, g·c]]
77
-
78
- where:
79
-
80
- c = cos(π·t/2)
81
- s = sin(π·t/2)
82
- g = exp(i·π·t/2).
73
+ The unitary matrix of `cirq.XPowGate(exponent=t)` is:
74
+ $$
75
+ \begin{bmatrix}
76
+ e^{i \pi t /2} \cos(\pi t) & -i e^{i \pi t /2} \sin(\pi t) \\
77
+ -i e^{i \pi t /2} \sin(\pi t) & e^{i \pi t /2} \cos(\pi t)
78
+ \end{bmatrix}
79
+ $$
83
80
84
81
Note in particular that this gate has a global phase factor of
85
- e^{i·π·t/2} vs the traditionally defined rotation matrices
86
- about the Pauli X axis. See `cirq.rx ` for rotations without the global
82
+ $ e^{i \pi t / 2}$ vs the traditionally defined rotation matrices
83
+ about the Pauli X axis. See `cirq.Rx ` for rotations without the global
87
84
phase. The global phase factor can be adjusted by using the `global_shift`
88
85
parameter when initializing.
89
86
90
- `cirq.X`, the Pauli X gate, is an instance of this gate at exponent=1.
87
+ `cirq.X`, the Pauli X gate, is an instance of this gate at ` exponent=1` .
91
88
"""
92
89
93
90
def _num_qubits_ (self ) -> int :
@@ -245,14 +242,18 @@ def __repr__(self) -> str:
245
242
246
243
247
244
class Rx (XPowGate ):
248
- """A gate, with matrix e^{-i X rads/2}, that rotates around the X axis of the Bloch sphere.
249
-
250
- The unitary matrix of ``Rx(rads=t)`` is:
251
-
252
- exp(-i X t/2) = [ cos(t/2) -isin(t/2)]
253
- [-isin(t/2) cos(t/2) ]
254
-
255
- The gate corresponds to the traditionally defined rotation matrices about the Pauli X axis.
245
+ r"""A gate with matrix $e^{-i X t/2}$ that rotates around the X axis of the Bloch sphere by $t$.
246
+
247
+ The unitary matrix of `cirq.Rx(rads=t)` is:
248
+ $$
249
+ e^{-i X t /2} =
250
+ \begin{bmatrix}
251
+ \cos(t/2) & -i \sin(t/2) \\
252
+ -i \sin(t/2) & \cos(t/2)
253
+ \end{bmatrix}
254
+ $$
255
+
256
+ This gate corresponds to the traditionally defined rotation matrices about the Pauli X axis.
256
257
"""
257
258
258
259
def __init__ (self , * , rads : value .TParamVal ):
@@ -286,26 +287,23 @@ def _from_json_dict_(cls, rads, **kwargs) -> 'Rx':
286
287
287
288
@value .value_equality
288
289
class YPowGate (eigen_gate .EigenGate ):
289
- """A gate that rotates around the Y axis of the Bloch sphere.
290
-
291
- The unitary matrix of ``YPowGate(exponent=t)`` is:
290
+ r"""A gate that rotates around the Y axis of the Bloch sphere.
292
291
293
- [[g·c, -g·s],
294
- [g·s, g·c]]
295
-
296
- where:
297
-
298
- c = cos(π·t/2)
299
- s = sin(π·t/2)
300
- g = exp(i·π·t/2).
292
+ The unitary matrix of `cirq.YPowGate(exponent=t)` is:
293
+ $$
294
+ \begin{bmatrix}
295
+ e^{i \pi t /2} \cos(\pi t /2) & - e^{i \pi t /2} \sin(\pi t /2) \\
296
+ e^{i \pi t /2} \sin(\pi t /2) & e^{i \pi t /2} \cos(\pi t /2)
297
+ \end{bmatrix}
298
+ $$
301
299
302
300
Note in particular that this gate has a global phase factor of
303
- e^{i·π·t/2} vs the traditionally defined rotation matrices
301
+ $ e^{i \pi t / 2}$ vs the traditionally defined rotation matrices
304
302
about the Pauli Y axis. See `cirq.Ry` for rotations without the global
305
303
phase. The global phase factor can be adjusted by using the `global_shift`
306
304
parameter when initializing.
307
305
308
- `cirq.Y`, the Pauli Y gate, is an instance of this gate at exponent=1.
306
+ `cirq.Y`, the Pauli Y gate, is an instance of this gate at ` exponent=1` .
309
307
"""
310
308
311
309
def _num_qubits_ (self ) -> int :
@@ -416,14 +414,18 @@ def __repr__(self) -> str:
416
414
417
415
418
416
class Ry (YPowGate ):
419
- """A gate, with matrix e^{-i Y rads/2}, that rotates around the Y axis of the Bloch sphere.
420
-
421
- The unitary matrix of ``Ry(rads=t)`` is:
422
-
423
- exp(-i Y t/2) = [cos(t/2) -sin(t/2)]
424
- [sin(t/2) cos(t/2) ]
425
-
426
- The gate corresponds to the traditionally defined rotation matrices about the Pauli Y axis.
417
+ r"""A gate with matrix $e^{-i Y t/2}$ that rotates around the Y axis of the Bloch sphere by $t$.
418
+
419
+ The unitary matrix of `cirq.Ry(rads=t)` is:
420
+ $$
421
+ e^{-i Y t / 2} =
422
+ \begin{bmatrix}
423
+ \cos(t/2) & -\sin(t/2) \\
424
+ \sin(t/2) & \cos(t/2)
425
+ \end{bmatrix}
426
+ $$
427
+
428
+ This gate corresponds to the traditionally defined rotation matrices about the Pauli Y axis.
427
429
"""
428
430
429
431
def __init__ (self , * , rads : value .TParamVal ):
@@ -457,24 +459,23 @@ def _from_json_dict_(cls, rads, **kwargs) -> 'Ry':
457
459
458
460
@value .value_equality
459
461
class ZPowGate (eigen_gate .EigenGate ):
460
- """A gate that rotates around the Z axis of the Bloch sphere.
461
-
462
- The unitary matrix of ``ZPowGate(exponent=t)`` is:
462
+ r"""A gate that rotates around the Z axis of the Bloch sphere.
463
463
464
- [[1, 0],
465
- [0, g]]
466
-
467
- where:
468
-
469
- g = exp(i·π·t).
464
+ The unitary matrix of `cirq.ZPowGate(exponent=t)` is:
465
+ $$
466
+ \begin{bmatrix}
467
+ 1 & 0 \\
468
+ 0 & e^{i \pi t}
469
+ \end{bmatrix}
470
+ $$
470
471
471
472
Note in particular that this gate has a global phase factor of
472
- e^{i·π· t/2} vs the traditionally defined rotation matrices
473
+ $ e^{i\pi t/2}$ vs the traditionally defined rotation matrices
473
474
about the Pauli Z axis. See `cirq.Rz` for rotations without the global
474
475
phase. The global phase factor can be adjusted by using the `global_shift`
475
476
parameter when initializing.
476
477
477
- `cirq.Z`, the Pauli Z gate, is an instance of this gate at exponent=1.
478
+ `cirq.Z`, the Pauli Z gate, is an instance of this gate at ` exponent=1` .
478
479
"""
479
480
480
481
def _num_qubits_ (self ) -> int :
@@ -658,14 +659,18 @@ def _commutes_on_qids_(
658
659
659
660
660
661
class Rz (ZPowGate ):
661
- """A gate, with matrix e^{-i Z rads/2}, that rotates around the Z axis of the Bloch sphere.
662
-
663
- The unitary matrix of ``Rz(rads=t)`` is:
664
-
665
- exp(-i Z t/2) = [ e^(-it/2) 0 ]
666
- [ 0 e^(it/2)]
667
-
668
- The gate corresponds to the traditionally defined rotation matrices about the Pauli Z axis.
662
+ r"""A gate with matrix $e^{-i Z t/2}$ that rotates around the Z axis of the Bloch sphere by $t$.
663
+
664
+ The unitary matrix of `cirq.Rz(rads=t)` is:
665
+ $$
666
+ e^{-i Z t /2} =
667
+ \begin{bmatrix}
668
+ e^{-it/2} & 0 \\
669
+ 0 & e^{it/2}
670
+ \end{bmatrix}
671
+ $$
672
+
673
+ This gate corresponds to the traditionally defined rotation matrices about the Pauli Z axis.
669
674
"""
670
675
671
676
def __init__ (self , * , rads : value .TParamVal ):
@@ -698,20 +703,24 @@ def _from_json_dict_(cls, rads, **kwargs) -> 'Rz':
698
703
699
704
700
705
class HPowGate (eigen_gate .EigenGate ):
701
- """A Gate that performs a rotation around the X+Z axis of the Bloch sphere.
702
-
703
- The unitary matrix of ``HPowGate(exponent=t)`` is:
704
-
705
- [[g·(c-i·s/sqrt(2)), -i·g·s/sqrt(2)],
706
- [-i·g·s/sqrt(2)], g·(c+i·s/sqrt(2))]]
707
-
708
- where
709
-
710
- c = cos(π·t/2)
711
- s = sin(π·t/2)
712
- g = exp(i·π·t/2).
713
-
714
- Note in particular that for `t=1`, this gives the Hadamard matrix.
706
+ r"""A Gate that performs a rotation around the X+Z axis of the Bloch sphere.
707
+
708
+ The unitary matrix of `cirq.HPowGate(exponent=t)` is:
709
+ $$
710
+ \begin{bmatrix}
711
+ e^{i\pi t/2} \left(\cos(\pi t/2) - i \frac{\sin (\pi t /2)}{\sqrt{2}}\right)
712
+ && -i e^{i\pi t/2} \frac{\sin(\pi t /2)}{\sqrt{2}} \\
713
+ -i e^{i\pi t/2} \frac{\sin(\pi t /2)}{\sqrt{2}}
714
+ && e^{i\pi t/2} \left(\cos(\pi t/2) + i \frac{\sin (\pi t /2)}{\sqrt{2}}\right)
715
+ \end{bmatrix}
716
+ $$
717
+ Note in particular that for $t=1$, this gives the Hadamard matrix
718
+ $$
719
+ \begin{bmatrix}
720
+ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\
721
+ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}
722
+ \end{bmatrix}
723
+ $$
715
724
716
725
`cirq.H`, the Hadamard gate, is an instance of this gate at `exponent=1`.
717
726
"""
@@ -1001,7 +1010,7 @@ class CXPowGate(eigen_gate.EigenGate):
1001
1010
or named arguments CNOT(control=q1, target=q2).
1002
1011
(Mixing the two is not permitted.)
1003
1012
1004
- The unitary matrix of `CXPowGate(exponent=t)` is:
1013
+ The unitary matrix of `cirq. CXPowGate(exponent=t)` is:
1005
1014
1006
1015
[[1, 0, 0, 0],
1007
1016
[0, 1, 0, 0],
@@ -1197,46 +1206,51 @@ def cphase(rads: value.TParamVal) -> CZPowGate:
1197
1206
H = HPowGate ()
1198
1207
document (
1199
1208
H ,
1200
- """The Hadamard gate.
1209
+ r """The Hadamard gate.
1201
1210
1202
1211
The `exponent=1` instance of `cirq.HPowGate`.
1203
1212
1204
- Matrix:
1205
- ```
1206
- [[s, s],
1207
- [s, -s]]
1208
- ```
1209
- where s = sqrt(0.5).
1213
+ The unitary matrix of `cirq.H` is:
1214
+ $$
1215
+ \begin{bmatrix}
1216
+ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\
1217
+ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}
1218
+ \end{bmatrix}
1219
+ $$
1210
1220
""" ,
1211
1221
)
1212
1222
1213
1223
S = ZPowGate (exponent = 0.5 )
1214
1224
document (
1215
1225
S ,
1216
- """The Clifford S gate.
1226
+ r """The Clifford S gate.
1217
1227
1218
1228
The `exponent=0.5` instance of `cirq.ZPowGate`.
1219
1229
1220
- Matrix:
1221
- ```
1222
- [[1, 0],
1223
- [0, i]]
1224
- ```
1230
+ The unitary matrix of `cirq.S` is:
1231
+ $$
1232
+ \begin{bmatrix}
1233
+ 1 & 0 \\
1234
+ 0 & i
1235
+ \end{bmatrix}
1236
+ $$
1225
1237
""" ,
1226
1238
)
1227
1239
1228
1240
T = ZPowGate (exponent = 0.25 )
1229
1241
document (
1230
1242
T ,
1231
- """The non-Clifford T gate.
1243
+ r """The non-Clifford T gate.
1232
1244
1233
1245
The `exponent=0.25` instance of `cirq.ZPowGate`.
1234
1246
1235
- Matrix:
1236
- ```
1237
- [[1, 0]
1238
- [0, exp(i pi / 4)]]
1239
- ```
1247
+ The unitary matrix of `cirq.T` is
1248
+ $$
1249
+ \begin{bmatrix}
1250
+ 1 & 0 \\
1251
+ 0 & e^{i \pi /4}
1252
+ \end{bmatrix}
1253
+ $$
1240
1254
""" ,
1241
1255
)
1242
1256
0 commit comments