Skip to content

Commit 1678882

Browse files
Attempted fix of narrowing-conversion.
1 parent 438402d commit 1678882

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

apps/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ windows_copts = [
2020
"/Iexternal/gemmlowp",
2121
"/wd4018",
2222
"/wd4577",
23-
"/wd4267", # Silence "narrowing conversion" errors.
2423
"/DNOGDI",
2524
"/UTF_COMPILE_LIBRARY",
2625
]

lib/gates_qsim.h

+19-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ enum GateKind {
5353
template <typename fp_type>
5454
using GateQSim = Gate<fp_type, GateKind>;
5555

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;
5858

5959
// One-qubit gates:
6060

@@ -76,6 +76,8 @@ struct GateHd {
7676
static constexpr char name[] = "h";
7777
static constexpr unsigned num_qubits = 1;
7878

79+
static constexpr fp_type is2 = static_cast<fp_type>(is2_double);
80+
7981
static GateQSim<fp_type> Create(unsigned time, unsigned q0) {
8082
return CreateGate<GateQSim<fp_type>, GateHd>(
8183
time, q0, {is2, 0, is2, 0, is2, 0, -is2, 0});
@@ -88,6 +90,8 @@ struct GateT {
8890
static constexpr char name[] = "t";
8991
static constexpr unsigned num_qubits = 1;
9092

93+
static constexpr fp_type is2 = static_cast<fp_type>(is2_double);
94+
9195
static GateQSim<fp_type> Create(unsigned time, unsigned q0) {
9296
return CreateGate<GateQSim<fp_type>, GateT>(
9397
time, q0, {1, 0, 0, 0, 0, 0, is2, is2});
@@ -136,6 +140,8 @@ struct GateX2 {
136140
static constexpr char name[] = "x_1_2";
137141
static constexpr unsigned num_qubits = 1;
138142

143+
static constexpr fp_type h = static_cast<fp_type>(h_double);
144+
139145
static GateQSim<fp_type> Create(unsigned time, unsigned q0) {
140146
return CreateGate<GateQSim<fp_type>, GateX2>(
141147
time, q0, {h, h, h, -h, h, -h, h, h});
@@ -148,6 +154,8 @@ struct GateY2 {
148154
static constexpr char name[] = "y_1_2";
149155
static constexpr unsigned num_qubits = 1;
150156

157+
static constexpr fp_type h = static_cast<fp_type>(h_double);
158+
151159
static GateQSim<fp_type> Create(unsigned time, unsigned q0) {
152160
return CreateGate<GateQSim<fp_type>, GateY2>(
153161
time, q0, {h, h, -h, -h, h, h, h, h});
@@ -227,6 +235,10 @@ struct GateHZ2 {
227235
static constexpr char name[] = "hz_1_2";
228236
static constexpr unsigned num_qubits = 1;
229237

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+
230242
static GateQSim<fp_type> Create(unsigned time, unsigned q0) {
231243
return CreateGate<GateQSim<fp_type>, GateHZ2>(
232244
time, q0, {h, h, 0, -is2, is2, 0, h, h});
@@ -319,6 +331,8 @@ struct GateSwap {
319331
static constexpr char name[] = "sw";
320332
static constexpr unsigned num_qubits = 2;
321333

334+
static constexpr fp_type is2 = static_cast<fp_type>(is2_double);
335+
322336
static GateQSim<fp_type> Create(unsigned time, unsigned q0, unsigned q1) {
323337
return CreateGate<GateQSim<fp_type>, GateSwap>(
324338
time, q0, q1, {1, 0, 0, 0, 0, 0, 0, 0,
@@ -343,6 +357,9 @@ struct GateIS {
343357
static constexpr char name[] = "is";
344358
static constexpr unsigned num_qubits = 2;
345359

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+
346363
static GateQSim<fp_type> Create(unsigned time, unsigned q0, unsigned q1) {
347364
return CreateGate<GateQSim<fp_type>, GateIS>(
348365
time, q0, q1, {1, 0, 0, 0, 0, 0, 0, 0,

tests/BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ windows_copts = [
2626
"/Iexternal/gemmlowp",
2727
"/wd4018",
2828
"/wd4577",
29-
"/wd4267", # Silence "narrowing conversion" errors.
3029
"/DNOGDI",
3130
"/UTF_COMPILE_LIBRARY",
3231
]

0 commit comments

Comments
 (0)