@@ -53,8 +53,8 @@ enum GateKind {
53
53
template <typename fp_type>
54
54
using GateQSim = Gate<fp_type, GateKind>;
55
55
56
- constexpr double h = 0.5 ;
57
- constexpr double is2 = 0.7071067811865475 ;
56
+ constexpr double h_double = 0.5 ;
57
+ constexpr double is2_double = 0.7071067811865475 ;
58
58
59
59
// One-qubit gates:
60
60
@@ -76,6 +76,8 @@ struct GateHd {
76
76
static constexpr char name[] = " h" ;
77
77
static constexpr unsigned num_qubits = 1 ;
78
78
79
+ static constexpr fp_type is2 = static_cast <fp_type>(is2_double);
80
+
79
81
static GateQSim<fp_type> Create (unsigned time, unsigned q0) {
80
82
return CreateGate<GateQSim<fp_type>, GateHd>(
81
83
time , q0, {is2, 0 , is2, 0 , is2, 0 , -is2, 0 });
@@ -88,6 +90,8 @@ struct GateT {
88
90
static constexpr char name[] = " t" ;
89
91
static constexpr unsigned num_qubits = 1 ;
90
92
93
+ static constexpr fp_type is2 = static_cast <fp_type>(is2_double);
94
+
91
95
static GateQSim<fp_type> Create (unsigned time, unsigned q0) {
92
96
return CreateGate<GateQSim<fp_type>, GateT>(
93
97
time , q0, {1 , 0 , 0 , 0 , 0 , 0 , is2, is2});
@@ -136,6 +140,8 @@ struct GateX2 {
136
140
static constexpr char name[] = " x_1_2" ;
137
141
static constexpr unsigned num_qubits = 1 ;
138
142
143
+ static constexpr fp_type h = static_cast <fp_type>(h_double);
144
+
139
145
static GateQSim<fp_type> Create (unsigned time, unsigned q0) {
140
146
return CreateGate<GateQSim<fp_type>, GateX2>(
141
147
time , q0, {h, h, h, -h, h, -h, h, h});
@@ -148,6 +154,8 @@ struct GateY2 {
148
154
static constexpr char name[] = " y_1_2" ;
149
155
static constexpr unsigned num_qubits = 1 ;
150
156
157
+ static constexpr fp_type h = static_cast <fp_type>(h_double);
158
+
151
159
static GateQSim<fp_type> Create (unsigned time, unsigned q0) {
152
160
return CreateGate<GateQSim<fp_type>, GateY2>(
153
161
time , q0, {h, h, -h, -h, h, h, h, h});
@@ -227,6 +235,10 @@ struct GateHZ2 {
227
235
static constexpr char name[] = " hz_1_2" ;
228
236
static constexpr unsigned num_qubits = 1 ;
229
237
238
+ static constexpr fp_type h = static_cast <fp_type>(h_double);
239
+
240
+ static constexpr fp_type is2 = static_cast <fp_type>(is2_double);
241
+
230
242
static GateQSim<fp_type> Create (unsigned time, unsigned q0) {
231
243
return CreateGate<GateQSim<fp_type>, GateHZ2>(
232
244
time , q0, {h, h, 0 , -is2, is2, 0 , h, h});
@@ -319,6 +331,8 @@ struct GateSwap {
319
331
static constexpr char name[] = " sw" ;
320
332
static constexpr unsigned num_qubits = 2 ;
321
333
334
+ static constexpr fp_type is2 = static_cast <fp_type>(is2_double);
335
+
322
336
static GateQSim<fp_type> Create (unsigned time, unsigned q0, unsigned q1) {
323
337
return CreateGate<GateQSim<fp_type>, GateSwap>(
324
338
time , q0, q1, {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@@ -343,6 +357,9 @@ struct GateIS {
343
357
static constexpr char name[] = " is" ;
344
358
static constexpr unsigned num_qubits = 2 ;
345
359
360
+ static constexpr fp_type h = static_cast <fp_type>(h_double);
361
+ static constexpr fp_type is2 = static_cast <fp_type>(is2_double);
362
+
346
363
static GateQSim<fp_type> Create (unsigned time, unsigned q0, unsigned q1) {
347
364
return CreateGate<GateQSim<fp_type>, GateIS>(
348
365
time , q0, q1, {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 commit comments