Maestro 0.2.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QuantumGates.h
Go to the documentation of this file.
1
14
15#pragma once
16
17#ifndef _QUANTUM_GATES_H_
18#define _QUANTUM_GATES_H_
19
20#include "Operations.h"
21
22namespace Circuits {
23
61
71template <typename Time = Types::time_type>
72class IQuantumGate : public IGateOperation<Time> {
73 public:
81 IQuantumGate(Time delay = 0) : IGateOperation<Time>(delay) {}
82
90 virtual QuantumGateType GetGateType() const = 0;
91
99 virtual std::vector<double> GetParams() const { return {}; }
100};
101
112template <typename Time = Types::time_type>
113class SingleQubitGate : public IQuantumGate<Time> {
114 public:
124 SingleQubitGate(Types::qubit_t qubit = 0, Time delay = 0)
125 : IQuantumGate<Time>(delay), qubit(qubit) {}
126
133 virtual ~SingleQubitGate() {}
134
142 unsigned int GetNumQubits() const override { return 1; }
143
152 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
153 qubit = q;
154 }
155
165 Types::qubit_t GetQubit(unsigned int index = 0) const override {
166 return qubit;
167 }
168
176 Types::qubits_vector AffectedQubits() const override { return {qubit}; }
177
188 std::shared_ptr<IOperation<Time>> Remap(
189 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
190 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
191 const override {
192 auto newGate = this->Clone();
193
194 const auto qubitit = qubitsMap.find(qubit);
195 if (qubitit != qubitsMap.end())
196 std::static_pointer_cast<SingleQubitGate<Time>>(newGate)->SetQubit(
197 qubitit->second);
198 // else throw std::invalid_argument("Qubit not found in qubits map to remap
199 // the gate.");
200
201 return newGate;
202 }
203
204 private:
205 Types::qubit_t qubit;
206};
207
217template <typename Time = Types::time_type>
218class TwoQubitsGate : public IQuantumGate<Time> {
219 public:
232 Time delay = 0)
233 : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2) {}
234
241 virtual ~TwoQubitsGate() {}
242
250 unsigned int GetNumQubits() const override { return 2; }
251
260 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
261 if (index == 0)
262 qubit1 = q;
263 else if (index == 1)
264 qubit2 = q;
265 }
266
276 Types::qubit_t GetQubit(unsigned int index = 0) const override {
277 if (index == 0)
278 return qubit1;
279 else if (index == 1)
280 return qubit2;
281
282 return UINT_MAX;
283 }
284
292 return {qubit1, qubit2};
293 }
294
305 std::shared_ptr<IOperation<Time>> Remap(
306 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
307 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
308 const override {
309 auto newGate = this->Clone();
310
311 const auto qubitit1 = qubitsMap.find(qubit1);
312 if (qubitit1 != qubitsMap.end())
313 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
314 qubitit1->second, 0);
315
316 const auto qubitit2 = qubitsMap.find(qubit2);
317 if (qubitit2 != qubitsMap.end())
318 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
319 qubitit2->second, 1);
320
321 return newGate;
322 }
323
324 private:
325 Types::qubit_t qubit1;
327 qubit2;
328};
329
339template <typename Time = Types::time_type>
340class ThreeQubitsGate : public IQuantumGate<Time> {
341 public:
355 Types::qubit_t qubit3 = 0, Time delay = 0)
356 : IQuantumGate<Time>(delay),
357 qubit1(qubit1),
358 qubit2(qubit2),
359 qubit3(qubit3) {}
360
367 virtual ~ThreeQubitsGate() {}
368
376 unsigned int GetNumQubits() const override { return 3; }
377
386 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
387 if (index == 0)
388 qubit1 = q;
389 else if (index == 1)
390 qubit2 = q;
391 else if (index == 2)
392 qubit3 = q;
393 }
394
404 Types::qubit_t GetQubit(unsigned int index = 0) const override {
405 if (index == 0)
406 return qubit1;
407 else if (index == 1)
408 return qubit2;
409 else if (index == 2)
410 return qubit3;
411
412 return UINT_MAX;
413 }
414
423 return {qubit1, qubit2, qubit3};
424 }
425
436 std::shared_ptr<IOperation<Time>> Remap(
437 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
438 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
439 const override {
440 auto newGate = this->Clone();
441
442 const auto qubitit1 = qubitsMap.find(qubit1);
443 if (qubitit1 != qubitsMap.end())
444 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
445 qubitit1->second, 0);
446
447 const auto qubitit2 = qubitsMap.find(qubit2);
448 if (qubitit2 != qubitsMap.end())
449 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
450 qubitit2->second, 1);
451
452 const auto qubitit3 = qubitsMap.find(qubit3);
453 if (qubitit3 != qubitsMap.end())
454 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
455 qubitit3->second, 2);
456
457 return newGate;
458 }
459
460 private:
461 Types::qubit_t qubit1;
463 qubit2;
464 Types::qubit_t qubit3;
465};
466
467//**********************************************************************************************
468// Single Qubit Gates
469//**********************************************************************************************
470
479template <typename Time = Types::time_type>
480class PhaseGate : public SingleQubitGate<Time> {
481 public:
492 PhaseGate(Types::qubit_t qubit = 0, double lambda = 0, Time delay = 0)
493 : SingleQubitGate<Time>(qubit, delay), lambda(lambda) {}
494
505 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
506 OperationState &state) const override {
507 sim->ApplyP(SingleQubitGate<Time>::GetQubit(), lambda);
508 }
509
516 void SetLambda(double l) { lambda = l; }
517
524 double GetLambda() const { return lambda; }
525
533 QuantumGateType GetGateType() const override {
535 }
536
543 std::shared_ptr<IOperation<Time>> Clone() const override {
544 return std::make_shared<PhaseGate<Time>>(SingleQubitGate<Time>::GetQubit(),
545 lambda,
547 }
548
555 std::vector<double> GetParams() const override { return {lambda}; }
556
566 bool IsClifford() const override {
567 if (std::abs(lambda - M_PI_2) > 1e-10) return false;
568
569 return true;
570 }
571
572 private:
573 double lambda;
574};
575
584template <typename Time = Types::time_type>
585class XGate : public SingleQubitGate<Time> {
586 public:
596 XGate(Types::qubit_t qubit = 0, Time delay = 0)
597 : SingleQubitGate<Time>(qubit, delay) {}
598
609 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
610 OperationState &state) const override {
611 sim->ApplyX(SingleQubitGate<Time>::GetQubit());
612 }
613
621 QuantumGateType GetGateType() const override {
623 }
624
631 std::shared_ptr<IOperation<Time>> Clone() const override {
632 return std::make_shared<XGate<Time>>(SingleQubitGate<Time>::GetQubit(),
634 }
635
645 bool IsClifford() const override { return true; }
646};
647
656template <typename Time = Types::time_type>
657class YGate : public SingleQubitGate<Time> {
658 public:
668 YGate(Types::qubit_t qubit = 0, Time delay = 0)
669 : SingleQubitGate<Time>(qubit, delay) {}
670
681 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
682 OperationState &state) const override {
683 sim->ApplyY(SingleQubitGate<Time>::GetQubit());
684 }
685
693 QuantumGateType GetGateType() const override {
695 }
696
703 std::shared_ptr<IOperation<Time>> Clone() const override {
704 return std::make_shared<YGate<Time>>(SingleQubitGate<Time>::GetQubit(),
706 }
707
717 bool IsClifford() const override { return true; }
718};
719
728template <typename Time = Types::time_type>
729class ZGate : public SingleQubitGate<Time> {
730 public:
740 ZGate(Types::qubit_t qubit = 0, Time delay = 0)
741 : SingleQubitGate<Time>(qubit, delay) {}
742
753 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
754 OperationState &state) const override {
755 sim->ApplyZ(SingleQubitGate<Time>::GetQubit());
756 }
757
765 QuantumGateType GetGateType() const override {
767 }
768
775 std::shared_ptr<IOperation<Time>> Clone() const override {
776 return std::make_shared<ZGate<Time>>(SingleQubitGate<Time>::GetQubit(),
778 }
779
789 bool IsClifford() const override { return true; }
790};
791
800template <typename Time = Types::time_type>
801class HadamardGate : public SingleQubitGate<Time> {
802 public:
812 HadamardGate(Types::qubit_t qubit = 0, Time delay = 0)
813 : SingleQubitGate<Time>(qubit, delay) {}
814
825 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
826 OperationState &state) const override {
827 sim->ApplyH(SingleQubitGate<Time>::GetQubit());
828 }
829
840
847 std::shared_ptr<IOperation<Time>> Clone() const override {
848 return std::make_shared<HadamardGate<Time>>(
850 }
851
861 bool IsClifford() const override { return true; }
862
871 bool IsBranching() const override { return true; }
872};
873
882template <typename Time = Types::time_type>
883class SGate : public SingleQubitGate<Time> {
884 public:
894 SGate(Types::qubit_t qubit = 0, Time delay = 0)
895 : SingleQubitGate<Time>(qubit, delay) {}
896
907 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
908 OperationState &state) const override {
909 sim->ApplyS(SingleQubitGate<Time>::GetQubit());
910 }
911
919 QuantumGateType GetGateType() const override {
921 }
922
929 std::shared_ptr<IOperation<Time>> Clone() const override {
930 return std::make_shared<SGate<Time>>(SingleQubitGate<Time>::GetQubit(),
932 }
933
943 bool IsClifford() const override { return true; }
944};
945
954template <typename Time = Types::time_type>
955class SdgGate : public SingleQubitGate<Time> {
956 public:
966 SdgGate(Types::qubit_t qubit = 0, Time delay = 0)
967 : SingleQubitGate<Time>(qubit, delay) {}
968
979 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
980 OperationState &state) const override {
981 sim->ApplySDG(SingleQubitGate<Time>::GetQubit());
982 }
983
991 QuantumGateType GetGateType() const override {
993 }
994
1001 std::shared_ptr<IOperation<Time>> Clone() const override {
1002 return std::make_shared<SdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1004 }
1005
1015 bool IsClifford() const override { return true; }
1016};
1017
1026template <typename Time = Types::time_type>
1027class TGate : public SingleQubitGate<Time> {
1028 public:
1038 TGate(Types::qubit_t qubit = 0, Time delay = 0)
1039 : SingleQubitGate<Time>(qubit, delay) {}
1040
1051 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1052 OperationState &state) const override {
1053 sim->ApplyT(SingleQubitGate<Time>::GetQubit());
1054 }
1055
1063 QuantumGateType GetGateType() const override {
1065 }
1066
1073 std::shared_ptr<IOperation<Time>> Clone() const override {
1074 return std::make_shared<TGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1076 }
1077};
1078
1087template <typename Time = Types::time_type>
1088class TdgGate : public SingleQubitGate<Time> {
1089 public:
1099 TdgGate(Types::qubit_t qubit = 0, Time delay = 0)
1100 : SingleQubitGate<Time>(qubit, delay) {}
1101
1112 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1113 OperationState &state) const override {
1114 sim->ApplyTDG(SingleQubitGate<Time>::GetQubit());
1115 }
1116
1124 QuantumGateType GetGateType() const override {
1126 }
1127
1134 std::shared_ptr<IOperation<Time>> Clone() const override {
1135 return std::make_shared<TdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1137 }
1138};
1139
1148template <typename Time = Types::time_type>
1149class SxGate : public SingleQubitGate<Time> {
1150 public:
1160 SxGate(Types::qubit_t qubit = 0, Time delay = 0)
1161 : SingleQubitGate<Time>(qubit, delay) {}
1162
1173 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1174 OperationState &state) const override {
1175 sim->ApplySx(SingleQubitGate<Time>::GetQubit());
1176 }
1177
1185 QuantumGateType GetGateType() const override {
1187 }
1188
1195 std::shared_ptr<IOperation<Time>> Clone() const override {
1196 return std::make_shared<SxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1198 }
1199
1209 bool IsClifford() const override { return true; }
1210
1219 bool IsBranching() const override { return true; }
1220};
1221
1230template <typename Time = Types::time_type>
1231class SxDagGate : public SingleQubitGate<Time> {
1232 public:
1242 SxDagGate(Types::qubit_t qubit = 0, Time delay = 0)
1243 : SingleQubitGate<Time>(qubit, delay) {}
1244
1255 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1256 OperationState &state) const override {
1257 sim->ApplySxDAG(SingleQubitGate<Time>::GetQubit());
1258 }
1259
1267 QuantumGateType GetGateType() const override {
1269 }
1270
1277 std::shared_ptr<IOperation<Time>> Clone() const override {
1278 return std::make_shared<SxDagGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1280 }
1281
1291 bool IsClifford() const override { return true; }
1292
1301 bool IsBranching() const override { return true; }
1302};
1303
1312template <typename Time = Types::time_type>
1313class KGate : public SingleQubitGate<Time> {
1314 public:
1324 KGate(Types::qubit_t qubit = 0, Time delay = 0)
1325 : SingleQubitGate<Time>(qubit, delay) {}
1326
1337 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1338 OperationState &state) const override {
1339 sim->ApplyK(SingleQubitGate<Time>::GetQubit());
1340 }
1341
1349 QuantumGateType GetGateType() const override {
1351 }
1352
1359 std::shared_ptr<IOperation<Time>> Clone() const override {
1360 return std::make_shared<KGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1362 }
1363
1373 bool IsClifford() const override { return true; }
1374
1383 bool IsBranching() const override { return true; }
1384};
1385
1394template <typename Time = Types::time_type>
1395class RotationGate : public SingleQubitGate<Time> {
1396 public:
1408 RotationGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1409 : SingleQubitGate<Time>(qubit, delay), theta(theta) {}
1410
1417 void SetTheta(double t) { theta = t; }
1418
1425 double GetTheta() const { return theta; }
1426
1433 std::vector<double> GetParams() const override { return {theta}; }
1434
1435 private:
1436 double theta;
1437};
1438
1448template <typename Time = Types::time_type>
1449class RxGate : public RotationGate<Time> {
1450 public:
1461 RxGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1462 : RotationGate<Time>(qubit, theta, delay) {}
1463
1474 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1475 OperationState &state) const override {
1476 sim->ApplyRx(SingleQubitGate<Time>::GetQubit(),
1478 }
1479
1487 QuantumGateType GetGateType() const override {
1489 }
1490
1497 std::shared_ptr<IOperation<Time>> Clone() const override {
1498 return std::make_shared<RxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1501 }
1502
1511 bool IsBranching() const override { return true; }
1512};
1513
1523template <typename Time = Types::time_type>
1524class RyGate : public RotationGate<Time> {
1525 public:
1536 RyGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1537 : RotationGate<Time>(qubit, theta, delay) {}
1538
1549 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1550 OperationState &state) const override {
1551 sim->ApplyRy(SingleQubitGate<Time>::GetQubit(),
1553 }
1554
1562 QuantumGateType GetGateType() const override {
1564 }
1565
1572 std::shared_ptr<IOperation<Time>> Clone() const override {
1573 return std::make_shared<RyGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1576 }
1577
1586 bool IsBranching() const override { return true; }
1587};
1588
1598template <typename Time = Types::time_type>
1599class RzGate : public RotationGate<Time> {
1600 public:
1611 RzGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1612 : RotationGate<Time>(qubit, theta, delay) {}
1613
1624 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1625 OperationState &state) const override {
1626 sim->ApplyRz(SingleQubitGate<Time>::GetQubit(),
1628 }
1629
1637 QuantumGateType GetGateType() const override {
1639 }
1640
1647 std::shared_ptr<IOperation<Time>> Clone() const override {
1648 return std::make_shared<RzGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1651 }
1652};
1653
1662template <typename Time = Types::time_type>
1663class UGate : public SingleQubitGate<Time> {
1664 public:
1675 UGate(Types::qubit_t qubit = 0, double theta = 0, double phi = 0,
1676 double lambda = 0, double gamma = 0, Time delay = 0)
1677 : SingleQubitGate<Time>(qubit, delay),
1678 theta(theta),
1679 phi(phi),
1680 lambda(lambda),
1681 gamma(gamma) {}
1682
1693 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1694 OperationState &state) const override {
1695 sim->ApplyU(SingleQubitGate<Time>::GetQubit(), theta, phi, lambda, gamma);
1696 }
1697
1705 QuantumGateType GetGateType() const override {
1707 }
1708
1715 std::shared_ptr<IOperation<Time>> Clone() const override {
1716 return std::make_shared<UGate<Time>>(
1719 }
1720
1727 void SetTheta(double t) { theta = t; }
1728
1735 double GetTheta() const { return theta; }
1736
1743 void SetPhi(double p) { phi = p; }
1744
1751 double GetPhi() const { return phi; }
1752
1759 void SetLambda(double l) { lambda = l; }
1760
1767 double GetLambda() const { return lambda; }
1768
1775 void SetGamma(double g) { gamma = g; }
1776
1783 double GetGamma() const { return gamma; }
1784
1791 std::vector<double> GetParams() const override {
1792 return {theta, phi, lambda, gamma};
1793 }
1794
1804 bool IsClifford() const override { return false; }
1805
1814 bool IsBranching() const override { return true; }
1815
1816 private:
1817 double theta;
1818 double phi;
1819 double lambda;
1820 double gamma;
1821};
1822
1823//**********************************************************************************************
1824// Two Qubit Gates
1825//**********************************************************************************************
1826
1827// this one should be replaced - for example with three qnots - to be able to
1828// distribute it
1829
1838template <typename Time = Types::time_type>
1839class SwapGate : public TwoQubitsGate<Time> {
1840 public:
1851 SwapGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 1, Time delay = 0)
1852 : TwoQubitsGate<Time>(qubit1, qubit2, delay) {}
1853
1864 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1865 OperationState &state) const override {
1866 sim->ApplySwap(TwoQubitsGate<Time>::GetQubit(0),
1868 }
1869
1877 QuantumGateType GetGateType() const override {
1879 }
1880
1887 std::shared_ptr<IOperation<Time>> Clone() const override {
1888 return std::make_shared<SwapGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1891 }
1892
1902 bool IsClifford() const override { return true; }
1903};
1904
1905// the others are all controlled gates
1906
1915template <typename Time = Types::time_type>
1916class CXGate : public TwoQubitsGate<Time> {
1917 public:
1928 CXGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1929 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1930
1941 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1942 OperationState &state) const override {
1943 sim->ApplyCX(TwoQubitsGate<Time>::GetQubit(0),
1945 }
1946
1954 QuantumGateType GetGateType() const override {
1956 }
1957
1964 std::shared_ptr<IOperation<Time>> Clone() const override {
1965 return std::make_shared<CXGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1968 }
1969
1979 bool IsClifford() const override { return true; }
1980};
1981
1990template <typename Time = Types::time_type>
1991class CYGate : public TwoQubitsGate<Time> {
1992 public:
2003 CYGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2004 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2005
2016 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2017 OperationState &state) const override {
2018 sim->ApplyCY(TwoQubitsGate<Time>::GetQubit(0),
2020 }
2021
2029 QuantumGateType GetGateType() const override {
2031 }
2032
2039 std::shared_ptr<IOperation<Time>> Clone() const override {
2040 return std::make_shared<CYGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2043 }
2044
2054 bool IsClifford() const override { return true; }
2055};
2056
2065template <typename Time = Types::time_type>
2066class CZGate : public TwoQubitsGate<Time> {
2067 public:
2078 CZGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2079 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2080
2091 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2092 OperationState &state) const override {
2093 sim->ApplyCZ(TwoQubitsGate<Time>::GetQubit(0),
2095 }
2096
2104 QuantumGateType GetGateType() const override {
2106 }
2107
2114 std::shared_ptr<IOperation<Time>> Clone() const override {
2115 return std::make_shared<CZGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2118 }
2119
2129 bool IsClifford() const override { return true; }
2130};
2131
2140template <typename Time = Types::time_type>
2141class CPGate : public TwoQubitsGate<Time> {
2142 public:
2154 CPGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double lambda = 0,
2155 Time delay = 0)
2156 : TwoQubitsGate<Time>(ctrl, target, delay), lambda(lambda) {}
2157
2168 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2169 OperationState &state) const override {
2170 sim->ApplyCP(TwoQubitsGate<Time>::GetQubit(0),
2172 }
2173
2180 void SetLambda(double l) { lambda = l; }
2181
2188 double GetLambda() const { return lambda; }
2189
2197 QuantumGateType GetGateType() const override {
2199 }
2200
2207 std::shared_ptr<IOperation<Time>> Clone() const override {
2208 return std::make_shared<CPGate<Time>>(
2211 }
2212
2219 std::vector<double> GetParams() const override { return {lambda}; }
2220
2221 private:
2222 double lambda;
2223};
2224
2233template <typename Time = Types::time_type>
2235 public:
2249 double theta = 0, Time delay = 0)
2250 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta) {}
2251
2258 void SetTheta(double t) { theta = t; }
2259
2266 double GetTheta() const { return theta; }
2267
2274 std::vector<double> GetParams() const override { return {theta}; }
2275
2276 private:
2277 double theta;
2278};
2279
2288template <typename Time = Types::time_type>
2289class CRxGate : public ControlledRotationGate<Time> {
2290 public:
2302 CRxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2303 Time delay = 0)
2304 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2305
2316 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2317 OperationState &state) const override {
2318 sim->ApplyCRx(TwoQubitsGate<Time>::GetQubit(0),
2321 }
2322
2330 QuantumGateType GetGateType() const override {
2332 }
2333
2340 std::shared_ptr<IOperation<Time>> Clone() const override {
2341 return std::make_shared<CRxGate<Time>>(
2344 }
2345
2354 bool IsBranching() const override { return true; }
2355};
2356
2365template <typename Time = Types::time_type>
2366class CRyGate : public ControlledRotationGate<Time> {
2367 public:
2379 CRyGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2380 Time delay = 0)
2381 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2382
2393 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2394 OperationState &state) const override {
2395 sim->ApplyCRy(TwoQubitsGate<Time>::GetQubit(0),
2398 }
2399
2407 QuantumGateType GetGateType() const override {
2409 }
2410
2417 std::shared_ptr<IOperation<Time>> Clone() const override {
2418 return std::make_shared<CRyGate<Time>>(
2421 }
2422
2431 bool IsBranching() const override { return true; }
2432};
2433
2442template <typename Time = Types::time_type>
2443class CRzGate : public ControlledRotationGate<Time> {
2444 public:
2456 CRzGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2457 Time delay = 0)
2458 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2459
2470 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2471 OperationState &state) const override {
2472 sim->ApplyCRz(TwoQubitsGate<Time>::GetQubit(0),
2475 }
2476
2484 QuantumGateType GetGateType() const override {
2486 }
2487
2494 std::shared_ptr<IOperation<Time>> Clone() const override {
2495 return std::make_shared<CRzGate<Time>>(
2498 }
2499};
2500
2509template <typename Time = Types::time_type>
2510class CHGate : public TwoQubitsGate<Time> {
2511 public:
2522 CHGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2523 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2524
2535 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2536 OperationState &state) const override {
2537 sim->ApplyCH(TwoQubitsGate<Time>::GetQubit(0),
2539 }
2540
2548 QuantumGateType GetGateType() const override {
2550 }
2551
2558 std::shared_ptr<IOperation<Time>> Clone() const override {
2559 return std::make_shared<CHGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2562 }
2563
2572 bool IsBranching() const override { return true; }
2573};
2574
2583template <typename Time = Types::time_type>
2584class CSxGate : public TwoQubitsGate<Time> {
2585 public:
2596 CSxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2597 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2598
2609 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2610 OperationState &state) const override {
2611 sim->ApplyCSx(TwoQubitsGate<Time>::GetQubit(0),
2613 }
2614
2622 QuantumGateType GetGateType() const override {
2624 }
2625
2632 std::shared_ptr<IOperation<Time>> Clone() const override {
2633 return std::make_shared<CSxGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2636 }
2637
2646 bool IsBranching() const override { return true; }
2647};
2648
2657template <typename Time = Types::time_type>
2658class CSxDagGate : public TwoQubitsGate<Time> {
2659 public:
2670 CSxDagGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2671 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2672
2683 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2684 OperationState &state) const override {
2685 sim->ApplyCSxDAG(TwoQubitsGate<Time>::GetQubit(0),
2687 }
2688
2696 QuantumGateType GetGateType() const override {
2698 }
2699
2706 std::shared_ptr<IOperation<Time>> Clone() const override {
2707 return std::make_shared<CSxDagGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2710 }
2711
2720 bool IsBranching() const override { return true; }
2721};
2722
2731template <typename Time = Types::time_type>
2732class CUGate : public TwoQubitsGate<Time> {
2733 public:
2748 CUGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2749 double phi = 0, double lambda = 0, double gamma = 0, Time delay = 0)
2750 : TwoQubitsGate<Time>(ctrl, target, delay),
2751 theta(theta),
2752 phi(phi),
2753 lambda(lambda),
2754 gamma(gamma) {}
2755
2766 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2767 OperationState &state) const override {
2768 sim->ApplyCU(TwoQubitsGate<Time>::GetQubit(0),
2770 GetLambda(), GetGamma());
2771 }
2772
2780 QuantumGateType GetGateType() const override {
2782 }
2783
2790 void SetTheta(double t) { theta = t; }
2791
2798 double GetTheta() const { return theta; }
2799
2806 void SetPhi(double p) { phi = p; }
2807
2814 double GetPhi() const { return phi; }
2815
2822 void SetLambda(double l) { lambda = l; }
2823
2830 double GetLambda() const { return lambda; }
2831
2838 void SetGamma(double g) { gamma = g; }
2839
2846 double GetGamma() const { return gamma; }
2847
2854 std::shared_ptr<IOperation<Time>> Clone() const override {
2855 return std::make_shared<CUGate<Time>>(
2857 GetTheta(), GetPhi(), GetLambda(), GetGamma(),
2859 }
2860
2867 std::vector<double> GetParams() const override {
2868 return {theta, phi, lambda, gamma};
2869 }
2870
2879 bool IsBranching() const override { return true; }
2880
2881 private:
2882 double theta;
2883 double phi;
2884 double lambda;
2885 double gamma;
2886};
2887
2888//**********************************************************************************************
2889// Three Qubit Gates
2890// those should be replaced by sets of gates with less qubits, to be able to
2891// distribute them
2892//**********************************************************************************************
2893
2902template <typename Time = Types::time_type>
2903class CCXGate : public ThreeQubitsGate<Time> {
2904 public:
2917 Types::qubit_t target = 2, Time delay = 0)
2918 : ThreeQubitsGate<Time>(ctrl1, ctrl2, target, delay) {}
2919
2930 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2931 OperationState &state) const override {
2932 sim->ApplyCCX(ThreeQubitsGate<Time>::GetQubit(0),
2935 }
2936
2944 QuantumGateType GetGateType() const override {
2946 }
2947
2954 std::shared_ptr<IOperation<Time>> Clone() const override {
2955 return std::make_shared<CCXGate<Time>>(
2958 }
2959};
2960
2969template <typename Time = Types::time_type>
2970class CSwapGate : public ThreeQubitsGate<Time> {
2971 public:
2984 Types::qubit_t target2 = 2, Time delay = 0)
2985 : ThreeQubitsGate<Time>(ctrl, target1, target2, delay) {}
2986
2997 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2998 OperationState &state) const override {
2999 sim->ApplyCSwap(ThreeQubitsGate<Time>::GetQubit(0),
3002 }
3003
3011 QuantumGateType GetGateType() const override {
3013 }
3014
3021 std::shared_ptr<IOperation<Time>> Clone() const override {
3022 return std::make_shared<CSwapGate<Time>>(
3025 }
3026};
3027
3028} // namespace Circuits
3029
3030#endif // !_QUANTUM_GATES_H_
CCXGate(Types::qubit_t ctrl1=0, Types::qubit_t ctrl2=1, Types::qubit_t target=2, Time delay=0)
CCXGate constructor.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CHGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CHGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void SetLambda(double l)
Set the lambda parameter for the controlled phase gate.
double GetLambda() const
Get the lambda parameter for the controlled phase gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
CPGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double lambda=0, Time delay=0)
CPGate constructor.
std::vector< double > GetParams() const override
Get the gate parameters.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CRxGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, Time delay=0)
CRxGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
CRyGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, Time delay=0)
CRyGate constructor.
bool IsBranching() const override
Checks if the operation is a branching one.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CRzGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, Time delay=0)
CRzGate constructor.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
CSwapGate(Types::qubit_t ctrl=0, Types::qubit_t target1=1, Types::qubit_t target2=2, Time delay=0)
CSwapGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CSxDagGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CSxDagGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsBranching() const override
Checks if the operation is a branching one.
CSxGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CSxGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void SetLambda(double l)
Set the lambda parameter for the controlled U gate.
double GetLambda() const
Get the lambda parameter for the controlled U gate.
CUGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, double phi=0, double lambda=0, double gamma=0, Time delay=0)
CUGate constructor.
double GetPhi() const
Get the phi parameter for the controlled U gate.
void SetPhi(double p)
Set the phi parameter for the controlled U gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsBranching() const override
Checks if the operation is a branching one.
double GetTheta() const
Get the theta parameter for the controlled U gate.
void SetTheta(double t)
Set the theta parameter for the controlled U gate.
std::vector< double > GetParams() const override
Get the gate parameters.
double GetGamma() const
Get the gamma parameter for the controlled U gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
void SetGamma(double g)
Set the gamma parameter for the controlled U gate.
CXGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CXGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CYGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CYGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
CZGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CZGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
ControlledRotationGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, Time delay=0)
ControlledRotationGate constructor.
double GetTheta() const
Get the theta angle for the controlled rotation gate.
void SetTheta(double t)
Set the theta angle for the controlled rotation gate.
std::vector< double > GetParams() const override
Get the gate parameters.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
HadamardGate(Types::qubit_t qubit=0, Time delay=0)
HadamardGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
bool IsClifford() const override
Checks if the operation is a Clifford one.
IGateOperation(Types::time_type delay=0)
Definition Operations.h:622
Time GetDelay() const
Get the delay of the operation.
Definition Operations.h:497
virtual std::shared_ptr< IOperation< Types::time_type > > Clone() const =0
IQuantumGate(Time delay=0)
IQuantumGate constructor.
virtual QuantumGateType GetGateType() const =0
Get the type of the quantum gate.
virtual std::vector< double > GetParams() const
Get the gate parameters.
bool IsClifford() const override
Checks if the operation is a Clifford one.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
KGate(Types::qubit_t qubit=0, Time delay=0)
KGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
The state class that stores the classical state of a quantum circuit execution.
Definition Operations.h:63
double GetLambda() const
Get the lambda parameter for the phase gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::vector< double > GetParams() const override
Get the gate parameters.
void SetLambda(double l)
Set the lambda parameter for the phase gate.
PhaseGate(Types::qubit_t qubit=0, double lambda=0, Time delay=0)
PhaseGate constructor.
bool IsClifford() const override
Checks if the operation is a Clifford one.
RotationGate(Types::qubit_t qubit=0, double theta=0, Time delay=0)
RotationGate constructor.
double GetTheta() const
Get the theta angle for the rotation gate.
std::vector< double > GetParams() const override
Get the gate parameters.
void SetTheta(double t)
Set the theta angle for the rotation gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
RxGate(Types::qubit_t qubit=0, double theta=0, Time delay=0)
RxGate constructor.
bool IsBranching() const override
Checks if the operation is a branching one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsBranching() const override
Checks if the operation is a branching one.
RyGate(Types::qubit_t qubit=0, double theta=0, Time delay=0)
RyGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
RzGate(Types::qubit_t qubit=0, double theta=0, Time delay=0)
RzGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
SGate(Types::qubit_t qubit=0, Time delay=0)
SGate constructor.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
SdgGate(Types::qubit_t qubit=0, Time delay=0)
SdgGate constructor.
void SetQubit(Types::qubit_t q, unsigned long index=0) override
Set the qubit the quantum gate is applied to.
SingleQubitGate(Types::qubit_t qubit=0, Time delay=0)
SingleQubitGate constructor.
virtual ~SingleQubitGate()
The SingleQubitGate destructor.
Types::qubits_vector AffectedQubits() const override
Get the qubits the quantum gate is applied to.
unsigned int GetNumQubits() const override
Get the number of qubits the quantum gate is applied to.
Types::qubit_t GetQubit(unsigned int index=0) const override
Get the qubit the quantum gate is applied to.
std::shared_ptr< IOperation< Time > > Remap(const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
Get a shared pointer to a remapped operation.
SwapGate(Types::qubit_t qubit1=0, Types::qubit_t qubit2=1, Time delay=0)
SwapGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsBranching() const override
Checks if the operation is a branching one.
bool IsClifford() const override
Checks if the operation is a Clifford one.
SxDagGate(Types::qubit_t qubit=0, Time delay=0)
SxDagGate constructor.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
bool IsBranching() const override
Checks if the operation is a branching one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
SxGate(Types::qubit_t qubit=0, Time delay=0)
SxGate constructor.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
TGate(Types::qubit_t qubit=0, Time delay=0)
TGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
TdgGate(Types::qubit_t qubit=0, Time delay=0)
TdgGate constructor.
Types::qubits_vector AffectedQubits() const override
Get the qubits the quantum gate is applied to.
Types::qubit_t GetQubit(unsigned int index=0) const override
Get the qubit the quantum gate is applied to.
unsigned int GetNumQubits() const override
Get the number of qubits the quantum gate is applied to.
std::shared_ptr< IOperation< Time > > Remap(const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
Get a shared pointer to a remapped operation.
ThreeQubitsGate(Types::qubit_t qubit1=0, Types::qubit_t qubit2=0, Types::qubit_t qubit3=0, Time delay=0)
ThreeQubitsGate constructor.
virtual ~ThreeQubitsGate()
The ThreeQubitsGate destructor.
void SetQubit(Types::qubit_t q, unsigned long index=0) override
Set the qubit the quantum gate is applied to.
Types::qubit_t GetQubit(unsigned int index=0) const override
Get the qubit the quantum gate is applied to.
std::shared_ptr< IOperation< Time > > Remap(const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
Get a shared pointer to a remapped operation.
virtual ~TwoQubitsGate()
The TwoQubitsGate destructor.
void SetQubit(Types::qubit_t q, unsigned long index=0) override
Set the qubit the quantum gate is applied to.
TwoQubitsGate(Types::qubit_t qubit1=0, Types::qubit_t qubit2=0, Time delay=0)
TwoQubitsGate constructor.
unsigned int GetNumQubits() const override
Get the number of qubits the quantum gate is applied to.
Types::qubits_vector AffectedQubits() const override
Get the qubits the quantum gate is applied to.
double GetGamma() const
Get the gamma parameter for the gate.
void SetLambda(double l)
Set the lambda parameter for the gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
bool IsBranching() const override
Checks if the operation is a branching one.
void SetPhi(double p)
Set the phi parameter for the gate.
double GetLambda() const
Get the lambda parameter for the gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
void SetTheta(double t)
Set the theta parameter for the gate.
UGate(Types::qubit_t qubit=0, double theta=0, double phi=0, double lambda=0, double gamma=0, Time delay=0)
UGate constructor.
std::vector< double > GetParams() const override
Get the gate parameters.
double GetTheta() const
Get the theta parameter for the gate.
double GetPhi() const
Get the phi parameter for the gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
void SetGamma(double g)
Set the gamma parameter for the gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsClifford() const override
Checks if the operation is a Clifford one.
XGate(Types::qubit_t qubit=0, Time delay=0)
XGate constructor.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
YGate(Types::qubit_t qubit=0, Time delay=0)
YGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsClifford() const override
Checks if the operation is a Clifford one.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool IsClifford() const override
Checks if the operation is a Clifford one.
ZGate(Types::qubit_t qubit=0, Time delay=0)
ZGate constructor.
QuantumGateType
The type of quantum gates.
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
Definition Types.h:22
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:21