Maestro 0.3.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#include "QuantumGate.h"
22
23namespace Circuits
24{
25
64
74template <typename Time = Types::time_type> class IQuantumGate : public IGateOperation<Time>
75{
76 public:
84 IQuantumGate(Time delay = 0) : IGateOperation<Time>(delay)
85 {
86 }
87
95 virtual QuantumGateType GetGateType() const = 0;
96
104 virtual std::vector<double> GetParams() const
105 {
106 return {};
107 }
108
115 virtual Eigen::MatrixXcd GetMatrix() const = 0;
116};
117
133template <template <typename> class Gate, template <typename> class Base, typename Time> class CloneableGate : public Base<Time>
134{
135 public:
136 using Base<Time>::Base;
137
144 std::shared_ptr<IOperation<Time>> Clone() const override
145 {
146 return std::make_shared<Gate<Time>>(static_cast<const Gate<Time> &>(*this));
147 }
148};
149
160template <typename Time = Types::time_type> class SingleQubitGate : public IQuantumGate<Time>
161{
162 public:
172 SingleQubitGate(Types::qubit_t qubit = 0, Time delay = 0) : IQuantumGate<Time>(delay), qubit(qubit)
173 {
174 }
175
183 {
184 }
185
193 unsigned int GetNumQubits() const override
194 {
195 return 1;
196 }
197
206 void SetQubit(Types::qubit_t q, unsigned long index = 0) override
207 {
208 qubit = q;
209 }
210
220 Types::qubit_t GetQubit(unsigned int index = 0) const override
221 {
222 return qubit;
223 }
224
233 {
234 return {qubit};
235 }
236
247 std::shared_ptr<IOperation<Time>> Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
248 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {}) const override
249 {
250 auto newGate = this->Clone();
251
252 const auto qubitit = qubitsMap.find(qubit);
253 if (qubitit != qubitsMap.end())
254 std::static_pointer_cast<SingleQubitGate<Time>>(newGate)->SetQubit(qubitit->second);
255 // else throw std::invalid_argument("Qubit not found in qubits map to remap
256 // the gate.");
257
258 return newGate;
259 }
260
261 private:
262 Types::qubit_t qubit;
263};
264
274template <typename Time = Types::time_type> class TwoQubitsGate : public IQuantumGate<Time>
275{
276 public:
288 TwoQubitsGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 0, Time delay = 0) : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2)
289 {
290 }
291
299 {
300 }
301
309 unsigned int GetNumQubits() const override
310 {
311 return 2;
312 }
313
322 void SetQubit(Types::qubit_t q, unsigned long index = 0) override
323 {
324 if (index == 0)
325 qubit1 = q;
326 else if (index == 1)
327 qubit2 = q;
328 }
329
339 Types::qubit_t GetQubit(unsigned int index = 0) const override
340 {
341 if (index == 0)
342 return qubit1;
343 else if (index == 1)
344 return qubit2;
345
346 return UINT_MAX;
347 }
348
356 {
357 return {qubit1, qubit2};
358 }
359
370 std::shared_ptr<IOperation<Time>> Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
371 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {}) const override
372 {
373 auto newGate = this->Clone();
374
375 const auto qubitit1 = qubitsMap.find(qubit1);
376 if (qubitit1 != qubitsMap.end())
377 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(qubitit1->second, 0);
378
379 const auto qubitit2 = qubitsMap.find(qubit2);
380 if (qubitit2 != qubitsMap.end())
381 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(qubitit2->second, 1);
382
383 return newGate;
384 }
385
386 private:
387 Types::qubit_t qubit1;
388 Types::qubit_t qubit2;
389};
390
400template <typename Time = Types::time_type> class ThreeQubitsGate : public IQuantumGate<Time>
401{
402 public:
415 ThreeQubitsGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 0, Types::qubit_t qubit3 = 0, Time delay = 0)
416 : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2), qubit3(qubit3)
417 {
418 }
419
427 {
428 }
429
437 unsigned int GetNumQubits() const override
438 {
439 return 3;
440 }
441
450 void SetQubit(Types::qubit_t q, unsigned long index = 0) override
451 {
452 if (index == 0)
453 qubit1 = q;
454 else if (index == 1)
455 qubit2 = q;
456 else if (index == 2)
457 qubit3 = q;
458 }
459
469 Types::qubit_t GetQubit(unsigned int index = 0) const override
470 {
471 if (index == 0)
472 return qubit1;
473 else if (index == 1)
474 return qubit2;
475 else if (index == 2)
476 return qubit3;
477
478 return UINT_MAX;
479 }
480
489 {
490 return {qubit1, qubit2, qubit3};
491 }
492
503 std::shared_ptr<IOperation<Time>> Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
504 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {}) const override
505 {
506 auto newGate = this->Clone();
507
508 const auto qubitit1 = qubitsMap.find(qubit1);
509 if (qubitit1 != qubitsMap.end())
510 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(qubitit1->second, 0);
511
512 const auto qubitit2 = qubitsMap.find(qubit2);
513 if (qubitit2 != qubitsMap.end())
514 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(qubitit2->second, 1);
515
516 const auto qubitit3 = qubitsMap.find(qubit3);
517 if (qubitit3 != qubitsMap.end())
518 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(qubitit3->second, 2);
519
520 return newGate;
521 }
522
523 private:
524 Types::qubit_t qubit1;
525 Types::qubit_t qubit2;
526 Types::qubit_t qubit3;
527};
528
529//**********************************************************************************************
530// Single Qubit Gates
531//**********************************************************************************************
532
541template <typename Time = Types::time_type> class PhaseGate : public CloneableGate<PhaseGate, SingleQubitGate, Time>
542{
543 public:
554 PhaseGate(Types::qubit_t qubit = 0, double lambda = 0, Time delay = 0)
555 : CloneableGate<PhaseGate, Circuits::SingleQubitGate, Time>(qubit, delay), lambda(lambda)
556 {
557 }
558
569 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
570 {
571 sim->ApplyP(SingleQubitGate<Time>::GetQubit(), lambda);
572 }
573
580 void SetLambda(double l)
581 {
582 lambda = l;
583 }
584
591 double GetLambda() const
592 {
593 return lambda;
594 }
595
604 {
606 }
607
614 std::vector<double> GetParams() const override
615 {
616 return {lambda};
617 }
618
628 bool IsClifford() const override
629 {
630 if (std::abs(lambda - M_PI_2) > 1e-10)
631 return false;
632
633 return true;
634 }
635
642 Eigen::MatrixXcd GetMatrix() const override
643 {
644 const QC::Gates::PhaseShiftGate<> pgate(lambda);
645
646 return pgate.getRawOperatorMatrix();
647 }
648
649 private:
650 double lambda;
651};
652
661template <typename Time = Types::time_type> class XGate : public CloneableGate<XGate, SingleQubitGate, Time>
662{
663 public:
673 XGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<XGate, Circuits::SingleQubitGate, Time>(qubit, delay)
674 {
675 }
676
687 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
688 {
689 sim->ApplyX(SingleQubitGate<Time>::GetQubit());
690 }
691
700 {
702 }
703
713 bool IsClifford() const override
714 {
715 return true;
716 }
717
724 Eigen::MatrixXcd GetMatrix() const override
725 {
726 static const QC::Gates::PauliXGate<> xgate;
727
728 return xgate.getRawOperatorMatrix();
729 }
730};
731
740template <typename Time = Types::time_type> class YGate : public CloneableGate<YGate, SingleQubitGate, Time>
741{
742 public:
752 YGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<YGate, Circuits::SingleQubitGate, Time>(qubit, delay)
753 {
754 }
755
766 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
767 {
768 sim->ApplyY(SingleQubitGate<Time>::GetQubit());
769 }
770
779 {
781 }
782
792 bool IsClifford() const override
793 {
794 return true;
795 }
796
803 Eigen::MatrixXcd GetMatrix() const override
804 {
805 static const QC::Gates::PauliYGate<> ygate;
806
807 return ygate.getRawOperatorMatrix();
808 }
809};
810
819template <typename Time = Types::time_type> class ZGate : public CloneableGate<ZGate, SingleQubitGate, Time>
820{
821 public:
831 ZGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<ZGate, Circuits::SingleQubitGate, Time>(qubit, delay)
832 {
833 }
834
845 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
846 {
847 sim->ApplyZ(SingleQubitGate<Time>::GetQubit());
848 }
849
858 {
860 }
861
871 bool IsClifford() const override
872 {
873 return true;
874 }
875
882 Eigen::MatrixXcd GetMatrix() const override
883 {
884 static const QC::Gates::PauliZGate<> zgate;
885
886 return zgate.getRawOperatorMatrix();
887 }
888};
889
898template <typename Time = Types::time_type> class HadamardGate : public CloneableGate<HadamardGate, SingleQubitGate, Time>
899{
900 public:
910 HadamardGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<HadamardGate, Circuits::SingleQubitGate, Time>(qubit, delay)
911 {
912 }
913
924 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
925 {
926 sim->ApplyH(SingleQubitGate<Time>::GetQubit());
927 }
928
937 {
939 }
940
950 bool IsClifford() const override
951 {
952 return true;
953 }
954
963 bool IsBranching() const override
964 {
965 return true;
966 }
967
974 Eigen::MatrixXcd GetMatrix() const override
975 {
976 static const QC::Gates::HadamardGate<> hgate;
977
978 return hgate.getRawOperatorMatrix();
979 }
980};
981
990template <typename Time = Types::time_type> class SGate : public CloneableGate<SGate, SingleQubitGate, Time>
991{
992 public:
1002 SGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<SGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1003 {
1004 }
1005
1016 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1017 {
1018 sim->ApplyS(SingleQubitGate<Time>::GetQubit());
1019 }
1020
1029 {
1031 }
1032
1042 bool IsClifford() const override
1043 {
1044 return true;
1045 }
1046
1053 Eigen::MatrixXcd GetMatrix() const override
1054 {
1055 static const QC::Gates::SGate<> sgate;
1056
1057 return sgate.getRawOperatorMatrix();
1058 }
1059};
1060
1069template <typename Time = Types::time_type> class SdgGate : public CloneableGate<SdgGate, SingleQubitGate, Time>
1070{
1071 public:
1081 SdgGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<SdgGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1082 {
1083 }
1084
1095 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1096 {
1097 sim->ApplySDG(SingleQubitGate<Time>::GetQubit());
1098 }
1099
1108 {
1110 }
1111
1121 bool IsClifford() const override
1122 {
1123 return true;
1124 }
1125
1132 Eigen::MatrixXcd GetMatrix() const override
1133 {
1134 static const QC::Gates::SDGGate<> sdggate;
1135
1136 return sdggate.getRawOperatorMatrix();
1137 }
1138};
1139
1148template <typename Time = Types::time_type> class TGate : public CloneableGate<TGate, SingleQubitGate, Time>
1149{
1150 public:
1160 TGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<TGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1161 {
1162 }
1163
1174 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1175 {
1176 sim->ApplyT(SingleQubitGate<Time>::GetQubit());
1177 }
1178
1187 {
1189 }
1190
1197 Eigen::MatrixXcd GetMatrix() const override
1198 {
1199 static const QC::Gates::TGate<> tgate;
1200
1201 return tgate.getRawOperatorMatrix();
1202 }
1203};
1204
1213template <typename Time = Types::time_type> class TdgGate : public CloneableGate<TdgGate, SingleQubitGate, Time>
1214{
1215 public:
1225 TdgGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<TdgGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1226 {
1227 }
1228
1239 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1240 {
1241 sim->ApplyTDG(SingleQubitGate<Time>::GetQubit());
1242 }
1243
1252 {
1254 }
1255
1262 Eigen::MatrixXcd GetMatrix() const override
1263 {
1264 static const QC::Gates::TDGGate<> tdggate;
1265
1266 return tdggate.getRawOperatorMatrix();
1267 }
1268};
1269
1278template <typename Time = Types::time_type> class SxGate : public CloneableGate<SxGate, SingleQubitGate, Time>
1279{
1280 public:
1290 SxGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<SxGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1291 {
1292 }
1293
1304 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1305 {
1306 sim->ApplySx(SingleQubitGate<Time>::GetQubit());
1307 }
1308
1317 {
1319 }
1320
1330 bool IsClifford() const override
1331 {
1332 return true;
1333 }
1334
1343 bool IsBranching() const override
1344 {
1345 return true;
1346 }
1347
1354 Eigen::MatrixXcd GetMatrix() const override
1355 {
1356 static const QC::Gates::SquareRootNOTGate<> sxgate;
1357 return sxgate.getRawOperatorMatrix();
1358 }
1359};
1360
1369template <typename Time = Types::time_type> class SxDagGate : public CloneableGate<SxDagGate, SingleQubitGate, Time>
1370{
1371 public:
1381 SxDagGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<SxDagGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1382 {
1383 }
1384
1395 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1396 {
1397 sim->ApplySxDAG(SingleQubitGate<Time>::GetQubit());
1398 }
1399
1408 {
1410 }
1411
1421 bool IsClifford() const override
1422 {
1423 return true;
1424 }
1425
1434 bool IsBranching() const override
1435 {
1436 return true;
1437 }
1438
1445 Eigen::MatrixXcd GetMatrix() const override
1446 {
1447 static const QC::Gates::SquareRootNOTDagGate<> sxdggate;
1448 return sxdggate.getRawOperatorMatrix();
1449 }
1450};
1451
1460template <typename Time = Types::time_type> class KGate : public CloneableGate<KGate, SingleQubitGate, Time>
1461{
1462 public:
1472 KGate(Types::qubit_t qubit = 0, Time delay = 0) : CloneableGate<KGate, Circuits::SingleQubitGate, Time>(qubit, delay)
1473 {
1474 }
1475
1486 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1487 {
1488 sim->ApplyK(SingleQubitGate<Time>::GetQubit());
1489 }
1490
1499 {
1501 }
1502
1512 bool IsClifford() const override
1513 {
1514 return true;
1515 }
1516
1525 bool IsBranching() const override
1526 {
1527 return true;
1528 }
1529
1536 Eigen::MatrixXcd GetMatrix() const override
1537 {
1538 static const QC::Gates::HyGate<> hygate;
1539 return hygate.getRawOperatorMatrix();
1540 }
1541};
1542
1551template <typename Time = Types::time_type> class RotationGate : public SingleQubitGate<Time>
1552{
1553 public:
1565 RotationGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0) : SingleQubitGate<Time>(qubit, delay), theta(theta)
1566 {
1567 }
1568
1575 void SetTheta(double t)
1576 {
1577 theta = t;
1578 }
1579
1586 double GetTheta() const
1587 {
1588 return theta;
1589 }
1590
1597 std::vector<double> GetParams() const override
1598 {
1599 return {theta};
1600 }
1601
1602 private:
1603 double theta;
1604};
1605
1615template <typename Time = Types::time_type> class RxGate : public CloneableGate<RxGate, RotationGate, Time>
1616{
1617 public:
1628 RxGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0) : CloneableGate<RxGate, Circuits::RotationGate, Time>(qubit, theta, delay)
1629 {
1630 }
1631
1642 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1643 {
1645 }
1646
1655 {
1657 }
1658
1667 bool IsBranching() const override
1668 {
1669 return true;
1670 }
1671
1678 Eigen::MatrixXcd GetMatrix() const override
1679 {
1680 const QC::Gates::RxGate<> rxgate(RotationGate<Time>::GetTheta());
1681 return rxgate.getRawOperatorMatrix();
1682 }
1683};
1684
1694template <typename Time = Types::time_type> class RyGate : public CloneableGate<RyGate, RotationGate, Time>
1695{
1696 public:
1707 RyGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0) : CloneableGate<RyGate, Circuits::RotationGate, Time>(qubit, theta, delay)
1708 {
1709 }
1710
1721 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1722 {
1724 }
1725
1734 {
1736 }
1737
1746 bool IsBranching() const override
1747 {
1748 return true;
1749 }
1750
1757 Eigen::MatrixXcd GetMatrix() const override
1758 {
1759 const QC::Gates::RyGate<> rygate(RotationGate<Time>::GetTheta());
1760 return rygate.getRawOperatorMatrix();
1761 }
1762};
1763
1773template <typename Time = Types::time_type> class RzGate : public CloneableGate<RzGate, RotationGate, Time>
1774{
1775 public:
1786 RzGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0) : CloneableGate<RzGate, Circuits::RotationGate, Time>(qubit, theta, delay)
1787 {
1788 }
1789
1800 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1801 {
1803 }
1804
1813 {
1815 }
1816
1823 Eigen::MatrixXcd GetMatrix() const override
1824 {
1825 const QC::Gates::RzGate<> rzgate(RotationGate<Time>::GetTheta());
1826 return rzgate.getRawOperatorMatrix();
1827 }
1828};
1829
1838template <typename Time = Types::time_type> class UGate : public CloneableGate<UGate, SingleQubitGate, Time>
1839{
1840 public:
1851 UGate(Types::qubit_t qubit = 0, double theta = 0, double phi = 0, double lambda = 0, double gamma = 0, Time delay = 0)
1852 : CloneableGate<UGate, Circuits::SingleQubitGate, Time>(qubit, delay), theta(theta), phi(phi), lambda(lambda), gamma(gamma)
1853 {
1854 }
1855
1866 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
1867 {
1868 sim->ApplyU(SingleQubitGate<Time>::GetQubit(), theta, phi, lambda, gamma);
1869 }
1870
1879 {
1881 }
1882
1889 void SetTheta(double t)
1890 {
1891 theta = t;
1892 }
1893
1900 double GetTheta() const
1901 {
1902 return theta;
1903 }
1904
1911 void SetPhi(double p)
1912 {
1913 phi = p;
1914 }
1915
1922 double GetPhi() const
1923 {
1924 return phi;
1925 }
1926
1933 void SetLambda(double l)
1934 {
1935 lambda = l;
1936 }
1937
1944 double GetLambda() const
1945 {
1946 return lambda;
1947 }
1948
1955 void SetGamma(double g)
1956 {
1957 gamma = g;
1958 }
1959
1966 double GetGamma() const
1967 {
1968 return gamma;
1969 }
1970
1977 std::vector<double> GetParams() const override
1978 {
1979 return {theta, phi, lambda, gamma};
1980 }
1981
1991 bool IsClifford() const override
1992 {
1993 return false;
1994 }
1995
2004 bool IsBranching() const override
2005 {
2006 return true;
2007 }
2008
2015 Eigen::MatrixXcd GetMatrix() const override
2016 {
2017 const QC::Gates::UGate<> ugate(theta, phi, lambda, gamma);
2018 return ugate.getRawOperatorMatrix();
2019 }
2020
2021 private:
2022 double theta;
2023 double phi;
2024 double lambda;
2025 double gamma;
2026};
2027
2028//**********************************************************************************************
2029// Two Qubit Gates
2030//**********************************************************************************************
2031
2032// this one should be replaced - for example with three qnots - to be able to
2033// distribute it
2034
2043template <typename Time = Types::time_type> class SwapGate : public CloneableGate<SwapGate, TwoQubitsGate, Time>
2044{
2045 public:
2056 SwapGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 1, Time delay = 0)
2057 : CloneableGate<SwapGate, Circuits::TwoQubitsGate, Time>(qubit1, qubit2, delay)
2058 {
2059 }
2060
2071 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2072 {
2074 }
2075
2084 {
2086 }
2087
2097 bool IsClifford() const override
2098 {
2099 return true;
2100 }
2101
2108 Eigen::MatrixXcd GetMatrix() const override
2109 {
2110 static const QC::Gates::SwapGate<> swapgate;
2111 return swapgate.getRawOperatorMatrix();
2112 }
2113};
2114
2115// the others are all controlled gates
2116
2125template <typename Time = Types::time_type> class CXGate : public CloneableGate<CXGate, TwoQubitsGate, Time>
2126{
2127 public:
2138 CXGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0) : CloneableGate<CXGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2139 {
2140 }
2141
2152 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2153 {
2155 }
2156
2165 {
2167 }
2168
2178 bool IsClifford() const override
2179 {
2180 return true;
2181 }
2182
2189 Eigen::MatrixXcd GetMatrix() const override
2190 {
2191 static const QC::Gates::CNOTGate<> cnotgate;
2192 return cnotgate.getRawOperatorMatrix();
2193 }
2194};
2195
2204template <typename Time = Types::time_type> class CYGate : public CloneableGate<CYGate, TwoQubitsGate, Time>
2205{
2206 public:
2217 CYGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0) : CloneableGate<CYGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2218 {
2219 }
2220
2231 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2232 {
2234 }
2235
2244 {
2246 }
2247
2257 bool IsClifford() const override
2258 {
2259 return true;
2260 }
2261
2268 Eigen::MatrixXcd GetMatrix() const override
2269 {
2270 static const QC::Gates::ControlledYGate<> cygate;
2271 return cygate.getRawOperatorMatrix();
2272 }
2273};
2274
2283template <typename Time = Types::time_type> class CZGate : public CloneableGate<CZGate, TwoQubitsGate, Time>
2284{
2285 public:
2296 CZGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0) : CloneableGate<CZGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2297 {
2298 }
2299
2310 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2311 {
2313 }
2314
2323 {
2325 }
2326
2336 bool IsClifford() const override
2337 {
2338 return true;
2339 }
2340
2347 Eigen::MatrixXcd GetMatrix() const override
2348 {
2349 static const QC::Gates::ControlledZGate<> czgate;
2350 return czgate.getRawOperatorMatrix();
2351 }
2352};
2353
2362template <typename Time = Types::time_type> class CPGate : public CloneableGate<CPGate, TwoQubitsGate, Time>
2363{
2364 public:
2376 CPGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double lambda = 0, Time delay = 0)
2377 : CloneableGate<CPGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay), lambda(lambda)
2378 {
2379 }
2380
2391 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2392 {
2394 }
2395
2402 void SetLambda(double l)
2403 {
2404 lambda = l;
2405 }
2406
2413 double GetLambda() const
2414 {
2415 return lambda;
2416 }
2417
2426 {
2428 }
2429
2436 std::vector<double> GetParams() const override
2437 {
2438 return {lambda};
2439 }
2440
2447 Eigen::MatrixXcd GetMatrix() const override
2448 {
2449 const QC::Gates::ControlledPhaseShiftGate<> cpgate(lambda);
2450 return cpgate.getRawOperatorMatrix();
2451 }
2452
2453 private:
2454 double lambda;
2455};
2456
2465template <typename Time = Types::time_type> class ControlledRotationGate : public TwoQubitsGate<Time>
2466{
2467 public:
2480 ControlledRotationGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0, Time delay = 0)
2481 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta)
2482 {
2483 }
2484
2491 void SetTheta(double t)
2492 {
2493 theta = t;
2494 }
2495
2502 double GetTheta() const
2503 {
2504 return theta;
2505 }
2506
2513 std::vector<double> GetParams() const override
2514 {
2515 return {theta};
2516 }
2517
2518 private:
2519 double theta;
2520};
2521
2530template <typename Time = Types::time_type> class CRxGate : public CloneableGate<CRxGate, ControlledRotationGate, Time>
2531{
2532 public:
2544 CRxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0, Time delay = 0)
2545 : CloneableGate<CRxGate, Circuits::ControlledRotationGate, Time>(ctrl, target, theta, delay)
2546 {
2547 }
2548
2559 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2560 {
2562 }
2563
2572 {
2574 }
2575
2584 bool IsBranching() const override
2585 {
2586 return true;
2587 }
2588
2595 Eigen::MatrixXcd GetMatrix() const override
2596 {
2597 const QC::Gates::ControlledRxGate<> crxgate(ControlledRotationGate<Time>::GetTheta());
2598 return crxgate.getRawOperatorMatrix();
2599 }
2600};
2601
2610template <typename Time = Types::time_type> class CRyGate : public CloneableGate<CRyGate, ControlledRotationGate, Time>
2611{
2612 public:
2624 CRyGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0, Time delay = 0)
2625 : CloneableGate<CRyGate, Circuits::ControlledRotationGate, Time>(ctrl, target, theta, delay)
2626 {
2627 }
2628
2639 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2640 {
2642 }
2643
2652 {
2654 }
2655
2664 bool IsBranching() const override
2665 {
2666 return true;
2667 }
2668
2675 Eigen::MatrixXcd GetMatrix() const override
2676 {
2677 const QC::Gates::ControlledRyGate<> crygate(ControlledRotationGate<Time>::GetTheta());
2678 return crygate.getRawOperatorMatrix();
2679 }
2680};
2681
2690template <typename Time = Types::time_type> class CRzGate : public CloneableGate<CRzGate, ControlledRotationGate, Time>
2691{
2692 public:
2704 CRzGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0, Time delay = 0)
2705 : CloneableGate<CRzGate, Circuits::ControlledRotationGate, Time>(ctrl, target, theta, delay)
2706 {
2707 }
2708
2719 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2720 {
2722 }
2723
2732 {
2734 }
2735
2742 Eigen::MatrixXcd GetMatrix() const override
2743 {
2744 const QC::Gates::ControlledRzGate<> crzgate(ControlledRotationGate<Time>::GetTheta());
2745 return crzgate.getRawOperatorMatrix();
2746 }
2747};
2748
2757template <typename Time = Types::time_type> class CHGate : public CloneableGate<CHGate, TwoQubitsGate, Time>
2758{
2759 public:
2770 CHGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0) : CloneableGate<CHGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2771 {
2772 }
2773
2784 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2785 {
2787 }
2788
2797 {
2799 }
2800
2809 bool IsBranching() const override
2810 {
2811 return true;
2812 }
2813
2820 Eigen::MatrixXcd GetMatrix() const override
2821 {
2822 static const QC::Gates::ControlledHadamardGate<> chgate;
2823 return chgate.getRawOperatorMatrix();
2824 }
2825};
2826
2835template <typename Time = Types::time_type> class CSxGate : public CloneableGate<CSxGate, TwoQubitsGate, Time>
2836{
2837 public:
2848 CSxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0) : CloneableGate<CSxGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2849 {
2850 }
2851
2862 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2863 {
2865 }
2866
2875 {
2877 }
2878
2887 bool IsBranching() const override
2888 {
2889 return true;
2890 }
2891
2898 Eigen::MatrixXcd GetMatrix() const override
2899 {
2900 static const QC::Gates::ControlledSquareRootNOTGate<> csxgate;
2901 return csxgate.getRawOperatorMatrix();
2902 }
2903};
2904
2913template <typename Time = Types::time_type> class CSxDagGate : public CloneableGate<CSxDagGate, TwoQubitsGate, Time>
2914{
2915 public:
2926 CSxDagGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2927 : CloneableGate<CSxDagGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay)
2928 {
2929 }
2930
2941 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
2942 {
2944 }
2945
2954 {
2956 }
2957
2966 bool IsBranching() const override
2967 {
2968 return true;
2969 }
2970
2977 Eigen::MatrixXcd GetMatrix() const override
2978 {
2979 static const QC::Gates::ControlledSquareRootNOTDagGate<> csxdaggate;
2980 return csxdaggate.getRawOperatorMatrix();
2981 }
2982};
2983
2992template <typename Time = Types::time_type> class CUGate : public CloneableGate<CUGate, TwoQubitsGate, Time>
2993{
2994 public:
3009 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)
3010 : CloneableGate<CUGate, Circuits::TwoQubitsGate, Time>(ctrl, target, delay), theta(theta), phi(phi), lambda(lambda), gamma(gamma)
3011 {
3012 }
3013
3024 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
3025 {
3027 }
3028
3037 {
3039 }
3040
3047 void SetTheta(double t)
3048 {
3049 theta = t;
3050 }
3051
3058 double GetTheta() const
3059 {
3060 return theta;
3061 }
3062
3069 void SetPhi(double p)
3070 {
3071 phi = p;
3072 }
3073
3080 double GetPhi() const
3081 {
3082 return phi;
3083 }
3084
3091 void SetLambda(double l)
3092 {
3093 lambda = l;
3094 }
3095
3102 double GetLambda() const
3103 {
3104 return lambda;
3105 }
3106
3113 void SetGamma(double g)
3114 {
3115 gamma = g;
3116 }
3117
3124 double GetGamma() const
3125 {
3126 return gamma;
3127 }
3128
3135 std::vector<double> GetParams() const override
3136 {
3137 return {theta, phi, lambda, gamma};
3138 }
3139
3148 bool IsBranching() const override
3149 {
3150 return true;
3151 }
3152
3159 Eigen::MatrixXcd GetMatrix() const override
3160 {
3161 const QC::Gates::ControlledUGate<> cugate(theta, phi, lambda, gamma);
3162 return cugate.getRawOperatorMatrix();
3163 }
3164
3165 private:
3166 double theta;
3167 double phi;
3168 double lambda;
3169 double gamma;
3170};
3171
3172//**********************************************************************************************
3173// Three Qubit Gates
3174// those should be replaced by sets of gates with less qubits, to be able to
3175// distribute them
3176//**********************************************************************************************
3177
3186template <typename Time = Types::time_type> class CCXGate : public CloneableGate<CCXGate, ThreeQubitsGate, Time>
3187{
3188 public:
3200 CCXGate(Types::qubit_t ctrl1 = 0, Types::qubit_t ctrl2 = 1, Types::qubit_t target = 2, Time delay = 0)
3201 : CloneableGate<CCXGate, Circuits::ThreeQubitsGate, Time>(ctrl1, ctrl2, target, delay)
3202 {
3203 }
3204
3215 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
3216 {
3218 }
3219
3228 {
3230 }
3231
3238 Eigen::MatrixXcd GetMatrix() const override
3239 {
3240 static const QC::Gates::ToffoliGate<> ccxaggate;
3241 return ccxaggate.getRawOperatorMatrix();
3242 }
3243};
3244
3253template <typename Time = Types::time_type> class CSwapGate : public CloneableGate<CSwapGate, ThreeQubitsGate, Time>
3254{
3255 public:
3267 CSwapGate(Types::qubit_t ctrl = 0, Types::qubit_t target1 = 1, Types::qubit_t target2 = 2, Time delay = 0)
3268 : CloneableGate<CSwapGate, Circuits::ThreeQubitsGate, Time>(ctrl, target1, target2, delay)
3269 {
3270 }
3271
3282 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim, OperationState &state) const override
3283 {
3285 }
3286
3295 {
3297 }
3298
3305 Eigen::MatrixXcd GetMatrix() const override
3306 {
3307 static const QC::Gates::FredkinGate<> cswapgate;
3308 return cswapgate.getRawOperatorMatrix();
3309 }
3310};
3311
3312} // namespace Circuits
3313
3314#endif // !_QUANTUM_GATES_H_
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
CCXGate(Types::qubit_t ctrl1=0, Types::qubit_t ctrl2=1, Types::qubit_t target=2, Time delay=0)
CCXGate 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
bool IsBranching() const override
Checks if the operation is a branching one.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
CRzGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, double theta=0, Time delay=0)
CRzGate constructor.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
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.
CZGate(Types::qubit_t ctrl=0, Types::qubit_t target=1, Time delay=0)
CZGate constructor.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
Implements Clone() once for a concrete gate.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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:711
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 Eigen::MatrixXcd GetMatrix() const =0
Get the matrix representation 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
The state class that stores the classical state of a quantum circuit execution.
Definition Operations.h:68
double GetLambda() const
Get the lambda parameter for the phase 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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
The rotation gate.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
QuantumGateType GetGateType() const override
Get the type of the quantum gate.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
SGate(Types::qubit_t qubit=0, Time delay=0)
SGate constructor.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the quantum gate.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of 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.
The interface for single qubit quantum gates.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum 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.
bool IsClifford() const override
Checks if the operation is a Clifford one.
bool IsBranching() const override
Checks if the operation is a branching one.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
bool IsClifford() const override
Checks if the operation is a Clifford one.
SxDagGate(Types::qubit_t qubit=0, Time delay=0)
SxDagGate 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of 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.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
The interface for three qubits quantum gates.
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.
The interface for two qubits quantum gates.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
void SetPhi(double p)
Set the phi parameter for the gate.
double GetLambda() const
Get the lambda parameter for the gate.
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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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.
bool IsClifford() const override
Checks if the operation is a Clifford one.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation 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.
Eigen::MatrixXcd GetMatrix() const override
Get the matrix representation of the quantum gate.
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:24
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:23