Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QuantumGates.h
Go to the documentation of this file.
1
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> {
72 public:
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> {
113 public:
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>> Remap(
188 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
203 private:
204 Types::qubit_t qubit;
205};
206
216template <typename Time = Types::time_type>
217class TwoQubitsGate : public IQuantumGate<Time> {
218 public:
230 TwoQubitsGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 0,
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
290 Types::qubits_vector AffectedQubits() const override {
291 return {qubit1, qubit2};
292 }
293
304 std::shared_ptr<IOperation<Time>> Remap(
305 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
323 private:
324 Types::qubit_t qubit1;
325 Types::qubit_t
326 qubit2;
327};
328
338template <typename Time = Types::time_type>
339class ThreeQubitsGate : public IQuantumGate<Time> {
340 public:
353 ThreeQubitsGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 0,
354 Types::qubit_t qubit3 = 0, Time delay = 0)
355 : IQuantumGate<Time>(delay),
356 qubit1(qubit1),
357 qubit2(qubit2),
358 qubit3(qubit3) {}
359
366 virtual ~ThreeQubitsGate() {}
367
375 unsigned int GetNumQubits() const override { return 3; }
376
385 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
386 if (index == 0)
387 qubit1 = q;
388 else if (index == 1)
389 qubit2 = q;
390 else if (index == 2)
391 qubit3 = q;
392 }
393
403 Types::qubit_t GetQubit(unsigned int index = 0) const override {
404 if (index == 0)
405 return qubit1;
406 else if (index == 1)
407 return qubit2;
408 else if (index == 2)
409 return qubit3;
410
411 return UINT_MAX;
412 }
413
421 Types::qubits_vector AffectedQubits() const override {
422 return {qubit1, qubit2, qubit3};
423 }
424
435 std::shared_ptr<IOperation<Time>> Remap(
436 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
437 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
438 const override {
439 auto newGate = this->Clone();
440
441 const auto qubitit1 = qubitsMap.find(qubit1);
442 if (qubitit1 != qubitsMap.end())
443 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
444 qubitit1->second, 0);
445
446 const auto qubitit2 = qubitsMap.find(qubit2);
447 if (qubitit2 != qubitsMap.end())
448 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
449 qubitit2->second, 1);
450
451 const auto qubitit3 = qubitsMap.find(qubit3);
452 if (qubitit3 != qubitsMap.end())
453 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
454 qubitit3->second, 2);
455
456 return newGate;
457 }
458
459 private:
460 Types::qubit_t qubit1;
461 Types::qubit_t
462 qubit2;
463 Types::qubit_t qubit3;
464};
465
466//**********************************************************************************************
467// Single Qubit Gates
468//**********************************************************************************************
469
478template <typename Time = Types::time_type>
479class PhaseGate : public SingleQubitGate<Time> {
480 public:
491 PhaseGate(Types::qubit_t qubit = 0, double lambda = 0, Time delay = 0)
492 : SingleQubitGate<Time>(qubit, delay), lambda(lambda) {}
493
504 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
505 OperationState &state) const override {
506 sim->ApplyP(SingleQubitGate<Time>::GetQubit(), lambda);
507 }
508
515 void SetLambda(double l) { lambda = l; }
516
523 double GetLambda() const { return lambda; }
524
532 QuantumGateType GetGateType() const override {
534 }
535
542 std::shared_ptr<IOperation<Time>> Clone() const override {
543 return std::make_shared<PhaseGate<Time>>(SingleQubitGate<Time>::GetQubit(),
544 lambda,
546 }
547
554 std::vector<double> GetParams() const override { return {lambda}; }
555
565 bool IsClifford() const override {
566 if (std::abs(lambda - M_PI_2) > 1e-10) return false;
567
568 return true;
569 }
570
571 private:
572 double lambda;
573};
574
583template <typename Time = Types::time_type>
584class XGate : public SingleQubitGate<Time> {
585 public:
595 XGate(Types::qubit_t qubit = 0, Time delay = 0)
596 : SingleQubitGate<Time>(qubit, delay) {}
597
608 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
609 OperationState &state) const override {
610 sim->ApplyX(SingleQubitGate<Time>::GetQubit());
611 }
612
620 QuantumGateType GetGateType() const override {
622 }
623
630 std::shared_ptr<IOperation<Time>> Clone() const override {
631 return std::make_shared<XGate<Time>>(SingleQubitGate<Time>::GetQubit(),
633 }
634
644 bool IsClifford() const override { return true; }
645};
646
655template <typename Time = Types::time_type>
656class YGate : public SingleQubitGate<Time> {
657 public:
667 YGate(Types::qubit_t qubit = 0, Time delay = 0)
668 : SingleQubitGate<Time>(qubit, delay) {}
669
680 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
681 OperationState &state) const override {
682 sim->ApplyY(SingleQubitGate<Time>::GetQubit());
683 }
684
692 QuantumGateType GetGateType() const override {
694 }
695
702 std::shared_ptr<IOperation<Time>> Clone() const override {
703 return std::make_shared<YGate<Time>>(SingleQubitGate<Time>::GetQubit(),
705 }
706
716 bool IsClifford() const override { return true; }
717};
718
727template <typename Time = Types::time_type>
728class ZGate : public SingleQubitGate<Time> {
729 public:
739 ZGate(Types::qubit_t qubit = 0, Time delay = 0)
740 : SingleQubitGate<Time>(qubit, delay) {}
741
752 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
753 OperationState &state) const override {
754 sim->ApplyZ(SingleQubitGate<Time>::GetQubit());
755 }
756
764 QuantumGateType GetGateType() const override {
766 }
767
774 std::shared_ptr<IOperation<Time>> Clone() const override {
775 return std::make_shared<ZGate<Time>>(SingleQubitGate<Time>::GetQubit(),
777 }
778
788 bool IsClifford() const override { return true; }
789};
790
799template <typename Time = Types::time_type>
800class HadamardGate : public SingleQubitGate<Time> {
801 public:
811 HadamardGate(Types::qubit_t qubit = 0, Time delay = 0)
812 : SingleQubitGate<Time>(qubit, delay) {}
813
824 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
825 OperationState &state) const override {
826 sim->ApplyH(SingleQubitGate<Time>::GetQubit());
827 }
828
839
846 std::shared_ptr<IOperation<Time>> Clone() const override {
847 return std::make_shared<HadamardGate<Time>>(
849 }
850
860 bool IsClifford() const override { return true; }
861};
862
871template <typename Time = Types::time_type>
872class SGate : public SingleQubitGate<Time> {
873 public:
883 SGate(Types::qubit_t qubit = 0, Time delay = 0)
884 : SingleQubitGate<Time>(qubit, delay) {}
885
896 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
897 OperationState &state) const override {
898 sim->ApplyS(SingleQubitGate<Time>::GetQubit());
899 }
900
908 QuantumGateType GetGateType() const override {
910 }
911
918 std::shared_ptr<IOperation<Time>> Clone() const override {
919 return std::make_shared<SGate<Time>>(SingleQubitGate<Time>::GetQubit(),
921 }
922
932 bool IsClifford() const override { return true; }
933};
934
943template <typename Time = Types::time_type>
944class SdgGate : public SingleQubitGate<Time> {
945 public:
955 SdgGate(Types::qubit_t qubit = 0, Time delay = 0)
956 : SingleQubitGate<Time>(qubit, delay) {}
957
968 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
969 OperationState &state) const override {
970 sim->ApplySDG(SingleQubitGate<Time>::GetQubit());
971 }
972
980 QuantumGateType GetGateType() const override {
982 }
983
990 std::shared_ptr<IOperation<Time>> Clone() const override {
991 return std::make_shared<SdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
993 }
994
1004 bool IsClifford() const override { return true; }
1005};
1006
1015template <typename Time = Types::time_type>
1016class TGate : public SingleQubitGate<Time> {
1017 public:
1027 TGate(Types::qubit_t qubit = 0, Time delay = 0)
1028 : SingleQubitGate<Time>(qubit, delay) {}
1029
1040 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1041 OperationState &state) const override {
1042 sim->ApplyT(SingleQubitGate<Time>::GetQubit());
1043 }
1044
1052 QuantumGateType GetGateType() const override {
1054 }
1055
1062 std::shared_ptr<IOperation<Time>> Clone() const override {
1063 return std::make_shared<TGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1065 }
1066};
1067
1076template <typename Time = Types::time_type>
1077class TdgGate : public SingleQubitGate<Time> {
1078 public:
1088 TdgGate(Types::qubit_t qubit = 0, Time delay = 0)
1089 : SingleQubitGate<Time>(qubit, delay) {}
1090
1101 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1102 OperationState &state) const override {
1103 sim->ApplyTDG(SingleQubitGate<Time>::GetQubit());
1104 }
1105
1113 QuantumGateType GetGateType() const override {
1115 }
1116
1123 std::shared_ptr<IOperation<Time>> Clone() const override {
1124 return std::make_shared<TdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1126 }
1127};
1128
1137template <typename Time = Types::time_type>
1138class SxGate : public SingleQubitGate<Time> {
1139 public:
1149 SxGate(Types::qubit_t qubit = 0, Time delay = 0)
1150 : SingleQubitGate<Time>(qubit, delay) {}
1151
1162 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1163 OperationState &state) const override {
1164 sim->ApplySx(SingleQubitGate<Time>::GetQubit());
1165 }
1166
1174 QuantumGateType GetGateType() const override {
1176 }
1177
1184 std::shared_ptr<IOperation<Time>> Clone() const override {
1185 return std::make_shared<SxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1187 }
1188
1198 bool IsClifford() const override { return true; }
1199};
1200
1209template <typename Time = Types::time_type>
1210class SxDagGate : public SingleQubitGate<Time> {
1211 public:
1221 SxDagGate(Types::qubit_t qubit = 0, Time delay = 0)
1222 : SingleQubitGate<Time>(qubit, delay) {}
1223
1234 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1235 OperationState &state) const override {
1236 sim->ApplySxDAG(SingleQubitGate<Time>::GetQubit());
1237 }
1238
1246 QuantumGateType GetGateType() const override {
1248 }
1249
1256 std::shared_ptr<IOperation<Time>> Clone() const override {
1257 return std::make_shared<SxDagGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1259 }
1260
1270 bool IsClifford() const override { return true; }
1271};
1272
1281template <typename Time = Types::time_type>
1282class KGate : public SingleQubitGate<Time> {
1283 public:
1293 KGate(Types::qubit_t qubit = 0, Time delay = 0)
1294 : SingleQubitGate<Time>(qubit, delay) {}
1295
1306 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1307 OperationState &state) const override {
1308 sim->ApplyK(SingleQubitGate<Time>::GetQubit());
1309 }
1310
1318 QuantumGateType GetGateType() const override {
1320 }
1321
1328 std::shared_ptr<IOperation<Time>> Clone() const override {
1329 return std::make_shared<KGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1331 }
1332
1342 bool IsClifford() const override { return true; }
1343};
1344
1353template <typename Time = Types::time_type>
1354class RotationGate : public SingleQubitGate<Time> {
1355 public:
1367 RotationGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1368 : SingleQubitGate<Time>(qubit, delay), theta(theta) {}
1369
1376 void SetTheta(double t) { theta = t; }
1377
1384 double GetTheta() const { return theta; }
1385
1392 std::vector<double> GetParams() const override { return {theta}; }
1393
1394 private:
1395 double theta;
1396};
1397
1407template <typename Time = Types::time_type>
1408class RxGate : public RotationGate<Time> {
1409 public:
1420 RxGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1421 : RotationGate<Time>(qubit, theta, delay) {}
1422
1433 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1434 OperationState &state) const override {
1435 sim->ApplyRx(SingleQubitGate<Time>::GetQubit(),
1437 }
1438
1446 QuantumGateType GetGateType() const override {
1448 }
1449
1456 std::shared_ptr<IOperation<Time>> Clone() const override {
1457 return std::make_shared<RxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1460 }
1461};
1462
1472template <typename Time = Types::time_type>
1473class RyGate : public RotationGate<Time> {
1474 public:
1485 RyGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1486 : RotationGate<Time>(qubit, theta, delay) {}
1487
1498 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1499 OperationState &state) const override {
1500 sim->ApplyRy(SingleQubitGate<Time>::GetQubit(),
1502 }
1503
1511 QuantumGateType GetGateType() const override {
1513 }
1514
1521 std::shared_ptr<IOperation<Time>> Clone() const override {
1522 return std::make_shared<RyGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1525 }
1526};
1527
1537template <typename Time = Types::time_type>
1538class RzGate : public RotationGate<Time> {
1539 public:
1550 RzGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1551 : RotationGate<Time>(qubit, theta, delay) {}
1552
1563 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1564 OperationState &state) const override {
1565 sim->ApplyRz(SingleQubitGate<Time>::GetQubit(),
1567 }
1568
1576 QuantumGateType GetGateType() const override {
1578 }
1579
1586 std::shared_ptr<IOperation<Time>> Clone() const override {
1587 return std::make_shared<RzGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1590 }
1591};
1592
1601template <typename Time = Types::time_type>
1602class UGate : public SingleQubitGate<Time> {
1603 public:
1614 UGate(Types::qubit_t qubit = 0, double theta = 0, double phi = 0,
1615 double lambda = 0, double gamma = 0, Time delay = 0)
1616 : SingleQubitGate<Time>(qubit, delay),
1617 theta(theta),
1618 phi(phi),
1619 lambda(lambda),
1620 gamma(gamma) {}
1621
1632 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1633 OperationState &state) const override {
1634 sim->ApplyU(SingleQubitGate<Time>::GetQubit(), theta, phi, lambda, gamma);
1635 }
1636
1644 QuantumGateType GetGateType() const override {
1646 }
1647
1654 std::shared_ptr<IOperation<Time>> Clone() const override {
1655 return std::make_shared<UGate<Time>>(
1658 }
1659
1666 void SetTheta(double t) { theta = t; }
1667
1674 double GetTheta() const { return theta; }
1675
1682 void SetPhi(double p) { phi = p; }
1683
1690 double GetPhi() const { return phi; }
1691
1698 void SetLambda(double l) { lambda = l; }
1699
1706 double GetLambda() const { return lambda; }
1707
1714 void SetGamma(double g) { gamma = g; }
1715
1722 double GetGamma() const { return gamma; }
1723
1730 std::vector<double> GetParams() const override {
1731 return {theta, phi, lambda, gamma};
1732 }
1733
1743 bool IsClifford() const override { return false; }
1744
1745 private:
1746 double theta;
1747 double phi;
1748 double lambda;
1749 double gamma;
1750};
1751
1752//**********************************************************************************************
1753// Two Qubit Gates
1754//**********************************************************************************************
1755
1756// this one should be replaced - for example with three qnots - to be able to
1757// distribute it
1758
1767template <typename Time = Types::time_type>
1768class SwapGate : public TwoQubitsGate<Time> {
1769 public:
1780 SwapGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 1, Time delay = 0)
1781 : TwoQubitsGate<Time>(qubit1, qubit2, delay) {}
1782
1793 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1794 OperationState &state) const override {
1795 sim->ApplySwap(TwoQubitsGate<Time>::GetQubit(0),
1797 }
1798
1806 QuantumGateType GetGateType() const override {
1808 }
1809
1816 std::shared_ptr<IOperation<Time>> Clone() const override {
1817 return std::make_shared<SwapGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1820 }
1821
1831 bool IsClifford() const override { return true; }
1832};
1833
1834// the others are all controlled gates
1835
1844template <typename Time = Types::time_type>
1845class CXGate : public TwoQubitsGate<Time> {
1846 public:
1857 CXGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1858 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1859
1870 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1871 OperationState &state) const override {
1872 sim->ApplyCX(TwoQubitsGate<Time>::GetQubit(0),
1874 }
1875
1883 QuantumGateType GetGateType() const override {
1885 }
1886
1893 std::shared_ptr<IOperation<Time>> Clone() const override {
1894 return std::make_shared<CXGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1897 }
1898
1908 bool IsClifford() const override { return true; }
1909};
1910
1919template <typename Time = Types::time_type>
1920class CYGate : public TwoQubitsGate<Time> {
1921 public:
1932 CYGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1933 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1934
1945 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1946 OperationState &state) const override {
1947 sim->ApplyCY(TwoQubitsGate<Time>::GetQubit(0),
1949 }
1950
1958 QuantumGateType GetGateType() const override {
1960 }
1961
1968 std::shared_ptr<IOperation<Time>> Clone() const override {
1969 return std::make_shared<CYGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1972 }
1973
1983 bool IsClifford() const override { return true; }
1984};
1985
1994template <typename Time = Types::time_type>
1995class CZGate : public TwoQubitsGate<Time> {
1996 public:
2007 CZGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2008 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2009
2020 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2021 OperationState &state) const override {
2022 sim->ApplyCZ(TwoQubitsGate<Time>::GetQubit(0),
2024 }
2025
2033 QuantumGateType GetGateType() const override {
2035 }
2036
2043 std::shared_ptr<IOperation<Time>> Clone() const override {
2044 return std::make_shared<CZGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2047 }
2048
2058 bool IsClifford() const override { return true; }
2059};
2060
2069template <typename Time = Types::time_type>
2070class CPGate : public TwoQubitsGate<Time> {
2071 public:
2083 CPGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double lambda = 0,
2084 Time delay = 0)
2085 : TwoQubitsGate<Time>(ctrl, target, delay), lambda(lambda) {}
2086
2097 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2098 OperationState &state) const override {
2099 sim->ApplyCP(TwoQubitsGate<Time>::GetQubit(0),
2101 }
2102
2109 void SetLambda(double l) { lambda = l; }
2110
2117 double GetLambda() const { return lambda; }
2118
2126 QuantumGateType GetGateType() const override {
2128 }
2129
2136 std::shared_ptr<IOperation<Time>> Clone() const override {
2137 return std::make_shared<CPGate<Time>>(
2140 }
2141
2148 std::vector<double> GetParams() const override { return {lambda}; }
2149
2150 private:
2151 double lambda;
2152};
2153
2162template <typename Time = Types::time_type>
2164 public:
2177 ControlledRotationGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1,
2178 double theta = 0, Time delay = 0)
2179 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta) {}
2180
2187 void SetTheta(double t) { theta = t; }
2188
2195 double GetTheta() const { return theta; }
2196
2203 std::vector<double> GetParams() const override { return {theta}; }
2204
2205 private:
2206 double theta;
2207};
2208
2217template <typename Time = Types::time_type>
2218class CRxGate : public ControlledRotationGate<Time> {
2219 public:
2231 CRxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2232 Time delay = 0)
2233 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2234
2245 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2246 OperationState &state) const override {
2247 sim->ApplyCRx(TwoQubitsGate<Time>::GetQubit(0),
2250 }
2251
2259 QuantumGateType GetGateType() const override {
2261 }
2262
2269 std::shared_ptr<IOperation<Time>> Clone() const override {
2270 return std::make_shared<CRxGate<Time>>(
2273 }
2274};
2275
2284template <typename Time = Types::time_type>
2285class CRyGate : public ControlledRotationGate<Time> {
2286 public:
2298 CRyGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2299 Time delay = 0)
2300 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2301
2312 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2313 OperationState &state) const override {
2314 sim->ApplyCRy(TwoQubitsGate<Time>::GetQubit(0),
2317 }
2318
2326 QuantumGateType GetGateType() const override {
2328 }
2329
2336 std::shared_ptr<IOperation<Time>> Clone() const override {
2337 return std::make_shared<CRyGate<Time>>(
2340 }
2341};
2342
2351template <typename Time = Types::time_type>
2352class CRzGate : public ControlledRotationGate<Time> {
2353 public:
2365 CRzGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2366 Time delay = 0)
2367 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2368
2379 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2380 OperationState &state) const override {
2381 sim->ApplyCRz(TwoQubitsGate<Time>::GetQubit(0),
2384 }
2385
2393 QuantumGateType GetGateType() const override {
2395 }
2396
2403 std::shared_ptr<IOperation<Time>> Clone() const override {
2404 return std::make_shared<CRzGate<Time>>(
2407 }
2408};
2409
2418template <typename Time = Types::time_type>
2419class CHGate : public TwoQubitsGate<Time> {
2420 public:
2431 CHGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2432 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2433
2444 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2445 OperationState &state) const override {
2446 sim->ApplyCH(TwoQubitsGate<Time>::GetQubit(0),
2448 }
2449
2457 QuantumGateType GetGateType() const override {
2459 }
2460
2467 std::shared_ptr<IOperation<Time>> Clone() const override {
2468 return std::make_shared<CHGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2471 }
2472};
2473
2482template <typename Time = Types::time_type>
2483class CSxGate : public TwoQubitsGate<Time> {
2484 public:
2495 CSxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2496 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2497
2508 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2509 OperationState &state) const override {
2510 sim->ApplyCSx(TwoQubitsGate<Time>::GetQubit(0),
2512 }
2513
2521 QuantumGateType GetGateType() const override {
2523 }
2524
2531 std::shared_ptr<IOperation<Time>> Clone() const override {
2532 return std::make_shared<CSxGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2535 }
2536};
2537
2546template <typename Time = Types::time_type>
2547class CSxDagGate : public TwoQubitsGate<Time> {
2548 public:
2559 CSxDagGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2560 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2561
2572 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2573 OperationState &state) const override {
2574 sim->ApplyCSxDAG(TwoQubitsGate<Time>::GetQubit(0),
2576 }
2577
2585 QuantumGateType GetGateType() const override {
2587 }
2588
2595 std::shared_ptr<IOperation<Time>> Clone() const override {
2596 return std::make_shared<CSxDagGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2599 }
2600};
2601
2610template <typename Time = Types::time_type>
2611class CUGate : public TwoQubitsGate<Time> {
2612 public:
2627 CUGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2628 double phi = 0, double lambda = 0, double gamma = 0, Time delay = 0)
2629 : TwoQubitsGate<Time>(ctrl, target, delay),
2630 theta(theta),
2631 phi(phi),
2632 lambda(lambda),
2633 gamma(gamma) {}
2634
2645 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2646 OperationState &state) const override {
2647 sim->ApplyCU(TwoQubitsGate<Time>::GetQubit(0),
2649 GetLambda(), GetGamma());
2650 }
2651
2659 QuantumGateType GetGateType() const override {
2661 }
2662
2669 void SetTheta(double t) { theta = t; }
2670
2677 double GetTheta() const { return theta; }
2678
2685 void SetPhi(double p) { phi = p; }
2686
2693 double GetPhi() const { return phi; }
2694
2701 void SetLambda(double l) { lambda = l; }
2702
2709 double GetLambda() const { return lambda; }
2710
2717 void SetGamma(double g) { gamma = g; }
2718
2725 double GetGamma() const { return gamma; }
2726
2733 std::shared_ptr<IOperation<Time>> Clone() const override {
2734 return std::make_shared<CUGate<Time>>(
2736 GetTheta(), GetPhi(), GetLambda(), GetGamma(),
2738 }
2739
2746 std::vector<double> GetParams() const override {
2747 return {theta, phi, lambda, gamma};
2748 }
2749
2750 private:
2751 double theta;
2752 double phi;
2753 double lambda;
2754 double gamma;
2755};
2756
2757//**********************************************************************************************
2758// Three Qubit Gates
2759// those should be replaced by sets of gates with less qubits, to be able to
2760// distribute them
2761//**********************************************************************************************
2762
2771template <typename Time = Types::time_type>
2772class CCXGate : public ThreeQubitsGate<Time> {
2773 public:
2785 CCXGate(Types::qubit_t ctrl1 = 0, Types::qubit_t ctrl2 = 1,
2786 Types::qubit_t target = 2, Time delay = 0)
2787 : ThreeQubitsGate<Time>(ctrl1, ctrl2, target, delay) {}
2788
2799 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2800 OperationState &state) const override {
2801 sim->ApplyCCX(ThreeQubitsGate<Time>::GetQubit(0),
2804 }
2805
2813 QuantumGateType GetGateType() const override {
2815 }
2816
2823 std::shared_ptr<IOperation<Time>> Clone() const override {
2824 return std::make_shared<CCXGate<Time>>(
2827 }
2828};
2829
2838template <typename Time = Types::time_type>
2839class CSwapGate : public ThreeQubitsGate<Time> {
2840 public:
2852 CSwapGate(Types::qubit_t ctrl = 0, Types::qubit_t target1 = 1,
2853 Types::qubit_t target2 = 2, Time delay = 0)
2854 : ThreeQubitsGate<Time>(ctrl, target1, target2, delay) {}
2855
2866 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2867 OperationState &state) const override {
2868 sim->ApplyCSwap(ThreeQubitsGate<Time>::GetQubit(0),
2871 }
2872
2880 QuantumGateType GetGateType() const override {
2882 }
2883
2890 std::shared_ptr<IOperation<Time>> Clone() const override {
2891 return std::make_shared<CSwapGate<Time>>(
2894 }
2895};
2896} // namespace Circuits
2897
2898#endif // !_QUANTUM_GATES_H_
The controlled controlled x gate.
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.
The controlled H 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.
The controlled P 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.
The controlled x rotation 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.
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 controlled y rotation gate.
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.
The controlled z 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.
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.
The controlled swap 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.
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.
The controlled Sx dagger 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.
The controlled Sx 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.
The controlled U 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.
The controlled x 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.
The controlled y 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.
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.
The controlled z 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.
The Hadamard gate.
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.
The gate operation interface.
Definition Operations.h:603
Time GetDelay() const
Get the delay of the operation.
Definition Operations.h:496
virtual std::shared_ptr< IOperation< Time > > Clone() const =0
Get a shared pointer to a clone of this object.
The interface for quantum gates.
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
The phase gate.
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.
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.
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.
The S 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.
The S dagger 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.
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.
The swap gate.
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.
The Sx dagger gate.
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.
The T dagger 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.
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.
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.
The X 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.
The Y gate.
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.
The Z 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::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.