@@ -28,107 +28,77 @@ DEFGATE H:
28
28
29
29
## Cartesian Rotation Gates
30
30
31
- DEFGATE RX(%theta):
32
- cos(%theta/2), -i*sin(%theta/2)
33
- -i*sin(%theta/2), cos(%theta/2)
31
+ DEFGATE RX(%theta) p AS PAULI-SUM:
32
+ X(-%theta/2) p
34
33
35
- DEFGATE RY(%theta):
36
- cos(%theta/2), -sin(%theta/2)
37
- sin(%theta/2), cos(%theta/2)
34
+ DEFGATE RY(%theta) p AS PAULI-SUM:
35
+ Y(-%theta/2) p
38
36
39
- DEFGATE RZ(%theta):
40
- cis(-%theta/2), 0
41
- 0, cis(%theta/2)
37
+ DEFGATE RZ(%theta) p AS PAULI-SUM:
38
+ Z(-%theta/2) p
42
39
43
40
44
41
## Controlled-NOT Variants
45
42
46
- DEFGATE CNOT:
47
- 1, 0, 0, 0
48
- 0, 1, 0, 0
49
- 0, 0, 0, 1
50
- 0, 0, 1, 0
43
+ DEFGATE CNOT p q AS SEQUENCE:
44
+ CONTROLLED X p q
51
45
52
46
# Also known as the Toffoli gate.
53
- DEFGATE CCNOT:
54
- 1, 0, 0, 0, 0, 0, 0, 0
55
- 0, 1, 0, 0, 0, 0, 0, 0
56
- 0, 0, 1, 0, 0, 0, 0, 0
57
- 0, 0, 0, 1, 0, 0, 0, 0
58
- 0, 0, 0, 0, 1, 0, 0, 0
59
- 0, 0, 0, 0, 0, 1, 0, 0
60
- 0, 0, 0, 0, 0, 0, 0, 1
61
- 0, 0, 0, 0, 0, 0, 1, 0
62
-
47
+ DEFGATE CCNOT p q r AS SEQUENCE:
48
+ CONTROLLED CONTROLLED X p q r
63
49
64
50
## Phase Gates
65
51
52
+ # Equivalent to RZ(pi/2) up to global phase
66
53
DEFGATE S:
67
54
1, 0
68
55
0, i
69
56
57
+ # Equivalent to RZ(pi/4) up to global phase
70
58
DEFGATE T:
71
59
1, 0
72
60
0, cis(pi/4)
73
61
62
+ # Equivalent to RZ(%alpha) up to global phase
74
63
DEFGATE PHASE(%alpha):
75
64
1, 0
76
65
0, cis(%alpha)
77
66
78
- DEFGATE CPHASE00(%alpha):
79
- cis(%alpha), 0, 0, 0
80
- 0, 1, 0, 0
81
- 0, 0, 1, 0
82
- 0, 0, 0, 1
83
-
84
- DEFGATE CPHASE01(%alpha):
85
- 1, 0, 0, 0
86
- 0, cis(%alpha), 0, 0
87
- 0, 0, 1, 0
88
- 0, 0, 0, 1
89
-
90
- DEFGATE CPHASE10(%alpha):
91
- 1, 0, 0, 0
92
- 0, 1, 0, 0
93
- 0, 0, cis(%alpha), 0
94
- 0, 0, 0, 1
95
-
96
- DEFGATE CPHASE(%alpha):
97
- 1, 0, 0, 0
98
- 0, 1, 0, 0
99
- 0, 0, 1, 0
100
- 0, 0, 0, cis(%alpha)
101
-
102
- DEFGATE CZ:
103
- 1, 0, 0, 0
104
- 0, 1, 0, 0
105
- 0, 0, 1, 0
106
- 0, 0, 0, -1
67
+ DEFGATE CPHASE(%alpha) p q AS SEQUENCE:
68
+ CONTROLLED PHASE(%alpha) p q
69
+
70
+ DEFGATE CPHASE00(%alpha) p q AS SEQUENCE:
71
+ X p
72
+ X q
73
+ CONTROLLED PHASE(%alpha) p q
74
+ X p
75
+ X q
76
+
77
+ DEFGATE CPHASE01(%alpha) p q AS SEQUENCE:
78
+ X p
79
+ CONTROLLED PHASE(%alpha) p q
80
+ X p
81
+
82
+ DEFGATE CPHASE10(%alpha) p q AS SEQUENCE:
83
+ X q
84
+ CONTROLLED PHASE(%alpha) p q
85
+ X q
86
+
87
+ DEFGATE CZ p q AS SEQUENCE:
88
+ CONTROLLED Z p q
107
89
108
90
## Swap Gates
109
91
110
- DEFGATE SWAP:
111
- 1, 0, 0, 0
112
- 0, 0, 1, 0
113
- 0, 1, 0, 0
114
- 0, 0, 0, 1
92
+ DEFGATE SWAP AS PERMUTATION:
93
+ 0, 2, 1, 3
115
94
116
95
# Also known as the Fredkin gate.
117
- DEFGATE CSWAP:
118
- 1, 0, 0, 0, 0, 0, 0, 0
119
- 0, 1, 0, 0, 0, 0, 0, 0
120
- 0, 0, 1, 0, 0, 0, 0, 0
121
- 0, 0, 0, 1, 0, 0, 0, 0
122
- 0, 0, 0, 0, 1, 0, 0, 0
123
- 0, 0, 0, 0, 0, 0, 1, 0
124
- 0, 0, 0, 0, 0, 1, 0, 0
125
- 0, 0, 0, 0, 0, 0, 0, 1
126
-
127
- DEFGATE ISWAP:
128
- 1, 0, 0, 0
129
- 0, 0, i, 0
130
- 0, i, 0, 0
131
- 0, 0, 0, 1
96
+ DEFGATE CSWAP p q r AS SEQUENCE:
97
+ CONTROLLED SWAP p q r
98
+
99
+ DEFGATE ISWAP p q AS PAULI-SUM:
100
+ XX(-pi/4) p q
101
+ YY(-pi/4) p q
132
102
133
103
DEFGATE PSWAP(%theta):
134
104
1, 0, 0, 0
@@ -152,11 +122,10 @@ DEFGATE XY(%theta):
152
122
0, i*sin(%theta/2), cos(%theta/2), 0
153
123
0, 0, 0, 1
154
124
155
- DEFGATE CAN(%alpha, %beta, %gamma):
156
- (cis((%alpha+%beta-%gamma)/2)+cis((%alpha-%beta+%gamma)/2))/2, 0, 0, (cis((%alpha-%beta+%gamma)/2)-cis((%alpha+%beta-%gamma)/2))/2
157
- 0, (cis((%alpha+%beta+%gamma)/(-2))+cis((%beta+%gamma-%alpha)/2))/2, (cis((%alpha+%beta+%gamma)/(-2))-cis((%beta+%gamma-%alpha)/2))/2, 0
158
- 0, (cis((%alpha+%beta+%gamma)/(-2))-cis((%beta+%gamma-%alpha)/2))/2, (cis((%alpha+%beta+%gamma)/(-2))+cis((%beta+%gamma-%alpha)/2))/2, 0
159
- (cis((%alpha-%beta+%gamma)/2)-cis((%alpha+%beta-%gamma)/2))/2, 0, 0, (cis((%alpha+%beta-%gamma)/2)+cis((%alpha-%beta+%gamma)/2))/2
125
+ DEFGATE CAN(%alpha, %beta, %gamma) p q AS PAULI-SUM:
126
+ XX(-%alpha/2) p q
127
+ YY(-%beta/2) p q
128
+ ZZ(-%gamma/2) p q
160
129
161
130
DEFGATE BLOCH(%alpha, %beta, %gamma) q AS PAULI-SUM:
162
131
X(%alpha) q
0 commit comments