Maestro 0.2.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QCSimSimulator.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#ifndef _QCSIMSIMULATOR_H
16#define _QCSIMSIMULATOR_H
17
18#ifdef INCLUDED_BY_FACTORY
19
20#include "QCSimState.h"
21
22#define _USE_MATH_DEFINES
23#include <math.h>
24
25namespace Simulators {
26// TODO: Maybe use the pimpl idiom
27// https://en.cppreference.com/w/cpp/language/pimpl to hide the implementation
28// for good but during development this should be good enough
29namespace Private {
30
31class IndividualSimulator;
32
44class QCSimSimulator : public QCSimState {
45 friend class IndividualSimulator;
46
47 public:
48 QCSimSimulator() = default;
49 // allow no copy or assignment
50 QCSimSimulator(const QCSimSimulator &) = delete;
51 QCSimSimulator &operator=(const QCSimSimulator &) = delete;
52
53 // but allow moving
54 QCSimSimulator(QCSimSimulator &&other) = default;
55 QCSimSimulator &operator=(QCSimSimulator &&other) = default;
56
64 void ApplyP(Types::qubit_t qubit, double lambda) override {
65 pgate.SetPhaseShift(lambda);
66 if (GetSimulationType() == SimulationType::kMatrixProductState)
67 mpsSimulator->ApplyGate(pgate, static_cast<unsigned int>(qubit));
68 else if (GetSimulationType() == SimulationType::kStabilizer) {
69 if (std::abs(lambda - M_PI_2) > 1e-10)
70 throw std::runtime_error(
71 "QCSimSimulator::ApplyP: Invalid phase shift "
72 "angle for a Clifford gate.");
73 cliffordSimulator->ApplyS(static_cast<unsigned int>(qubit));
74 } else if (GetSimulationType() == SimulationType::kTensorNetwork)
75 tensorNetwork->AddGate(pgate, static_cast<unsigned int>(qubit));
76 else if (GetSimulationType() == SimulationType::kPauliPropagator)
77 pp->ApplyP(static_cast<unsigned int>(qubit), lambda);
78 else if (GetSimulationType() == SimulationType::kPathIntegral) {
79 QC::Gates::AppliedGate<> agate(pgate.getRawOperatorMatrix(), qubit);
80 pathIntegralSimulator->ApplyGate(agate);
81 }
82 else
83 state->ApplyGate(pgate, static_cast<unsigned int>(qubit));
84 NotifyObservers({qubit});
85 }
86
93 void ApplyX(Types::qubit_t qubit) override {
94 if (GetSimulationType() == SimulationType::kMatrixProductState)
95 mpsSimulator->ApplyGate(xgate, static_cast<unsigned int>(qubit));
96 else if (GetSimulationType() == SimulationType::kStabilizer)
97 cliffordSimulator->ApplyX(static_cast<unsigned int>(qubit));
98 else if (GetSimulationType() == SimulationType::kTensorNetwork)
99 tensorNetwork->AddGate(xgate, static_cast<unsigned int>(qubit));
100 else if (GetSimulationType() == SimulationType::kPauliPropagator)
101 pp->ApplyX(static_cast<unsigned int>(qubit));
102 else if (GetSimulationType() == SimulationType::kPathIntegral) {
103 QC::Gates::AppliedGate<> agate(xgate.getRawOperatorMatrix(), qubit);
104 pathIntegralSimulator->ApplyGate(agate);
105 }
106 else
107 state->ApplyGate(xgate, static_cast<unsigned int>(qubit));
108 NotifyObservers({qubit});
109 }
110
117 void ApplyY(Types::qubit_t qubit) override {
118 if (GetSimulationType() == SimulationType::kMatrixProductState)
119 mpsSimulator->ApplyGate(ygate, static_cast<unsigned int>(qubit));
120 else if (GetSimulationType() == SimulationType::kStabilizer)
121 cliffordSimulator->ApplyY(static_cast<unsigned int>(qubit));
122 else if (GetSimulationType() == SimulationType::kTensorNetwork)
123 tensorNetwork->AddGate(ygate, static_cast<unsigned int>(qubit));
124 else if (GetSimulationType() == SimulationType::kPauliPropagator)
125 pp->ApplyY(static_cast<unsigned int>(qubit));
126 else if (GetSimulationType() == SimulationType::kPathIntegral) {
127 QC::Gates::AppliedGate<> agate(ygate.getRawOperatorMatrix(), qubit);
128 pathIntegralSimulator->ApplyGate(agate);
129 }
130 else
131 state->ApplyGate(ygate, static_cast<unsigned int>(qubit));
132 NotifyObservers({qubit});
133 }
134
141 void ApplyZ(Types::qubit_t qubit) override {
142 if (GetSimulationType() == SimulationType::kMatrixProductState)
143 mpsSimulator->ApplyGate(zgate, static_cast<unsigned int>(qubit));
144 else if (GetSimulationType() == SimulationType::kStabilizer)
145 cliffordSimulator->ApplyZ(static_cast<unsigned int>(qubit));
146 else if (GetSimulationType() == SimulationType::kTensorNetwork)
147 tensorNetwork->AddGate(zgate, static_cast<unsigned int>(qubit));
148 else if (GetSimulationType() == SimulationType::kPauliPropagator)
149 pp->ApplyZ(static_cast<unsigned int>(qubit));
150 else if (GetSimulationType() == SimulationType::kPathIntegral) {
151 QC::Gates::AppliedGate<> agate(zgate.getRawOperatorMatrix(), qubit);
152 pathIntegralSimulator->ApplyGate(agate);
153 }
154 else
155 state->ApplyGate(zgate, static_cast<unsigned int>(qubit));
156 NotifyObservers({qubit});
157 }
158
165 void ApplyH(Types::qubit_t qubit) override {
166 if (GetSimulationType() == SimulationType::kMatrixProductState)
167 mpsSimulator->ApplyGate(h, static_cast<unsigned int>(qubit));
168 else if (GetSimulationType() == SimulationType::kStabilizer)
169 cliffordSimulator->ApplyH(static_cast<unsigned int>(qubit));
170 else if (GetSimulationType() == SimulationType::kTensorNetwork)
171 tensorNetwork->AddGate(h, static_cast<unsigned int>(qubit));
172 else if (GetSimulationType() == SimulationType::kPauliPropagator)
173 pp->ApplyH(static_cast<unsigned int>(qubit));
174 else if (GetSimulationType() == SimulationType::kPathIntegral) {
175 QC::Gates::AppliedGate<> agate(h.getRawOperatorMatrix(), qubit);
176 pathIntegralSimulator->ApplyGate(agate);
177 }
178 else
179 state->ApplyGate(h, static_cast<unsigned int>(qubit));
180 NotifyObservers({qubit});
181 }
182
189 void ApplyS(Types::qubit_t qubit) override {
190 if (GetSimulationType() == SimulationType::kMatrixProductState)
191 mpsSimulator->ApplyGate(sgate, static_cast<unsigned int>(qubit));
192 else if (GetSimulationType() == SimulationType::kStabilizer)
193 cliffordSimulator->ApplyS(static_cast<unsigned int>(qubit));
194 else if (GetSimulationType() == SimulationType::kTensorNetwork)
195 tensorNetwork->AddGate(sgate, static_cast<unsigned int>(qubit));
196 else if (GetSimulationType() == SimulationType::kPauliPropagator)
197 pp->ApplyS(static_cast<unsigned int>(qubit));
198 else if (GetSimulationType() == SimulationType::kPathIntegral) {
199 QC::Gates::AppliedGate<> agate(sgate.getRawOperatorMatrix(), qubit);
200 pathIntegralSimulator->ApplyGate(agate);
201 }
202 else
203 state->ApplyGate(sgate, static_cast<unsigned int>(qubit));
204 NotifyObservers({qubit});
205 }
206
213 void ApplySDG(Types::qubit_t qubit) override {
214 if (GetSimulationType() == SimulationType::kMatrixProductState)
215 mpsSimulator->ApplyGate(sdggate, static_cast<unsigned int>(qubit));
216 else if (GetSimulationType() == SimulationType::kStabilizer)
217 cliffordSimulator->ApplySdg(static_cast<unsigned int>(qubit));
218 else if (GetSimulationType() == SimulationType::kTensorNetwork)
219 tensorNetwork->AddGate(sdggate, static_cast<unsigned int>(qubit));
220 else if (GetSimulationType() == SimulationType::kPauliPropagator)
221 pp->ApplySDG(static_cast<unsigned int>(qubit));
222 else if (GetSimulationType() == SimulationType::kPathIntegral) {
223 QC::Gates::AppliedGate<> agate(sdggate.getRawOperatorMatrix(), qubit);
224 pathIntegralSimulator->ApplyGate(agate);
225 }
226 else
227 state->ApplyGate(sdggate, static_cast<unsigned int>(qubit));
228 NotifyObservers({qubit});
229 }
230
237 void ApplyT(Types::qubit_t qubit) override {
238 if (GetSimulationType() == SimulationType::kMatrixProductState)
239 mpsSimulator->ApplyGate(tgate, static_cast<unsigned int>(qubit));
240 else if (GetSimulationType() == SimulationType::kStabilizer)
241 throw std::runtime_error(
242 "QCSimSimulator::ApplyT: The stabilizer simulator does not support "
243 "non-clifford gates.");
244 else if (GetSimulationType() == SimulationType::kTensorNetwork)
245 tensorNetwork->AddGate(tgate, static_cast<unsigned int>(qubit));
246 else if (GetSimulationType() == SimulationType::kPauliPropagator)
247 pp->ApplyT(static_cast<unsigned int>(qubit));
248 else if (GetSimulationType() == SimulationType::kPathIntegral) {
249 QC::Gates::AppliedGate<> agate(tgate.getRawOperatorMatrix(), qubit);
250 pathIntegralSimulator->ApplyGate(agate);
251 }
252 else
253 state->ApplyGate(tgate, static_cast<unsigned int>(qubit));
254 NotifyObservers({qubit});
255 }
256
263 void ApplyTDG(Types::qubit_t qubit) override {
264 if (GetSimulationType() == SimulationType::kMatrixProductState)
265 mpsSimulator->ApplyGate(tdggate, static_cast<unsigned int>(qubit));
266 else if (GetSimulationType() == SimulationType::kStabilizer)
267 throw std::runtime_error(
268 "QCSimSimulator::ApplyTDG: The stabilizer simulator does not support "
269 "non-clifford gates.");
270 else if (GetSimulationType() == SimulationType::kTensorNetwork)
271 tensorNetwork->AddGate(tdggate, static_cast<unsigned int>(qubit));
272 else if (GetSimulationType() == SimulationType::kPauliPropagator)
273 pp->ApplyTDG(static_cast<unsigned int>(qubit));
274 else if (GetSimulationType() == SimulationType::kPathIntegral) {
275 QC::Gates::AppliedGate<> agate(tdggate.getRawOperatorMatrix(), qubit);
276 pathIntegralSimulator->ApplyGate(agate);
277 }
278 else
279 state->ApplyGate(tdggate, static_cast<unsigned int>(qubit));
280 NotifyObservers({qubit});
281 }
282
289 void ApplySx(Types::qubit_t qubit) override {
290 if (GetSimulationType() == SimulationType::kMatrixProductState)
291 mpsSimulator->ApplyGate(sxgate, static_cast<unsigned int>(qubit));
292 else if (GetSimulationType() == SimulationType::kStabilizer)
293 cliffordSimulator->ApplySx(static_cast<unsigned int>(qubit));
294 else if (GetSimulationType() == SimulationType::kTensorNetwork)
295 tensorNetwork->AddGate(sxgate, static_cast<unsigned int>(qubit));
296 else if (GetSimulationType() == SimulationType::kPauliPropagator)
297 pp->ApplySX(static_cast<unsigned int>(qubit));
298 else if (GetSimulationType() == SimulationType::kPathIntegral) {
299 QC::Gates::AppliedGate<> agate(sxgate.getRawOperatorMatrix(), qubit);
300 pathIntegralSimulator->ApplyGate(agate);
301 }
302 else
303 state->ApplyGate(sxgate, static_cast<unsigned int>(qubit));
304 NotifyObservers({qubit});
305 }
306
313 void ApplySxDAG(Types::qubit_t qubit) override {
314 if (GetSimulationType() == SimulationType::kMatrixProductState)
315 mpsSimulator->ApplyGate(sxdaggate, static_cast<unsigned int>(qubit));
316 else if (GetSimulationType() == SimulationType::kStabilizer)
317 cliffordSimulator->ApplySxDag(static_cast<unsigned int>(qubit));
318 else if (GetSimulationType() == SimulationType::kTensorNetwork)
319 tensorNetwork->AddGate(sxdaggate, static_cast<unsigned int>(qubit));
320 else if (GetSimulationType() == SimulationType::kPauliPropagator)
321 pp->ApplySXDG(static_cast<unsigned int>(qubit));
322 else if (GetSimulationType() == SimulationType::kPathIntegral) {
323 QC::Gates::AppliedGate<> agate(sxdaggate.getRawOperatorMatrix(), qubit);
324 pathIntegralSimulator->ApplyGate(agate);
325 }
326 else
327 state->ApplyGate(sxdaggate, static_cast<unsigned int>(qubit));
328 NotifyObservers({qubit});
329 }
330
337 void ApplyK(Types::qubit_t qubit) override {
338 if (GetSimulationType() == SimulationType::kMatrixProductState)
339 mpsSimulator->ApplyGate(k, static_cast<unsigned int>(qubit));
340 else if (GetSimulationType() == SimulationType::kStabilizer)
341 cliffordSimulator->ApplyK(static_cast<unsigned int>(qubit));
342 else if (GetSimulationType() == SimulationType::kTensorNetwork)
343 tensorNetwork->AddGate(k, static_cast<unsigned int>(qubit));
344 else if (GetSimulationType() == SimulationType::kPauliPropagator)
345 pp->ApplyK(static_cast<unsigned int>(qubit));
346 else if (GetSimulationType() == SimulationType::kPathIntegral) {
347 QC::Gates::AppliedGate<> agate(k.getRawOperatorMatrix(), qubit);
348 pathIntegralSimulator->ApplyGate(agate);
349 }
350 else
351 state->ApplyGate(k, static_cast<unsigned int>(qubit));
352 NotifyObservers({qubit});
353 }
354
362 void ApplyRx(Types::qubit_t qubit, double theta) override {
363 rxgate.SetTheta(theta);
364 if (GetSimulationType() == SimulationType::kMatrixProductState)
365 mpsSimulator->ApplyGate(rxgate, static_cast<unsigned int>(qubit));
366 else if (GetSimulationType() == SimulationType::kStabilizer)
367 throw std::runtime_error(
368 "QCSimSimulator::ApplyRx: The stabilizer "
369 "simulator does not support the Rx gate.");
370 else if (GetSimulationType() == SimulationType::kTensorNetwork)
371 tensorNetwork->AddGate(rxgate, static_cast<unsigned int>(qubit));
372 else if (GetSimulationType() == SimulationType::kPauliPropagator)
373 pp->ApplyRX(static_cast<unsigned int>(qubit), theta);
374 else if (GetSimulationType() == SimulationType::kPathIntegral) {
375 QC::Gates::AppliedGate<> agate(rxgate.getRawOperatorMatrix(), qubit);
376 pathIntegralSimulator->ApplyGate(agate);
377 }
378 else
379 state->ApplyGate(rxgate, static_cast<unsigned int>(qubit));
380 NotifyObservers({qubit});
381 }
382
390 void ApplyRy(Types::qubit_t qubit, double theta) override {
391 rygate.SetTheta(theta);
392 if (GetSimulationType() == SimulationType::kMatrixProductState)
393 mpsSimulator->ApplyGate(rygate, static_cast<unsigned int>(qubit));
394 else if (GetSimulationType() == SimulationType::kStabilizer)
395 throw std::runtime_error(
396 "QCSimSimulator::ApplyRy: The stabilizer "
397 "simulator does not support the Ry gate.");
398 else if (GetSimulationType() == SimulationType::kTensorNetwork)
399 tensorNetwork->AddGate(rygate, static_cast<unsigned int>(qubit));
400 else if (GetSimulationType() == SimulationType::kPauliPropagator)
401 pp->ApplyRY(static_cast<unsigned int>(qubit), theta);
402 else if (GetSimulationType() == SimulationType::kPathIntegral) {
403 QC::Gates::AppliedGate<> agate(rygate.getRawOperatorMatrix(), qubit);
404 pathIntegralSimulator->ApplyGate(agate);
405 }
406 else
407 state->ApplyGate(rygate, static_cast<unsigned int>(qubit));
408 NotifyObservers({qubit});
409 }
410
418 void ApplyRz(Types::qubit_t qubit, double theta) override {
419 rzgate.SetTheta(theta);
420 if (GetSimulationType() == SimulationType::kMatrixProductState)
421 mpsSimulator->ApplyGate(rzgate, static_cast<unsigned int>(qubit));
422 else if (GetSimulationType() == SimulationType::kStabilizer)
423 throw std::runtime_error(
424 "QCSimSimulator::ApplyRz: The stabilizer "
425 "simulator does not support the Rz gate.");
426 else if (GetSimulationType() == SimulationType::kTensorNetwork)
427 tensorNetwork->AddGate(rzgate, static_cast<unsigned int>(qubit));
428 else if (GetSimulationType() == SimulationType::kPauliPropagator)
429 pp->ApplyRZ(static_cast<unsigned int>(qubit), theta);
430 else if (GetSimulationType() == SimulationType::kPathIntegral) {
431 QC::Gates::AppliedGate<> agate(rzgate.getRawOperatorMatrix(), qubit);
432 pathIntegralSimulator->ApplyGate(agate);
433 }
434 else
435 state->ApplyGate(rzgate, static_cast<unsigned int>(qubit));
436 NotifyObservers({qubit});
437 }
438
449 void ApplyU(Types::qubit_t qubit, double theta, double phi, double lambda,
450 double gamma) override {
451 ugate.SetParams(theta, phi, lambda, gamma);
452 if (GetSimulationType() == SimulationType::kMatrixProductState)
453 mpsSimulator->ApplyGate(ugate, static_cast<unsigned int>(qubit));
454 else if (GetSimulationType() == SimulationType::kStabilizer)
455 throw std::runtime_error(
456 "QCSimSimulator::ApplyU: The stabilizer "
457 "simulator does not support the U gate.");
458 else if (GetSimulationType() == SimulationType::kTensorNetwork)
459 tensorNetwork->AddGate(ugate, static_cast<unsigned int>(qubit));
460 else if (GetSimulationType() == SimulationType::kPauliPropagator)
461 pp->ApplyU(static_cast<unsigned int>(qubit), theta, phi, lambda, gamma);
462 else if (GetSimulationType() == SimulationType::kPathIntegral) {
463 QC::Gates::AppliedGate<> agate(ugate.getRawOperatorMatrix(), qubit);
464 pathIntegralSimulator->ApplyGate(agate);
465 }
466 else
467 state->ApplyGate(ugate, static_cast<unsigned int>(qubit));
468 NotifyObservers({qubit});
469 }
470
478 void ApplyCX(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit) override {
479 if (GetSimulationType() == SimulationType::kMatrixProductState)
480 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(tgt_qubit),
481 static_cast<unsigned int>(ctrl_qubit));
482 else if (GetSimulationType() == SimulationType::kStabilizer)
483 cliffordSimulator->ApplyCX(static_cast<unsigned int>(tgt_qubit),
484 static_cast<unsigned int>(ctrl_qubit));
485 else if (GetSimulationType() == SimulationType::kTensorNetwork)
486 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(ctrl_qubit),
487 static_cast<unsigned int>(tgt_qubit));
488 else if (GetSimulationType() == SimulationType::kPauliPropagator)
489 pp->ApplyCX(static_cast<unsigned int>(ctrl_qubit),
490 static_cast<unsigned int>(tgt_qubit));
491 else if (GetSimulationType() == SimulationType::kPathIntegral) {
492 QC::Gates::AppliedGate<> agate(cxgate.getRawOperatorMatrix(),
493 tgt_qubit, ctrl_qubit);
494 pathIntegralSimulator->ApplyGate(agate);
495 }
496 else
497 state->ApplyGate(cxgate, static_cast<unsigned int>(tgt_qubit),
498 static_cast<unsigned int>(ctrl_qubit));
499 NotifyObservers({tgt_qubit, ctrl_qubit});
500 }
501
509 void ApplyCY(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit) override {
510 if (GetSimulationType() == SimulationType::kMatrixProductState)
511 mpsSimulator->ApplyGate(cygate, static_cast<unsigned int>(tgt_qubit),
512 static_cast<unsigned int>(ctrl_qubit));
513 else if (GetSimulationType() == SimulationType::kStabilizer)
514 cliffordSimulator->ApplyCY(static_cast<unsigned int>(tgt_qubit),
515 static_cast<unsigned int>(ctrl_qubit));
516 else if (GetSimulationType() == SimulationType::kTensorNetwork)
517 tensorNetwork->AddGate(cygate, static_cast<unsigned int>(ctrl_qubit),
518 static_cast<unsigned int>(tgt_qubit));
519 else if (GetSimulationType() == SimulationType::kPauliPropagator)
520 pp->ApplyCY(static_cast<unsigned int>(ctrl_qubit),
521 static_cast<unsigned int>(tgt_qubit));
522 else if (GetSimulationType() == SimulationType::kPathIntegral) {
523 QC::Gates::AppliedGate<> agate(cygate.getRawOperatorMatrix(),
524 tgt_qubit, ctrl_qubit);
525 pathIntegralSimulator->ApplyGate(agate);
526 }
527 else
528 state->ApplyGate(cygate, static_cast<unsigned int>(tgt_qubit),
529 static_cast<unsigned int>(ctrl_qubit));
530 NotifyObservers({tgt_qubit, ctrl_qubit});
531 }
532
540 void ApplyCZ(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit) override {
541 if (GetSimulationType() == SimulationType::kMatrixProductState)
542 mpsSimulator->ApplyGate(czgate, static_cast<unsigned int>(tgt_qubit),
543 static_cast<unsigned int>(ctrl_qubit));
544 else if (GetSimulationType() == SimulationType::kStabilizer)
545 cliffordSimulator->ApplyCZ(static_cast<unsigned int>(tgt_qubit),
546 static_cast<unsigned int>(ctrl_qubit));
547 else if (GetSimulationType() == SimulationType::kTensorNetwork)
548 tensorNetwork->AddGate(czgate, static_cast<unsigned int>(ctrl_qubit),
549 static_cast<unsigned int>(tgt_qubit));
550 else if (GetSimulationType() == SimulationType::kPauliPropagator)
551 pp->ApplyCZ(static_cast<unsigned int>(ctrl_qubit),
552 static_cast<unsigned int>(tgt_qubit));
553 else if (GetSimulationType() == SimulationType::kPathIntegral) {
554 QC::Gates::AppliedGate<> agate(czgate.getRawOperatorMatrix(),
555 tgt_qubit, ctrl_qubit);
556 pathIntegralSimulator->ApplyGate(agate);
557 }
558 else
559 state->ApplyGate(czgate, static_cast<unsigned int>(tgt_qubit),
560 static_cast<unsigned int>(ctrl_qubit));
561 NotifyObservers({tgt_qubit, ctrl_qubit});
562 }
563
572 void ApplyCP(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit,
573 double lambda) override {
574 cpgate.SetPhaseShift(lambda);
575 if (GetSimulationType() == SimulationType::kMatrixProductState)
576 mpsSimulator->ApplyGate(cpgate, static_cast<unsigned int>(tgt_qubit),
577 static_cast<unsigned int>(ctrl_qubit));
578 else if (GetSimulationType() == SimulationType::kStabilizer)
579 throw std::runtime_error(
580 "QCSimSimulator::ApplyCP: The stabilizer "
581 "simulator does not support the CP gate.");
582 else if (GetSimulationType() == SimulationType::kTensorNetwork)
583 tensorNetwork->AddGate(cpgate, static_cast<unsigned int>(ctrl_qubit),
584 static_cast<unsigned int>(tgt_qubit));
585 else if (GetSimulationType() == SimulationType::kPauliPropagator)
586 pp->ApplyCP(static_cast<unsigned int>(ctrl_qubit),
587 static_cast<unsigned int>(tgt_qubit), lambda);
588 else if (GetSimulationType() == SimulationType::kPathIntegral) {
589 QC::Gates::AppliedGate<> agate(cpgate.getRawOperatorMatrix(),
590 tgt_qubit, ctrl_qubit);
591 pathIntegralSimulator->ApplyGate(agate);
592 }
593 else
594 state->ApplyGate(cpgate, static_cast<unsigned int>(tgt_qubit),
595 static_cast<unsigned int>(ctrl_qubit));
596 NotifyObservers({tgt_qubit, ctrl_qubit});
597 }
598
607 void ApplyCRx(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit,
608 double theta) override {
609 crxgate.SetTheta(theta);
610 if (GetSimulationType() == SimulationType::kMatrixProductState)
611 mpsSimulator->ApplyGate(crxgate, static_cast<unsigned int>(tgt_qubit),
612 static_cast<unsigned int>(ctrl_qubit));
613 else if (GetSimulationType() == SimulationType::kStabilizer)
614 throw std::runtime_error(
615 "QCSimSimulator::ApplyCRx: The stabilizer "
616 "simulator does not support the CRx gate.");
617 else if (GetSimulationType() == SimulationType::kTensorNetwork)
618 tensorNetwork->AddGate(crxgate, static_cast<unsigned int>(ctrl_qubit),
619 static_cast<unsigned int>(tgt_qubit));
620 else if (GetSimulationType() == SimulationType::kPauliPropagator)
621 pp->ApplyCRX(static_cast<unsigned int>(ctrl_qubit),
622 static_cast<unsigned int>(tgt_qubit), theta);
623 else if (GetSimulationType() == SimulationType::kPathIntegral) {
624 QC::Gates::AppliedGate<> agate(crxgate.getRawOperatorMatrix(),
625 tgt_qubit, ctrl_qubit);
626 pathIntegralSimulator->ApplyGate(agate);
627 }
628 else
629 state->ApplyGate(crxgate, static_cast<unsigned int>(tgt_qubit),
630 static_cast<unsigned int>(ctrl_qubit));
631 NotifyObservers({tgt_qubit, ctrl_qubit});
632 }
633
642 void ApplyCRy(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit,
643 double theta) override {
644 crygate.SetTheta(theta);
645 if (GetSimulationType() == SimulationType::kMatrixProductState)
646 mpsSimulator->ApplyGate(crygate, static_cast<unsigned int>(tgt_qubit),
647 static_cast<unsigned int>(ctrl_qubit));
648 else if (GetSimulationType() == SimulationType::kStabilizer)
649 throw std::runtime_error(
650 "QCSimSimulator::ApplyCRy: The stabilizer "
651 "simulator does not support the CRy gate.");
652 else if (GetSimulationType() == SimulationType::kTensorNetwork)
653 tensorNetwork->AddGate(crygate, static_cast<unsigned int>(ctrl_qubit),
654 static_cast<unsigned int>(tgt_qubit));
655 else if (GetSimulationType() == SimulationType::kPauliPropagator)
656 pp->ApplyCRY(static_cast<unsigned int>(ctrl_qubit),
657 static_cast<unsigned int>(tgt_qubit), theta);
658 else if (GetSimulationType() == SimulationType::kPathIntegral) {
659 QC::Gates::AppliedGate<> agate(crygate.getRawOperatorMatrix(),
660 tgt_qubit, ctrl_qubit);
661 pathIntegralSimulator->ApplyGate(agate);
662 }
663 else
664 state->ApplyGate(crygate, static_cast<unsigned int>(tgt_qubit),
665 static_cast<unsigned int>(ctrl_qubit));
666 NotifyObservers({tgt_qubit, ctrl_qubit});
667 }
668
677 void ApplyCRz(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit,
678 double theta) override {
679 crzgate.SetTheta(theta);
680 if (GetSimulationType() == SimulationType::kMatrixProductState)
681 mpsSimulator->ApplyGate(crzgate, static_cast<unsigned int>(tgt_qubit),
682 static_cast<unsigned int>(ctrl_qubit));
683 else if (GetSimulationType() == SimulationType::kStabilizer)
684 throw std::runtime_error(
685 "QCSimSimulator::ApplyCRz: The stabilizer "
686 "simulator does not support the CRz gate.");
687 else if (GetSimulationType() == SimulationType::kTensorNetwork)
688 tensorNetwork->AddGate(crzgate, static_cast<unsigned int>(ctrl_qubit),
689 static_cast<unsigned int>(tgt_qubit));
690 else if (GetSimulationType() == SimulationType::kPauliPropagator)
691 pp->ApplyCRZ(static_cast<unsigned int>(ctrl_qubit),
692 static_cast<unsigned int>(tgt_qubit), theta);
693 else if (GetSimulationType() == SimulationType::kPathIntegral) {
694 QC::Gates::AppliedGate<> agate(crzgate.getRawOperatorMatrix(), tgt_qubit,
695 ctrl_qubit);
696 pathIntegralSimulator->ApplyGate(agate);
697 }
698 else
699 state->ApplyGate(crzgate, static_cast<unsigned int>(tgt_qubit),
700 static_cast<unsigned int>(ctrl_qubit));
701 NotifyObservers({tgt_qubit, ctrl_qubit});
702 }
703
711 void ApplyCH(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit) override {
712 if (GetSimulationType() == SimulationType::kMatrixProductState)
713 mpsSimulator->ApplyGate(ch, static_cast<unsigned int>(tgt_qubit),
714 static_cast<unsigned int>(ctrl_qubit));
715 else if (GetSimulationType() == SimulationType::kStabilizer)
716 throw std::runtime_error(
717 "QCSimSimulator::ApplyCH: The stabilizer "
718 "simulator does not support the CH gate.");
719 else if (GetSimulationType() == SimulationType::kTensorNetwork)
720 tensorNetwork->AddGate(ch, static_cast<unsigned int>(ctrl_qubit),
721 static_cast<unsigned int>(tgt_qubit));
722 else if (GetSimulationType() == SimulationType::kPauliPropagator)
723 pp->ApplyCH(static_cast<unsigned int>(ctrl_qubit),
724 static_cast<unsigned int>(tgt_qubit));
725 else if (GetSimulationType() == SimulationType::kPathIntegral) {
726 QC::Gates::AppliedGate<> agate(ch.getRawOperatorMatrix(), tgt_qubit,
727 ctrl_qubit);
728 pathIntegralSimulator->ApplyGate(agate);
729 }
730 else
731 state->ApplyGate(ch, static_cast<unsigned int>(tgt_qubit),
732 static_cast<unsigned int>(ctrl_qubit));
733 NotifyObservers({tgt_qubit, ctrl_qubit});
734 }
735
743 void ApplyCSx(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit) override {
744 if (GetSimulationType() == SimulationType::kMatrixProductState)
745 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(tgt_qubit),
746 static_cast<unsigned int>(ctrl_qubit));
747 else if (GetSimulationType() == SimulationType::kStabilizer)
748 throw std::runtime_error(
749 "QCSimSimulator::ApplyCSx: The stabilizer "
750 "simulator does not support the CSx gate.");
751 else if (GetSimulationType() == SimulationType::kTensorNetwork)
752 tensorNetwork->AddGate(csx, static_cast<unsigned int>(ctrl_qubit),
753 static_cast<unsigned int>(tgt_qubit));
754 else if (GetSimulationType() == SimulationType::kPauliPropagator)
755 pp->ApplyCSX(static_cast<unsigned int>(ctrl_qubit),
756 static_cast<unsigned int>(tgt_qubit));
757 else if (GetSimulationType() == SimulationType::kPathIntegral) {
758 QC::Gates::AppliedGate<> agate(csx.getRawOperatorMatrix(), tgt_qubit,
759 ctrl_qubit);
760 pathIntegralSimulator->ApplyGate(agate);
761 }
762 else
763 state->ApplyGate(csx, static_cast<unsigned int>(tgt_qubit),
764 static_cast<unsigned int>(ctrl_qubit));
765 NotifyObservers({tgt_qubit, ctrl_qubit});
766 }
767
775 void ApplyCSxDAG(Types::qubit_t ctrl_qubit,
776 Types::qubit_t tgt_qubit) override {
777 if (GetSimulationType() == SimulationType::kMatrixProductState)
778 mpsSimulator->ApplyGate(csxdag, static_cast<unsigned int>(tgt_qubit),
779 static_cast<unsigned int>(ctrl_qubit));
780 else if (GetSimulationType() == SimulationType::kStabilizer)
781 throw std::runtime_error(
782 "QCSimSimulator::ApplyCSxDAG: The stabilizer "
783 "simulator does not support the CSxDag gate.");
784 else if (GetSimulationType() == SimulationType::kTensorNetwork)
785 tensorNetwork->AddGate(csxdag, static_cast<unsigned int>(ctrl_qubit),
786 static_cast<unsigned int>(tgt_qubit));
787 else if (GetSimulationType() == SimulationType::kPauliPropagator)
788 pp->ApplyCSXDAG(static_cast<unsigned int>(ctrl_qubit),
789 static_cast<unsigned int>(tgt_qubit));
790 else if (GetSimulationType() == SimulationType::kPathIntegral) {
791 QC::Gates::AppliedGate<> agate(csxdag.getRawOperatorMatrix(), tgt_qubit,
792 ctrl_qubit);
793 pathIntegralSimulator->ApplyGate(agate);
794 }
795 else
796 state->ApplyGate(csxdag, static_cast<unsigned int>(tgt_qubit),
797 static_cast<unsigned int>(ctrl_qubit));
798 NotifyObservers({tgt_qubit, ctrl_qubit});
799 }
800
808 void ApplySwap(Types::qubit_t qubit0, Types::qubit_t qubit1) override {
809 if (GetSimulationType() == SimulationType::kMatrixProductState)
810 mpsSimulator->ApplyGate(swapgate, static_cast<unsigned int>(qubit1),
811 static_cast<unsigned int>(qubit0));
812 else if (GetSimulationType() == SimulationType::kStabilizer)
813 cliffordSimulator->ApplySwap(static_cast<unsigned int>(qubit1),
814 static_cast<unsigned int>(qubit0));
815 else if (GetSimulationType() == SimulationType::kTensorNetwork)
816 tensorNetwork->AddGate(swapgate, static_cast<unsigned int>(qubit0),
817 static_cast<unsigned int>(qubit1));
818 else if (GetSimulationType() == SimulationType::kPauliPropagator)
819 pp->ApplySWAP(static_cast<unsigned int>(qubit0),
820 static_cast<unsigned int>(qubit1));
821 else if (GetSimulationType() == SimulationType::kPathIntegral) {
822 QC::Gates::AppliedGate<> agate(swapgate.getRawOperatorMatrix(), qubit1,
823 qubit0);
824 pathIntegralSimulator->ApplyGate(agate);
825 }
826 else
827 state->ApplyGate(swapgate, static_cast<unsigned int>(qubit1),
828 static_cast<unsigned int>(qubit0));
829 NotifyObservers({qubit1, qubit0});
830 }
831
840 void ApplyCCX(Types::qubit_t qubit0, Types::qubit_t qubit1,
841 Types::qubit_t qubit2) override {
842 if (GetSimulationType() == SimulationType::kMatrixProductState) {
843 const size_t q1 = qubit0; // control 1
844 const size_t q2 = qubit1; // control 2
845 const size_t q3 = qubit2; // target
846
847 // Sleator-Weinfurter decomposition
848 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(q3),
849 static_cast<unsigned int>(q2));
850 NotifyObservers({qubit1, qubit2});
851
852 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
853 static_cast<unsigned int>(q1));
854 NotifyObservers({qubit0, qubit1});
855
856 mpsSimulator->ApplyGate(csxdag, static_cast<unsigned int>(q3),
857 static_cast<unsigned int>(q2));
858 NotifyObservers({qubit1, qubit2});
859
860 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
861 static_cast<unsigned int>(q1));
862 NotifyObservers({qubit0, qubit1});
863
864 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(q3),
865 static_cast<unsigned int>(q1));
866 NotifyObservers({qubit0, qubit2});
867 } else if (GetSimulationType() == SimulationType::kStabilizer)
868 throw std::runtime_error(
869 "QCSimSimulator::ApplyCCX: The stabilizer "
870 "simulator does not support the CCX gate.");
871 else if (GetSimulationType() == SimulationType::kTensorNetwork) {
872 const size_t q1 = qubit0; // control 1
873 const size_t q2 = qubit1; // control 2
874 const size_t q3 = qubit2; // target
875
876 // Sleator-Weinfurter decomposition
877 tensorNetwork->AddGate(csx, static_cast<unsigned int>(q2),
878 static_cast<unsigned int>(q3));
879 NotifyObservers({qubit1, qubit2});
880
881 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q1),
882 static_cast<unsigned int>(q2));
883 NotifyObservers({qubit0, qubit1});
884
885 tensorNetwork->AddGate(csxdag, static_cast<unsigned int>(q2),
886 static_cast<unsigned int>(q3));
887 NotifyObservers({qubit1, qubit2});
888
889 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q1),
890 static_cast<unsigned int>(q2));
891 NotifyObservers({qubit0, qubit1});
892
893 tensorNetwork->AddGate(csx, static_cast<unsigned int>(q1),
894 static_cast<unsigned int>(q3));
895 NotifyObservers({qubit0, qubit2});
896 } else if (GetSimulationType() == SimulationType::kPauliPropagator) {
897 pp->ApplyCCX(static_cast<unsigned int>(qubit0),
898 static_cast<unsigned int>(qubit1),
899 static_cast<unsigned int>(qubit2));
900 NotifyObservers({qubit2, qubit1, qubit0});
901 } else if (GetSimulationType() == SimulationType::kPathIntegral) {
902 QC::Gates::AppliedGate<> agate(ccxgate.getRawOperatorMatrix(), qubit2,
903 qubit1, qubit0);
904 pathIntegralSimulator->ApplyGate(agate);
905 NotifyObservers({qubit2, qubit1, qubit0});
906 } else {
907 state->ApplyGate(ccxgate, static_cast<unsigned int>(qubit2),
908 static_cast<unsigned int>(qubit1),
909 static_cast<unsigned int>(qubit0));
910 NotifyObservers({qubit2, qubit1, qubit0});
911 }
912 }
913
922 void ApplyCSwap(Types::qubit_t ctrl_qubit, Types::qubit_t qubit0,
923 Types::qubit_t qubit1) override {
924 if (GetSimulationType() == SimulationType::kMatrixProductState) {
925 const size_t q1 = ctrl_qubit; // control
926 const size_t q2 = qubit0;
927 const size_t q3 = qubit1;
928
929 // TODO: find a better decomposition
930 // this one I've got with the qiskit transpiler
931 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
932 static_cast<unsigned int>(q3));
933 NotifyObservers({qubit1, qubit0});
934
935 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(q3),
936 static_cast<unsigned int>(q2));
937 NotifyObservers({qubit0, qubit1});
938
939 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
940 static_cast<unsigned int>(q1));
941 NotifyObservers({ctrl_qubit, qubit0});
942
943 pgate.SetPhaseShift(M_PI);
944 mpsSimulator->ApplyGate(pgate, static_cast<unsigned int>(q3));
945 NotifyObservers({qubit1});
946 pgate.SetPhaseShift(-M_PI_2);
947 mpsSimulator->ApplyGate(pgate, static_cast<unsigned int>(q2));
948 NotifyObservers({qubit0});
949
950 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(q3),
951 static_cast<unsigned int>(q2));
952 NotifyObservers({qubit0, qubit1});
953
954 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
955 static_cast<unsigned int>(q1));
956 NotifyObservers({ctrl_qubit, qubit0});
957
958 pgate.SetPhaseShift(M_PI);
959 mpsSimulator->ApplyGate(pgate, static_cast<unsigned int>(q3));
960 NotifyObservers({qubit1});
961
962 mpsSimulator->ApplyGate(csx, static_cast<unsigned int>(q3),
963 static_cast<unsigned int>(q1));
964 NotifyObservers({ctrl_qubit, qubit1});
965
966 mpsSimulator->ApplyGate(cxgate, static_cast<unsigned int>(q2),
967 static_cast<unsigned int>(q3));
968 NotifyObservers({qubit1, qubit0});
969 } else if (GetSimulationType() == SimulationType::kStabilizer)
970 throw std::runtime_error(
971 "QCSimSimulator::ApplyCSwap: The stabilizer "
972 "simulator does not support the CSwap gate.");
973 else if (GetSimulationType() == SimulationType::kTensorNetwork) {
974 const size_t q1 = ctrl_qubit; // control
975 const size_t q2 = qubit0;
976 const size_t q3 = qubit1;
977
978 // TODO: find a better decomposition
979 // this one I've got with the qiskit transpiler
980 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q3),
981 static_cast<unsigned int>(q2));
982 NotifyObservers({qubit1, qubit0});
983
984 tensorNetwork->AddGate(csx, static_cast<unsigned int>(q2),
985 static_cast<unsigned int>(q3));
986 NotifyObservers({qubit0, qubit1});
987
988 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q1),
989 static_cast<unsigned int>(q2));
990 NotifyObservers({ctrl_qubit, qubit0});
991
992 pgate.SetPhaseShift(M_PI);
993 tensorNetwork->AddGate(pgate, static_cast<unsigned int>(q3));
994 NotifyObservers({qubit1});
995 pgate.SetPhaseShift(-M_PI_2);
996 tensorNetwork->AddGate(pgate, static_cast<unsigned int>(q2));
997 NotifyObservers({qubit0});
998
999 tensorNetwork->AddGate(csx, static_cast<unsigned int>(q2),
1000 static_cast<unsigned int>(q3));
1001 NotifyObservers({qubit0, qubit1});
1002
1003 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q1),
1004 static_cast<unsigned int>(q2));
1005 NotifyObservers({ctrl_qubit, qubit0});
1006
1007 pgate.SetPhaseShift(M_PI);
1008 tensorNetwork->AddGate(pgate, static_cast<unsigned int>(q3));
1009 NotifyObservers({qubit1});
1010
1011 tensorNetwork->AddGate(csx, static_cast<unsigned int>(q1),
1012 static_cast<unsigned int>(q3));
1013 NotifyObservers({ctrl_qubit, qubit1});
1014
1015 tensorNetwork->AddGate(cxgate, static_cast<unsigned int>(q3),
1016 static_cast<unsigned int>(q2));
1017 NotifyObservers({qubit1, qubit0});
1018 } else if (GetSimulationType() == SimulationType::kPauliPropagator) {
1019 pp->ApplyCSwap(static_cast<unsigned int>(ctrl_qubit),
1020 static_cast<unsigned int>(qubit0),
1021 static_cast<unsigned int>(qubit1));
1022 NotifyObservers({qubit1, qubit0, ctrl_qubit});
1023 } else if (GetSimulationType() == SimulationType::kPathIntegral) {
1024 QC::Gates::AppliedGate<> agate(cswapgate.getRawOperatorMatrix(),
1025 qubit1, qubit0, ctrl_qubit);
1026 pathIntegralSimulator->ApplyGate(agate);
1027 NotifyObservers({qubit1, qubit0, ctrl_qubit});
1028 } else {
1029 state->ApplyGate(cswapgate, static_cast<unsigned int>(qubit1),
1030 static_cast<unsigned int>(qubit0),
1031 static_cast<unsigned int>(ctrl_qubit));
1032 NotifyObservers({qubit1, qubit0, ctrl_qubit});
1033 }
1034 }
1035
1047 void ApplyCU(Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit,
1048 double theta, double phi, double lambda, double gamma) override {
1049 cugate.SetParams(theta, phi, lambda, gamma);
1050 if (GetSimulationType() == SimulationType::kMatrixProductState)
1051 mpsSimulator->ApplyGate(cugate, static_cast<unsigned int>(tgt_qubit),
1052 static_cast<unsigned int>(ctrl_qubit));
1053 else if (GetSimulationType() == SimulationType::kStabilizer)
1054 throw std::runtime_error(
1055 "QCSimSimulator::ApplyCU: The stabilizer "
1056 "simulator does not support the CU gate.");
1057 else if (GetSimulationType() == SimulationType::kTensorNetwork)
1058 tensorNetwork->AddGate(cugate, static_cast<unsigned int>(ctrl_qubit),
1059 static_cast<unsigned int>(tgt_qubit));
1060 else if (GetSimulationType() == SimulationType::kPauliPropagator)
1061 pp->ApplyCU(static_cast<unsigned int>(ctrl_qubit),
1062 static_cast<unsigned int>(tgt_qubit), theta, phi, lambda,
1063 gamma);
1064 else if (GetSimulationType() == SimulationType::kPathIntegral) {
1065 QC::Gates::AppliedGate<> agate(cugate.getRawOperatorMatrix(), tgt_qubit,
1066 ctrl_qubit);
1067 pathIntegralSimulator->ApplyGate(agate);
1068 }
1069 else
1070 state->ApplyGate(cugate, static_cast<unsigned int>(tgt_qubit),
1071 static_cast<unsigned int>(ctrl_qubit));
1072 NotifyObservers({tgt_qubit, ctrl_qubit});
1073 }
1074
1082 void ApplyNop() override {
1083 // do nothing
1084 }
1085
1096 std::unique_ptr<ISimulator> Clone() override {
1097 auto cloned = std::make_unique<QCSimSimulator>();
1098
1099 cloned->simulationType = simulationType;
1100 cloned->nrQubits = nrQubits;
1101
1102 cloned->limitSize = limitSize;
1103 cloned->limitEntanglement = limitEntanglement;
1104 cloned->chi = chi;
1105 cloned->singularValueThreshold = singularValueThreshold;
1106
1107 cloned->enableMultithreading = enableMultithreading;
1108 cloned->useMPSMeasureNoCollapse = useMPSMeasureNoCollapse;
1109
1110 cloned->lookaheadDepth = lookaheadDepth;
1111 cloned->useOptimalMeetingPosition = useOptimalMeetingPosition;
1112 cloned->upcomingGates = upcomingGates;
1113 cloned->upcomingGateIndex = upcomingGateIndex;
1114 cloned->growthFactorGate = growthFactorGate;
1115 cloned->growthFactorSwap = growthFactorSwap;
1116
1117 if (state) cloned->state = state->Clone();
1118
1119 if (mpsSimulator) {
1120 cloned->mpsSimulator = mpsSimulator->Clone();
1121
1122 if (limitEntanglement && singularValueThreshold > 0.)
1123 cloned->mpsSimulator->setLimitEntanglement(singularValueThreshold);
1124 if (limitSize && chi > 0)
1125 cloned->mpsSimulator->setLimitBondDimension(chi);
1126
1127 cloned->dummySim = dummySim ? dummySim->Clone() : nullptr;
1128
1129 cloned->gateCounterObserver =
1130 std::make_shared<GateCounterObserver>(upcomingGateIndex);
1131 cloned->RegisterObserver(cloned->gateCounterObserver);
1132 }
1133
1134 if (cliffordSimulator)
1135 cloned->cliffordSimulator = cliffordSimulator->Clone();
1136
1137 if (tensorNetwork) cloned->tensorNetwork = tensorNetwork->Clone();
1138
1139 if (pp) cloned->pp = pp->Clone();
1140
1141 if (pathIntegralSimulator)
1142 cloned->pathIntegralSimulator = pathIntegralSimulator->Clone();
1143
1144 return cloned;
1145 }
1146
1147 private:
1148 QC::Gates::PhaseShiftGate<> pgate;
1149 QC::Gates::PauliXGate<> xgate;
1150 QC::Gates::PauliYGate<> ygate;
1151 QC::Gates::PauliZGate<> zgate;
1152 QC::Gates::HadamardGate<> h;
1153 // QC::Gates::UGate<> ugate;
1154 QC::Gates::SGate<> sgate;
1155 QC::Gates::SDGGate<> sdggate;
1156 QC::Gates::TGate<> tgate;
1157 QC::Gates::TDGGate<> tdggate;
1158 QC::Gates::SquareRootNOTGate<> sxgate;
1159 QC::Gates::SquareRootNOTDagGate<> sxdaggate;
1160 QC::Gates::HyGate<> k;
1161 QC::Gates::RxGate<> rxgate;
1162 QC::Gates::RyGate<> rygate;
1163 QC::Gates::RzGate<> rzgate;
1164 QC::Gates::UGate<> ugate;
1165 QC::Gates::CNOTGate<> cxgate;
1166 QC::Gates::ControlledYGate<> cygate;
1167 QC::Gates::ControlledZGate<> czgate;
1168 QC::Gates::ControlledPhaseShiftGate<> cpgate;
1169 QC::Gates::ControlledRxGate<> crxgate;
1170 QC::Gates::ControlledRyGate<> crygate;
1171 QC::Gates::ControlledRzGate<> crzgate;
1172 QC::Gates::ControlledHadamardGate<> ch;
1173 QC::Gates::ControlledSquareRootNOTGate<> csx;
1174 QC::Gates::ControlledSquareRootNOTDagGate<> csxdag;
1175 QC::Gates::SwapGate<> swapgate;
1176 QC::Gates::ToffoliGate<> ccxgate;
1177 QC::Gates::FredkinGate<> cswapgate;
1178 QC::Gates::ControlledUGate<> cugate;
1179};
1180
1181} // namespace Private
1182} // namespace Simulators
1183
1184#endif
1185
1186#endif // !_QCSIMSIMULATOR_H
int ApplyK(void *sim, int qubit)
int ApplyRx(void *sim, int qubit, double theta)
int ApplyX(void *sim, int qubit)
int ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyCRy(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyTDG(void *sim, int qubit)
int ApplyS(void *sim, int qubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int ApplySDG(void *sim, int qubit)
int ApplyCSwap(void *sim, int controlQubit, int qubit1, int qubit2)
int ApplyCCX(void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ApplyY(void *sim, int qubit)
int ApplyZ(void *sim, int qubit)
int ApplyH(void *sim, int qubit)
int ApplyCY(void *sim, int controlQubit, int targetQubit)
int ApplyCU(void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int ApplySwap(void *sim, int qubit1, int qubit2)
int ApplyRy(void *sim, int qubit, double theta)
int ApplyP(void *sim, int qubit, double theta)
int ApplyCH(void *sim, int controlQubit, int targetQubit)
int GetSimulationType(void *sim)
int ApplyCZ(void *sim, int controlQubit, int targetQubit)
int ApplyRz(void *sim, int qubit, double theta)
int ApplyT(void *sim, int qubit)
int ApplyCRx(void *sim, int controlQubit, int targetQubit, double theta)
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:21