@@ -188,8 +188,7 @@ const vector<CplxType> Pennylane::SGate::matrix{
188
188
0 , IMAG };
189
189
190
190
void Pennylane::SGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
191
- CplxType shift = IMAG;
192
- if (inverse == true ) {shift *= -1 ;}
191
+ CplxType shift = (inverse == true ) ? -IMAG : IMAG;
193
192
194
193
for (const size_t & externalIndex : externalIndices) {
195
194
CplxType* shiftedState = state.arr + externalIndex;
@@ -213,8 +212,7 @@ const vector<CplxType> Pennylane::TGate::matrix{
213
212
0 , Pennylane::TGate::shift };
214
213
215
214
void Pennylane::TGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
216
- CplxType shift = Pennylane::TGate::shift;
217
- if (inverse == true ) {shift = conj (Pennylane::TGate::shift);}
215
+ CplxType shift = (inverse == true ) ? conj (Pennylane::TGate::shift) : Pennylane::TGate::shift;
218
216
219
217
for (const size_t & externalIndex : externalIndices) {
220
218
CplxType* shiftedState = state.arr + externalIndex;
@@ -240,9 +238,7 @@ Pennylane::RotationXGate::RotationXGate(double rotationAngle)
240
238
{}
241
239
242
240
void Pennylane::RotationXGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
243
- CplxType js_ = js;
244
-
245
- if (inverse == true ) {js_ *= -1 ;}
241
+ CplxType js_ = (inverse == true ) ? -js : js;
246
242
247
243
for (const size_t & externalIndex : externalIndices) {
248
244
CplxType* shiftedState = state.arr + externalIndex;
@@ -271,9 +267,7 @@ Pennylane::RotationYGate::RotationYGate(double rotationAngle)
271
267
{}
272
268
273
269
void Pennylane::RotationYGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
274
- CplxType s_ = s;
275
-
276
- if (inverse == true ) {s_ *= -1 ;}
270
+ CplxType s_ = (inverse == true ) ? -s : s;
277
271
278
272
for (const size_t & externalIndex : externalIndices) {
279
273
CplxType* shiftedState = state.arr + externalIndex;
@@ -334,9 +328,7 @@ Pennylane::PhaseShiftGate::PhaseShiftGate(double rotationAngle)
334
328
{}
335
329
336
330
void Pennylane::PhaseShiftGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
337
- CplxType s = shift;
338
-
339
- if (inverse == true ){s = conj (shift);}
331
+ CplxType s = (inverse == true ) ? conj (shift) : shift;
340
332
341
333
for (const size_t & externalIndex : externalIndices) {
342
334
CplxType* shiftedState = state.arr + externalIndex;
@@ -482,9 +474,7 @@ Pennylane::CRotationXGate::CRotationXGate(double rotationAngle)
482
474
{}
483
475
484
476
void Pennylane::CRotationXGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
485
- CplxType js_ = js;
486
-
487
- if (inverse == true ) {js_ *= -1 ;}
477
+ CplxType js_ = (inverse == true ) ? -js : js;
488
478
489
479
for (const size_t & externalIndex : externalIndices) {
490
480
CplxType* shiftedState = state.arr + externalIndex;
@@ -515,9 +505,7 @@ Pennylane::CRotationYGate::CRotationYGate(double rotationAngle)
515
505
{}
516
506
517
507
void Pennylane::CRotationYGate::applyKernel (const StateVector& state, const std::vector<size_t >& indices, const std::vector<size_t >& externalIndices, bool inverse) {
518
- CplxType s_ = s;
519
-
520
- if (inverse == true ) {s_ *= -1 ;}
508
+ CplxType s_ = (inverse == true ) ? -s : s;
521
509
522
510
for (const size_t & externalIndex : externalIndices) {
523
511
CplxType* shiftedState = state.arr + externalIndex;
0 commit comments