Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QuantumGates.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#ifndef _QUANTUM_GATES_H_
17#define _QUANTUM_GATES_H_
18
19#include "Operations.h"
20
21namespace Circuits {
22
60
70template <typename Time = Types::time_type>
71class IQuantumGate : public IGateOperation<Time> {
72public:
80 IQuantumGate(Time delay = 0) : IGateOperation<Time>(delay) {}
81
89 virtual QuantumGateType GetGateType() const = 0;
90
98 virtual std::vector<double> GetParams() const { return {}; }
99};
100
111template <typename Time = Types::time_type>
112class SingleQubitGate : public IQuantumGate<Time> {
113public:
123 SingleQubitGate(Types::qubit_t qubit = 0, Time delay = 0)
124 : IQuantumGate<Time>(delay), qubit(qubit) {}
125
132 virtual ~SingleQubitGate() {}
133
141 unsigned int GetNumQubits() const override { return 1; }
142
151 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
152 qubit = q;
153 }
154
164 Types::qubit_t GetQubit(unsigned int index = 0) const override {
165 return qubit;
166 }
167
175 Types::qubits_vector AffectedQubits() const override { return {qubit}; }
176
187 std::shared_ptr<IOperation<Time>>
188 Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
189 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
190 const override {
191 auto newGate = this->Clone();
192
193 const auto qubitit = qubitsMap.find(qubit);
194 if (qubitit != qubitsMap.end())
195 std::static_pointer_cast<SingleQubitGate<Time>>(newGate)->SetQubit(
196 qubitit->second);
197 // else throw std::invalid_argument("Qubit not found in qubits map to remap
198 // the gate.");
199
200 return newGate;
201 }
202
203private:
204 Types::qubit_t qubit;
205};
206
216template <typename Time = Types::time_type>
217class TwoQubitsGate : public IQuantumGate<Time> {
218public:
231 Time delay = 0)
232 : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2) {}
233
240 virtual ~TwoQubitsGate() {}
241
249 unsigned int GetNumQubits() const override { return 2; }
250
259 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
260 if (index == 0)
261 qubit1 = q;
262 else if (index == 1)
263 qubit2 = q;
264 }
265
275 Types::qubit_t GetQubit(unsigned int index = 0) const override {
276 if (index == 0)
277 return qubit1;
278 else if (index == 1)
279 return qubit2;
280
281 return UINT_MAX;
282 }
283
291 return {qubit1, qubit2};
292 }
293
304 std::shared_ptr<IOperation<Time>>
305 Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
306 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
307 const override {
308 auto newGate = this->Clone();
309
310 const auto qubitit1 = qubitsMap.find(qubit1);
311 if (qubitit1 != qubitsMap.end())
312 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
313 qubitit1->second, 0);
314
315 const auto qubitit2 = qubitsMap.find(qubit2);
316 if (qubitit2 != qubitsMap.end())
317 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
318 qubitit2->second, 1);
319
320 return newGate;
321 }
322
323private:
324 Types::qubit_t qubit1;
326 qubit2;
327};
328
338template <typename Time = Types::time_type>
339class ThreeQubitsGate : public IQuantumGate<Time> {
340public:
354 Types::qubit_t qubit3 = 0, Time delay = 0)
355 : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2),
356 qubit3(qubit3) {}
357
364 virtual ~ThreeQubitsGate() {}
365
373 unsigned int GetNumQubits() const override { return 3; }
374
383 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
384 if (index == 0)
385 qubit1 = q;
386 else if (index == 1)
387 qubit2 = q;
388 else if (index == 2)
389 qubit3 = q;
390 }
391
401 Types::qubit_t GetQubit(unsigned int index = 0) const override {
402 if (index == 0)
403 return qubit1;
404 else if (index == 1)
405 return qubit2;
406 else if (index == 2)
407 return qubit3;
408
409 return UINT_MAX;
410 }
411
420 return {qubit1, qubit2, qubit3};
421 }
422
433 std::shared_ptr<IOperation<Time>>
434 Remap(const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
435 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
436 const override {
437 auto newGate = this->Clone();
438
439 const auto qubitit1 = qubitsMap.find(qubit1);
440 if (qubitit1 != qubitsMap.end())
441 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
442 qubitit1->second, 0);
443
444 const auto qubitit2 = qubitsMap.find(qubit2);
445 if (qubitit2 != qubitsMap.end())
446 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
447 qubitit2->second, 1);
448
449 const auto qubitit3 = qubitsMap.find(qubit3);
450 if (qubitit3 != qubitsMap.end())
451 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
452 qubitit3->second, 2);
453
454 return newGate;
455 }
456
457private:
458 Types::qubit_t qubit1;
460 qubit2;
461 Types::qubit_t qubit3;
462};
463
464//**********************************************************************************************
465// Single Qubit Gates
466//**********************************************************************************************
467
476template <typename Time = Types::time_type>
477class PhaseGate : public SingleQubitGate<Time> {
478public:
489 PhaseGate(Types::qubit_t qubit = 0, double lambda = 0, Time delay = 0)
490 : SingleQubitGate<Time>(qubit, delay), lambda(lambda) {}
491
502 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
503 OperationState &state) const override {
504 sim->ApplyP(SingleQubitGate<Time>::GetQubit(), lambda);
505 }
506
513 void SetLambda(double l) { lambda = l; }
514
521 double GetLambda() const { return lambda; }
522
530 QuantumGateType GetGateType() const override {
532 }
533
540 std::shared_ptr<IOperation<Time>> Clone() const override {
541 return std::make_shared<PhaseGate<Time>>(SingleQubitGate<Time>::GetQubit(),
542 lambda,
544 }
545
552 std::vector<double> GetParams() const override { return {lambda}; }
553
563 bool IsClifford() const override {
564 if (std::abs(lambda - M_PI_2) > 1e-10)
565 return false;
566
567 return true;
568 }
569
570private:
571 double lambda;
572};
573
582template <typename Time = Types::time_type>
583class XGate : public SingleQubitGate<Time> {
584public:
594 XGate(Types::qubit_t qubit = 0, Time delay = 0)
595 : SingleQubitGate<Time>(qubit, delay) {}
596
607 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
608 OperationState &state) const override {
609 sim->ApplyX(SingleQubitGate<Time>::GetQubit());
610 }
611
619 QuantumGateType GetGateType() const override {
621 }
622
629 std::shared_ptr<IOperation<Time>> Clone() const override {
630 return std::make_shared<XGate<Time>>(SingleQubitGate<Time>::GetQubit(),
632 }
633
643 bool IsClifford() const override { return true; }
644};
645
654template <typename Time = Types::time_type>
655class YGate : public SingleQubitGate<Time> {
656public:
666 YGate(Types::qubit_t qubit = 0, Time delay = 0)
667 : SingleQubitGate<Time>(qubit, delay) {}
668
679 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
680 OperationState &state) const override {
681 sim->ApplyY(SingleQubitGate<Time>::GetQubit());
682 }
683
691 QuantumGateType GetGateType() const override {
693 }
694
701 std::shared_ptr<IOperation<Time>> Clone() const override {
702 return std::make_shared<YGate<Time>>(SingleQubitGate<Time>::GetQubit(),
704 }
705
715 bool IsClifford() const override { return true; }
716};
717
726template <typename Time = Types::time_type>
727class ZGate : public SingleQubitGate<Time> {
728public:
738 ZGate(Types::qubit_t qubit = 0, Time delay = 0)
739 : SingleQubitGate<Time>(qubit, delay) {}
740
751 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
752 OperationState &state) const override {
753 sim->ApplyZ(SingleQubitGate<Time>::GetQubit());
754 }
755
763 QuantumGateType GetGateType() const override {
765 }
766
773 std::shared_ptr<IOperation<Time>> Clone() const override {
774 return std::make_shared<ZGate<Time>>(SingleQubitGate<Time>::GetQubit(),
776 }
777
787 bool IsClifford() const override { return true; }
788};
789
798template <typename Time = Types::time_type>
799class HadamardGate : public SingleQubitGate<Time> {
800public:
810 HadamardGate(Types::qubit_t qubit = 0, Time delay = 0)
811 : SingleQubitGate<Time>(qubit, delay) {}
812
823 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
824 OperationState &state) const override {
825 sim->ApplyH(SingleQubitGate<Time>::GetQubit());
826 }
827
838
845 std::shared_ptr<IOperation<Time>> Clone() const override {
846 return std::make_shared<HadamardGate<Time>>(
848 }
849
859 bool IsClifford() const override { return true; }
860};
861
870template <typename Time = Types::time_type>
871class SGate : public SingleQubitGate<Time> {
872public:
882 SGate(Types::qubit_t qubit = 0, Time delay = 0)
883 : SingleQubitGate<Time>(qubit, delay) {}
884
895 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
896 OperationState &state) const override {
897 sim->ApplyS(SingleQubitGate<Time>::GetQubit());
898 }
899
907 QuantumGateType GetGateType() const override {
909 }
910
917 std::shared_ptr<IOperation<Time>> Clone() const override {
918 return std::make_shared<SGate<Time>>(SingleQubitGate<Time>::GetQubit(),
920 }
921
931 bool IsClifford() const override { return true; }
932};
933
942template <typename Time = Types::time_type>
943class SdgGate : public SingleQubitGate<Time> {
944public:
954 SdgGate(Types::qubit_t qubit = 0, Time delay = 0)
955 : SingleQubitGate<Time>(qubit, delay) {}
956
967 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
968 OperationState &state) const override {
969 sim->ApplySDG(SingleQubitGate<Time>::GetQubit());
970 }
971
979 QuantumGateType GetGateType() const override {
981 }
982
989 std::shared_ptr<IOperation<Time>> Clone() const override {
990 return std::make_shared<SdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
992 }
993
1003 bool IsClifford() const override { return true; }
1004};
1005
1014template <typename Time = Types::time_type>
1015class TGate : public SingleQubitGate<Time> {
1016public:
1026 TGate(Types::qubit_t qubit = 0, Time delay = 0)
1027 : SingleQubitGate<Time>(qubit, delay) {}
1028
1039 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1040 OperationState &state) const override {
1041 sim->ApplyT(SingleQubitGate<Time>::GetQubit());
1042 }
1043
1051 QuantumGateType GetGateType() const override {
1053 }
1054
1061 std::shared_ptr<IOperation<Time>> Clone() const override {
1062 return std::make_shared<TGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1064 }
1065};
1066
1075template <typename Time = Types::time_type>
1076class TdgGate : public SingleQubitGate<Time> {
1077public:
1087 TdgGate(Types::qubit_t qubit = 0, Time delay = 0)
1088 : SingleQubitGate<Time>(qubit, delay) {}
1089
1100 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1101 OperationState &state) const override {
1102 sim->ApplyTDG(SingleQubitGate<Time>::GetQubit());
1103 }
1104
1112 QuantumGateType GetGateType() const override {
1114 }
1115
1122 std::shared_ptr<IOperation<Time>> Clone() const override {
1123 return std::make_shared<TdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1125 }
1126};
1127
1136template <typename Time = Types::time_type>
1137class SxGate : public SingleQubitGate<Time> {
1138public:
1148 SxGate(Types::qubit_t qubit = 0, Time delay = 0)
1149 : SingleQubitGate<Time>(qubit, delay) {}
1150
1161 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1162 OperationState &state) const override {
1163 sim->ApplySx(SingleQubitGate<Time>::GetQubit());
1164 }
1165
1173 QuantumGateType GetGateType() const override {
1175 }
1176
1183 std::shared_ptr<IOperation<Time>> Clone() const override {
1184 return std::make_shared<SxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1186 }
1187
1197 bool IsClifford() const override { return true; }
1198};
1199
1208template <typename Time = Types::time_type>
1209class SxDagGate : public SingleQubitGate<Time> {
1210public:
1220 SxDagGate(Types::qubit_t qubit = 0, Time delay = 0)
1221 : SingleQubitGate<Time>(qubit, delay) {}
1222
1233 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1234 OperationState &state) const override {
1235 sim->ApplySxDAG(SingleQubitGate<Time>::GetQubit());
1236 }
1237
1245 QuantumGateType GetGateType() const override {
1247 }
1248
1255 std::shared_ptr<IOperation<Time>> Clone() const override {
1256 return std::make_shared<SxDagGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1258 }
1259
1269 bool IsClifford() const override { return true; }
1270};
1271
1280template <typename Time = Types::time_type>
1281class KGate : public SingleQubitGate<Time> {
1282public:
1292 KGate(Types::qubit_t qubit = 0, Time delay = 0)
1293 : SingleQubitGate<Time>(qubit, delay) {}
1294
1305 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1306 OperationState &state) const override {
1307 sim->ApplyK(SingleQubitGate<Time>::GetQubit());
1308 }
1309
1317 QuantumGateType GetGateType() const override {
1319 }
1320
1327 std::shared_ptr<IOperation<Time>> Clone() const override {
1328 return std::make_shared<KGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1330 }
1331
1341 bool IsClifford() const override { return true; }
1342};
1343
1352template <typename Time = Types::time_type>
1353class RotationGate : public SingleQubitGate<Time> {
1354public:
1366 RotationGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1367 : SingleQubitGate<Time>(qubit, delay), theta(theta) {}
1368
1375 void SetTheta(double t) { theta = t; }
1376
1383 double GetTheta() const { return theta; }
1384
1391 std::vector<double> GetParams() const override { return {theta}; }
1392
1393private:
1394 double theta;
1395};
1396
1406template <typename Time = Types::time_type>
1407class RxGate : public RotationGate<Time> {
1408public:
1419 RxGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1420 : RotationGate<Time>(qubit, theta, delay) {}
1421
1432 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1433 OperationState &state) const override {
1434 sim->ApplyRx(SingleQubitGate<Time>::GetQubit(),
1436 }
1437
1445 QuantumGateType GetGateType() const override {
1447 }
1448
1455 std::shared_ptr<IOperation<Time>> Clone() const override {
1456 return std::make_shared<RxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1459 }
1460};
1461
1471template <typename Time = Types::time_type>
1472class RyGate : public RotationGate<Time> {
1473public:
1484 RyGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1485 : RotationGate<Time>(qubit, theta, delay) {}
1486
1497 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1498 OperationState &state) const override {
1499 sim->ApplyRy(SingleQubitGate<Time>::GetQubit(),
1501 }
1502
1510 QuantumGateType GetGateType() const override {
1512 }
1513
1520 std::shared_ptr<IOperation<Time>> Clone() const override {
1521 return std::make_shared<RyGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1524 }
1525};
1526
1536template <typename Time = Types::time_type>
1537class RzGate : public RotationGate<Time> {
1538public:
1549 RzGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1550 : RotationGate<Time>(qubit, theta, delay) {}
1551
1562 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1563 OperationState &state) const override {
1564 sim->ApplyRz(SingleQubitGate<Time>::GetQubit(),
1566 }
1567
1575 QuantumGateType GetGateType() const override {
1577 }
1578
1585 std::shared_ptr<IOperation<Time>> Clone() const override {
1586 return std::make_shared<RzGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1589 }
1590};
1591
1600template <typename Time = Types::time_type>
1601class UGate : public SingleQubitGate<Time> {
1602public:
1613 UGate(Types::qubit_t qubit = 0, double theta = 0, double phi = 0,
1614 double lambda = 0, double gamma = 0, Time delay = 0)
1615 : SingleQubitGate<Time>(qubit, delay), theta(theta), phi(phi),
1616 lambda(lambda), gamma(gamma) {}
1617
1628 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1629 OperationState &state) const override {
1630 sim->ApplyU(SingleQubitGate<Time>::GetQubit(), theta, phi, lambda, gamma);
1631 }
1632
1640 QuantumGateType GetGateType() const override {
1642 }
1643
1650 std::shared_ptr<IOperation<Time>> Clone() const override {
1651 return std::make_shared<UGate<Time>>(
1654 }
1655
1662 void SetTheta(double t) { theta = t; }
1663
1670 double GetTheta() const { return theta; }
1671
1678 void SetPhi(double p) { phi = p; }
1679
1686 double GetPhi() const { return phi; }
1687
1694 void SetLambda(double l) { lambda = l; }
1695
1702 double GetLambda() const { return lambda; }
1703
1710 void SetGamma(double g) { gamma = g; }
1711
1718 double GetGamma() const { return gamma; }
1719
1726 std::vector<double> GetParams() const override {
1727 return {theta, phi, lambda, gamma};
1728 }
1729
1739 bool IsClifford() const override { return false; }
1740
1741private:
1742 double theta;
1743 double phi;
1744 double lambda;
1745 double gamma;
1746};
1747
1748//**********************************************************************************************
1749// Two Qubit Gates
1750//**********************************************************************************************
1751
1752// this one should be replaced - for example with three qnots - to be able to
1753// distribute it
1754
1763template <typename Time = Types::time_type>
1764class SwapGate : public TwoQubitsGate<Time> {
1765public:
1776 SwapGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 1, Time delay = 0)
1777 : TwoQubitsGate<Time>(qubit1, qubit2, delay) {}
1778
1789 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1790 OperationState &state) const override {
1791 sim->ApplySwap(TwoQubitsGate<Time>::GetQubit(0),
1793 }
1794
1802 QuantumGateType GetGateType() const override {
1804 }
1805
1812 std::shared_ptr<IOperation<Time>> Clone() const override {
1813 return std::make_shared<SwapGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1816 }
1817
1827 bool IsClifford() const override { return true; }
1828};
1829
1830// the others are all controlled gates
1831
1840template <typename Time = Types::time_type>
1841class CXGate : public TwoQubitsGate<Time> {
1842public:
1853 CXGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1854 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1855
1866 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1867 OperationState &state) const override {
1868 sim->ApplyCX(TwoQubitsGate<Time>::GetQubit(0),
1870 }
1871
1879 QuantumGateType GetGateType() const override {
1881 }
1882
1889 std::shared_ptr<IOperation<Time>> Clone() const override {
1890 return std::make_shared<CXGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1893 }
1894
1904 bool IsClifford() const override { return true; }
1905};
1906
1915template <typename Time = Types::time_type>
1916class CYGate : public TwoQubitsGate<Time> {
1917public:
1928 CYGate(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->ApplyCY(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<CYGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1968 }
1969
1979 bool IsClifford() const override { return true; }
1980};
1981
1990template <typename Time = Types::time_type>
1991class CZGate : public TwoQubitsGate<Time> {
1992public:
2003 CZGate(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->ApplyCZ(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<CZGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2043 }
2044
2054 bool IsClifford() const override { return true; }
2055};
2056
2065template <typename Time = Types::time_type>
2066class CPGate : public TwoQubitsGate<Time> {
2067public:
2079 CPGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double lambda = 0,
2080 Time delay = 0)
2081 : TwoQubitsGate<Time>(ctrl, target, delay), lambda(lambda) {}
2082
2093 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2094 OperationState &state) const override {
2095 sim->ApplyCP(TwoQubitsGate<Time>::GetQubit(0),
2097 }
2098
2105 void SetLambda(double l) { lambda = l; }
2106
2113 double GetLambda() const { return lambda; }
2114
2122 QuantumGateType GetGateType() const override {
2124 }
2125
2132 std::shared_ptr<IOperation<Time>> Clone() const override {
2133 return std::make_shared<CPGate<Time>>(
2136 }
2137
2144 std::vector<double> GetParams() const override { return {lambda}; }
2145
2146private:
2147 double lambda;
2148};
2149
2158template <typename Time = Types::time_type>
2160public:
2174 double theta = 0, Time delay = 0)
2175 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta) {}
2176
2183 void SetTheta(double t) { theta = t; }
2184
2191 double GetTheta() const { return theta; }
2192
2199 std::vector<double> GetParams() const override { return {theta}; }
2200
2201private:
2202 double theta;
2203};
2204
2213template <typename Time = Types::time_type>
2214class CRxGate : public ControlledRotationGate<Time> {
2215public:
2227 CRxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2228 Time delay = 0)
2229 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2230
2241 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2242 OperationState &state) const override {
2243 sim->ApplyCRx(TwoQubitsGate<Time>::GetQubit(0),
2246 }
2247
2255 QuantumGateType GetGateType() const override {
2257 }
2258
2265 std::shared_ptr<IOperation<Time>> Clone() const override {
2266 return std::make_shared<CRxGate<Time>>(
2269 }
2270};
2271
2280template <typename Time = Types::time_type>
2281class CRyGate : public ControlledRotationGate<Time> {
2282public:
2294 CRyGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2295 Time delay = 0)
2296 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2297
2308 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2309 OperationState &state) const override {
2310 sim->ApplyCRy(TwoQubitsGate<Time>::GetQubit(0),
2313 }
2314
2322 QuantumGateType GetGateType() const override {
2324 }
2325
2332 std::shared_ptr<IOperation<Time>> Clone() const override {
2333 return std::make_shared<CRyGate<Time>>(
2336 }
2337};
2338
2347template <typename Time = Types::time_type>
2348class CRzGate : public ControlledRotationGate<Time> {
2349public:
2361 CRzGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2362 Time delay = 0)
2363 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2364
2375 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2376 OperationState &state) const override {
2377 sim->ApplyCRz(TwoQubitsGate<Time>::GetQubit(0),
2380 }
2381
2389 QuantumGateType GetGateType() const override {
2391 }
2392
2399 std::shared_ptr<IOperation<Time>> Clone() const override {
2400 return std::make_shared<CRzGate<Time>>(
2403 }
2404};
2405
2414template <typename Time = Types::time_type>
2415class CHGate : public TwoQubitsGate<Time> {
2416public:
2427 CHGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2428 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2429
2440 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2441 OperationState &state) const override {
2442 sim->ApplyCH(TwoQubitsGate<Time>::GetQubit(0),
2444 }
2445
2453 QuantumGateType GetGateType() const override {
2455 }
2456
2463 std::shared_ptr<IOperation<Time>> Clone() const override {
2464 return std::make_shared<CHGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2467 }
2468};
2469
2478template <typename Time = Types::time_type>
2479class CSxGate : public TwoQubitsGate<Time> {
2480public:
2491 CSxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2492 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2493
2504 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2505 OperationState &state) const override {
2506 sim->ApplyCSx(TwoQubitsGate<Time>::GetQubit(0),
2508 }
2509
2517 QuantumGateType GetGateType() const override {
2519 }
2520
2527 std::shared_ptr<IOperation<Time>> Clone() const override {
2528 return std::make_shared<CSxGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2531 }
2532};
2533
2542template <typename Time = Types::time_type>
2543class CSxDagGate : public TwoQubitsGate<Time> {
2544public:
2555 CSxDagGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2556 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2557
2568 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2569 OperationState &state) const override {
2570 sim->ApplyCSxDAG(TwoQubitsGate<Time>::GetQubit(0),
2572 }
2573
2581 QuantumGateType GetGateType() const override {
2583 }
2584
2591 std::shared_ptr<IOperation<Time>> Clone() const override {
2592 return std::make_shared<CSxDagGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2595 }
2596};
2597
2606template <typename Time = Types::time_type>
2607class CUGate : public TwoQubitsGate<Time> {
2608public:
2623 CUGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2624 double phi = 0, double lambda = 0, double gamma = 0, Time delay = 0)
2625 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta), phi(phi),
2626 lambda(lambda), gamma(gamma) {}
2627
2638 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2639 OperationState &state) const override {
2640 sim->ApplyCU(TwoQubitsGate<Time>::GetQubit(0),
2642 GetLambda(), GetGamma());
2643 }
2644
2652 QuantumGateType GetGateType() const override {
2654 }
2655
2662 void SetTheta(double t) { theta = t; }
2663
2670 double GetTheta() const { return theta; }
2671
2678 void SetPhi(double p) { phi = p; }
2679
2686 double GetPhi() const { return phi; }
2687
2694 void SetLambda(double l) { lambda = l; }
2695
2702 double GetLambda() const { return lambda; }
2703
2710 void SetGamma(double g) { gamma = g; }
2711
2718 double GetGamma() const { return gamma; }
2719
2726 std::shared_ptr<IOperation<Time>> Clone() const override {
2727 return std::make_shared<CUGate<Time>>(
2729 GetTheta(), GetPhi(), GetLambda(), GetGamma(),
2731 }
2732
2739 std::vector<double> GetParams() const override {
2740 return {theta, phi, lambda, gamma};
2741 }
2742
2743private:
2744 double theta;
2745 double phi;
2746 double lambda;
2747 double gamma;
2748};
2749
2750//**********************************************************************************************
2751// Three Qubit Gates
2752// those should be replaced by sets of gates with less qubits, to be able to
2753// distribute them
2754//**********************************************************************************************
2755
2764template <typename Time = Types::time_type>
2765class CCXGate : public ThreeQubitsGate<Time> {
2766public:
2779 Types::qubit_t target = 2, Time delay = 0)
2780 : ThreeQubitsGate<Time>(ctrl1, ctrl2, target, delay) {}
2781
2792 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2793 OperationState &state) const override {
2794 sim->ApplyCCX(ThreeQubitsGate<Time>::GetQubit(0),
2797 }
2798
2806 QuantumGateType GetGateType() const override {
2808 }
2809
2816 std::shared_ptr<IOperation<Time>> Clone() const override {
2817 return std::make_shared<CCXGate<Time>>(
2820 }
2821};
2822
2831template <typename Time = Types::time_type>
2832class CSwapGate : public ThreeQubitsGate<Time> {
2833public:
2846 Types::qubit_t target2 = 2, Time delay = 0)
2847 : ThreeQubitsGate<Time>(ctrl, target1, target2, delay) {}
2848
2859 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2860 OperationState &state) const override {
2861 sim->ApplyCSwap(ThreeQubitsGate<Time>::GetQubit(0),
2864 }
2865
2873 QuantumGateType GetGateType() const override {
2875 }
2876
2883 std::shared_ptr<IOperation<Time>> Clone() const override {
2884 return std::make_shared<CSwapGate<Time>>(
2887 }
2888};
2889} // namespace Circuits
2890
2891#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.
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.
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.
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.
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.
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.
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 IsClifford() const override
Checks if the operation is a Clifford one.
IGateOperation(Types::time_type delay=0)
Definition Operations.h:615
Time GetDelay() const
Get the delay of the operation.
Definition Operations.h:500
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.
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:62
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.
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.
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 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.
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.
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:21
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:20