Maestro 0.2.5
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QuantumGates.h
Go to the documentation of this file.
1
15#pragma once
16
17#ifndef _QUANTUM_GATES_H_
18#define _QUANTUM_GATES_H_
19
20#include "Operations.h"
21
22namespace Circuits {
23
61
71template <typename Time = Types::time_type>
72class IQuantumGate : public IGateOperation<Time> {
73 public:
81 IQuantumGate(Time delay = 0) : IGateOperation<Time>(delay) {}
82
90 virtual QuantumGateType GetGateType() const = 0;
91
99 virtual std::vector<double> GetParams() const { return {}; }
100};
101
112template <typename Time = Types::time_type>
113class SingleQubitGate : public IQuantumGate<Time> {
114 public:
124 SingleQubitGate(Types::qubit_t qubit = 0, Time delay = 0)
125 : IQuantumGate<Time>(delay), qubit(qubit) {}
126
133 virtual ~SingleQubitGate() {}
134
142 unsigned int GetNumQubits() const override { return 1; }
143
152 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
153 qubit = q;
154 }
155
165 Types::qubit_t GetQubit(unsigned int index = 0) const override {
166 return qubit;
167 }
168
176 Types::qubits_vector AffectedQubits() const override { return {qubit}; }
177
188 std::shared_ptr<IOperation<Time>> Remap(
189 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
190 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
191 const override {
192 auto newGate = this->Clone();
193
194 const auto qubitit = qubitsMap.find(qubit);
195 if (qubitit != qubitsMap.end())
196 std::static_pointer_cast<SingleQubitGate<Time>>(newGate)->SetQubit(
197 qubitit->second);
198 // else throw std::invalid_argument("Qubit not found in qubits map to remap
199 // the gate.");
200
201 return newGate;
202 }
203
204 private:
205 Types::qubit_t qubit;
206};
207
217template <typename Time = Types::time_type>
218class TwoQubitsGate : public IQuantumGate<Time> {
219 public:
232 Time delay = 0)
233 : IQuantumGate<Time>(delay), qubit1(qubit1), qubit2(qubit2) {}
234
241 virtual ~TwoQubitsGate() {}
242
250 unsigned int GetNumQubits() const override { return 2; }
251
260 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
261 if (index == 0)
262 qubit1 = q;
263 else if (index == 1)
264 qubit2 = q;
265 }
266
276 Types::qubit_t GetQubit(unsigned int index = 0) const override {
277 if (index == 0)
278 return qubit1;
279 else if (index == 1)
280 return qubit2;
281
282 return UINT_MAX;
283 }
284
292 return {qubit1, qubit2};
293 }
294
305 std::shared_ptr<IOperation<Time>> Remap(
306 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
307 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
308 const override {
309 auto newGate = this->Clone();
310
311 const auto qubitit1 = qubitsMap.find(qubit1);
312 if (qubitit1 != qubitsMap.end())
313 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
314 qubitit1->second, 0);
315
316 const auto qubitit2 = qubitsMap.find(qubit2);
317 if (qubitit2 != qubitsMap.end())
318 std::static_pointer_cast<TwoQubitsGate<Time>>(newGate)->SetQubit(
319 qubitit2->second, 1);
320
321 return newGate;
322 }
323
324 private:
325 Types::qubit_t qubit1;
327 qubit2;
328};
329
339template <typename Time = Types::time_type>
340class ThreeQubitsGate : public IQuantumGate<Time> {
341 public:
355 Types::qubit_t qubit3 = 0, Time delay = 0)
356 : IQuantumGate<Time>(delay),
357 qubit1(qubit1),
358 qubit2(qubit2),
359 qubit3(qubit3) {}
360
367 virtual ~ThreeQubitsGate() {}
368
376 unsigned int GetNumQubits() const override { return 3; }
377
386 void SetQubit(Types::qubit_t q, unsigned long index = 0) override {
387 if (index == 0)
388 qubit1 = q;
389 else if (index == 1)
390 qubit2 = q;
391 else if (index == 2)
392 qubit3 = q;
393 }
394
404 Types::qubit_t GetQubit(unsigned int index = 0) const override {
405 if (index == 0)
406 return qubit1;
407 else if (index == 1)
408 return qubit2;
409 else if (index == 2)
410 return qubit3;
411
412 return UINT_MAX;
413 }
414
423 return {qubit1, qubit2, qubit3};
424 }
425
436 std::shared_ptr<IOperation<Time>> Remap(
437 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
438 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
439 const override {
440 auto newGate = this->Clone();
441
442 const auto qubitit1 = qubitsMap.find(qubit1);
443 if (qubitit1 != qubitsMap.end())
444 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
445 qubitit1->second, 0);
446
447 const auto qubitit2 = qubitsMap.find(qubit2);
448 if (qubitit2 != qubitsMap.end())
449 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
450 qubitit2->second, 1);
451
452 const auto qubitit3 = qubitsMap.find(qubit3);
453 if (qubitit3 != qubitsMap.end())
454 std::static_pointer_cast<ThreeQubitsGate<Time>>(newGate)->SetQubit(
455 qubitit3->second, 2);
456
457 return newGate;
458 }
459
460 private:
461 Types::qubit_t qubit1;
463 qubit2;
464 Types::qubit_t qubit3;
465};
466
467//**********************************************************************************************
468// Single Qubit Gates
469//**********************************************************************************************
470
479template <typename Time = Types::time_type>
480class PhaseGate : public SingleQubitGate<Time> {
481 public:
492 PhaseGate(Types::qubit_t qubit = 0, double lambda = 0, Time delay = 0)
493 : SingleQubitGate<Time>(qubit, delay), lambda(lambda) {}
494
505 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
506 OperationState &state) const override {
507 sim->ApplyP(SingleQubitGate<Time>::GetQubit(), lambda);
508 }
509
516 void SetLambda(double l) { lambda = l; }
517
524 double GetLambda() const { return lambda; }
525
533 QuantumGateType GetGateType() const override {
535 }
536
543 std::shared_ptr<IOperation<Time>> Clone() const override {
544 return std::make_shared<PhaseGate<Time>>(SingleQubitGate<Time>::GetQubit(),
545 lambda,
547 }
548
555 std::vector<double> GetParams() const override { return {lambda}; }
556
566 bool IsClifford() const override {
567 if (std::abs(lambda - M_PI_2) > 1e-10) return false;
568
569 return true;
570 }
571
572 private:
573 double lambda;
574};
575
584template <typename Time = Types::time_type>
585class XGate : public SingleQubitGate<Time> {
586 public:
596 XGate(Types::qubit_t qubit = 0, Time delay = 0)
597 : SingleQubitGate<Time>(qubit, delay) {}
598
609 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
610 OperationState &state) const override {
611 sim->ApplyX(SingleQubitGate<Time>::GetQubit());
612 }
613
621 QuantumGateType GetGateType() const override {
623 }
624
631 std::shared_ptr<IOperation<Time>> Clone() const override {
632 return std::make_shared<XGate<Time>>(SingleQubitGate<Time>::GetQubit(),
634 }
635
645 bool IsClifford() const override { return true; }
646};
647
656template <typename Time = Types::time_type>
657class YGate : public SingleQubitGate<Time> {
658 public:
668 YGate(Types::qubit_t qubit = 0, Time delay = 0)
669 : SingleQubitGate<Time>(qubit, delay) {}
670
681 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
682 OperationState &state) const override {
683 sim->ApplyY(SingleQubitGate<Time>::GetQubit());
684 }
685
693 QuantumGateType GetGateType() const override {
695 }
696
703 std::shared_ptr<IOperation<Time>> Clone() const override {
704 return std::make_shared<YGate<Time>>(SingleQubitGate<Time>::GetQubit(),
706 }
707
717 bool IsClifford() const override { return true; }
718};
719
728template <typename Time = Types::time_type>
729class ZGate : public SingleQubitGate<Time> {
730 public:
740 ZGate(Types::qubit_t qubit = 0, Time delay = 0)
741 : SingleQubitGate<Time>(qubit, delay) {}
742
753 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
754 OperationState &state) const override {
755 sim->ApplyZ(SingleQubitGate<Time>::GetQubit());
756 }
757
765 QuantumGateType GetGateType() const override {
767 }
768
775 std::shared_ptr<IOperation<Time>> Clone() const override {
776 return std::make_shared<ZGate<Time>>(SingleQubitGate<Time>::GetQubit(),
778 }
779
789 bool IsClifford() const override { return true; }
790};
791
800template <typename Time = Types::time_type>
801class HadamardGate : public SingleQubitGate<Time> {
802 public:
812 HadamardGate(Types::qubit_t qubit = 0, Time delay = 0)
813 : SingleQubitGate<Time>(qubit, delay) {}
814
825 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
826 OperationState &state) const override {
827 sim->ApplyH(SingleQubitGate<Time>::GetQubit());
828 }
829
840
847 std::shared_ptr<IOperation<Time>> Clone() const override {
848 return std::make_shared<HadamardGate<Time>>(
850 }
851
861 bool IsClifford() const override { return true; }
862};
863
872template <typename Time = Types::time_type>
873class SGate : public SingleQubitGate<Time> {
874 public:
884 SGate(Types::qubit_t qubit = 0, Time delay = 0)
885 : SingleQubitGate<Time>(qubit, delay) {}
886
897 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
898 OperationState &state) const override {
899 sim->ApplyS(SingleQubitGate<Time>::GetQubit());
900 }
901
909 QuantumGateType GetGateType() const override {
911 }
912
919 std::shared_ptr<IOperation<Time>> Clone() const override {
920 return std::make_shared<SGate<Time>>(SingleQubitGate<Time>::GetQubit(),
922 }
923
933 bool IsClifford() const override { return true; }
934};
935
944template <typename Time = Types::time_type>
945class SdgGate : public SingleQubitGate<Time> {
946 public:
956 SdgGate(Types::qubit_t qubit = 0, Time delay = 0)
957 : SingleQubitGate<Time>(qubit, delay) {}
958
969 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
970 OperationState &state) const override {
971 sim->ApplySDG(SingleQubitGate<Time>::GetQubit());
972 }
973
981 QuantumGateType GetGateType() const override {
983 }
984
991 std::shared_ptr<IOperation<Time>> Clone() const override {
992 return std::make_shared<SdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
994 }
995
1005 bool IsClifford() const override { return true; }
1006};
1007
1016template <typename Time = Types::time_type>
1017class TGate : public SingleQubitGate<Time> {
1018 public:
1028 TGate(Types::qubit_t qubit = 0, Time delay = 0)
1029 : SingleQubitGate<Time>(qubit, delay) {}
1030
1041 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1042 OperationState &state) const override {
1043 sim->ApplyT(SingleQubitGate<Time>::GetQubit());
1044 }
1045
1053 QuantumGateType GetGateType() const override {
1055 }
1056
1063 std::shared_ptr<IOperation<Time>> Clone() const override {
1064 return std::make_shared<TGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1066 }
1067};
1068
1077template <typename Time = Types::time_type>
1078class TdgGate : public SingleQubitGate<Time> {
1079 public:
1089 TdgGate(Types::qubit_t qubit = 0, Time delay = 0)
1090 : SingleQubitGate<Time>(qubit, delay) {}
1091
1102 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1103 OperationState &state) const override {
1104 sim->ApplyTDG(SingleQubitGate<Time>::GetQubit());
1105 }
1106
1114 QuantumGateType GetGateType() const override {
1116 }
1117
1124 std::shared_ptr<IOperation<Time>> Clone() const override {
1125 return std::make_shared<TdgGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1127 }
1128};
1129
1138template <typename Time = Types::time_type>
1139class SxGate : public SingleQubitGate<Time> {
1140 public:
1150 SxGate(Types::qubit_t qubit = 0, Time delay = 0)
1151 : SingleQubitGate<Time>(qubit, delay) {}
1152
1163 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1164 OperationState &state) const override {
1165 sim->ApplySx(SingleQubitGate<Time>::GetQubit());
1166 }
1167
1175 QuantumGateType GetGateType() const override {
1177 }
1178
1185 std::shared_ptr<IOperation<Time>> Clone() const override {
1186 return std::make_shared<SxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1188 }
1189
1199 bool IsClifford() const override { return true; }
1200};
1201
1210template <typename Time = Types::time_type>
1211class SxDagGate : public SingleQubitGate<Time> {
1212 public:
1222 SxDagGate(Types::qubit_t qubit = 0, Time delay = 0)
1223 : SingleQubitGate<Time>(qubit, delay) {}
1224
1235 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1236 OperationState &state) const override {
1237 sim->ApplySxDAG(SingleQubitGate<Time>::GetQubit());
1238 }
1239
1247 QuantumGateType GetGateType() const override {
1249 }
1250
1257 std::shared_ptr<IOperation<Time>> Clone() const override {
1258 return std::make_shared<SxDagGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1260 }
1261
1271 bool IsClifford() const override { return true; }
1272};
1273
1282template <typename Time = Types::time_type>
1283class KGate : public SingleQubitGate<Time> {
1284 public:
1294 KGate(Types::qubit_t qubit = 0, Time delay = 0)
1295 : SingleQubitGate<Time>(qubit, delay) {}
1296
1307 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1308 OperationState &state) const override {
1309 sim->ApplyK(SingleQubitGate<Time>::GetQubit());
1310 }
1311
1319 QuantumGateType GetGateType() const override {
1321 }
1322
1329 std::shared_ptr<IOperation<Time>> Clone() const override {
1330 return std::make_shared<KGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1332 }
1333
1343 bool IsClifford() const override { return true; }
1344};
1345
1354template <typename Time = Types::time_type>
1355class RotationGate : public SingleQubitGate<Time> {
1356 public:
1368 RotationGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1369 : SingleQubitGate<Time>(qubit, delay), theta(theta) {}
1370
1377 void SetTheta(double t) { theta = t; }
1378
1385 double GetTheta() const { return theta; }
1386
1393 std::vector<double> GetParams() const override { return {theta}; }
1394
1395 private:
1396 double theta;
1397};
1398
1408template <typename Time = Types::time_type>
1409class RxGate : public RotationGate<Time> {
1410 public:
1421 RxGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1422 : RotationGate<Time>(qubit, theta, delay) {}
1423
1434 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1435 OperationState &state) const override {
1436 sim->ApplyRx(SingleQubitGate<Time>::GetQubit(),
1438 }
1439
1447 QuantumGateType GetGateType() const override {
1449 }
1450
1457 std::shared_ptr<IOperation<Time>> Clone() const override {
1458 return std::make_shared<RxGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1461 }
1462};
1463
1473template <typename Time = Types::time_type>
1474class RyGate : public RotationGate<Time> {
1475 public:
1486 RyGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1487 : RotationGate<Time>(qubit, theta, delay) {}
1488
1499 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1500 OperationState &state) const override {
1501 sim->ApplyRy(SingleQubitGate<Time>::GetQubit(),
1503 }
1504
1512 QuantumGateType GetGateType() const override {
1514 }
1515
1522 std::shared_ptr<IOperation<Time>> Clone() const override {
1523 return std::make_shared<RyGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1526 }
1527};
1528
1538template <typename Time = Types::time_type>
1539class RzGate : public RotationGate<Time> {
1540 public:
1551 RzGate(Types::qubit_t qubit = 0, double theta = 0, Time delay = 0)
1552 : RotationGate<Time>(qubit, theta, delay) {}
1553
1564 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1565 OperationState &state) const override {
1566 sim->ApplyRz(SingleQubitGate<Time>::GetQubit(),
1568 }
1569
1577 QuantumGateType GetGateType() const override {
1579 }
1580
1587 std::shared_ptr<IOperation<Time>> Clone() const override {
1588 return std::make_shared<RzGate<Time>>(SingleQubitGate<Time>::GetQubit(),
1591 }
1592};
1593
1602template <typename Time = Types::time_type>
1603class UGate : public SingleQubitGate<Time> {
1604 public:
1615 UGate(Types::qubit_t qubit = 0, double theta = 0, double phi = 0,
1616 double lambda = 0, double gamma = 0, Time delay = 0)
1617 : SingleQubitGate<Time>(qubit, delay),
1618 theta(theta),
1619 phi(phi),
1620 lambda(lambda),
1621 gamma(gamma) {}
1622
1633 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1634 OperationState &state) const override {
1635 sim->ApplyU(SingleQubitGate<Time>::GetQubit(), theta, phi, lambda, gamma);
1636 }
1637
1645 QuantumGateType GetGateType() const override {
1647 }
1648
1655 std::shared_ptr<IOperation<Time>> Clone() const override {
1656 return std::make_shared<UGate<Time>>(
1659 }
1660
1667 void SetTheta(double t) { theta = t; }
1668
1675 double GetTheta() const { return theta; }
1676
1683 void SetPhi(double p) { phi = p; }
1684
1691 double GetPhi() const { return phi; }
1692
1699 void SetLambda(double l) { lambda = l; }
1700
1707 double GetLambda() const { return lambda; }
1708
1715 void SetGamma(double g) { gamma = g; }
1716
1723 double GetGamma() const { return gamma; }
1724
1731 std::vector<double> GetParams() const override {
1732 return {theta, phi, lambda, gamma};
1733 }
1734
1744 bool IsClifford() const override { return false; }
1745
1746 private:
1747 double theta;
1748 double phi;
1749 double lambda;
1750 double gamma;
1751};
1752
1753//**********************************************************************************************
1754// Two Qubit Gates
1755//**********************************************************************************************
1756
1757// this one should be replaced - for example with three qnots - to be able to
1758// distribute it
1759
1768template <typename Time = Types::time_type>
1769class SwapGate : public TwoQubitsGate<Time> {
1770 public:
1781 SwapGate(Types::qubit_t qubit1 = 0, Types::qubit_t qubit2 = 1, Time delay = 0)
1782 : TwoQubitsGate<Time>(qubit1, qubit2, delay) {}
1783
1794 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1795 OperationState &state) const override {
1796 sim->ApplySwap(TwoQubitsGate<Time>::GetQubit(0),
1798 }
1799
1807 QuantumGateType GetGateType() const override {
1809 }
1810
1817 std::shared_ptr<IOperation<Time>> Clone() const override {
1818 return std::make_shared<SwapGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1821 }
1822
1832 bool IsClifford() const override { return true; }
1833};
1834
1835// the others are all controlled gates
1836
1845template <typename Time = Types::time_type>
1846class CXGate : public TwoQubitsGate<Time> {
1847 public:
1858 CXGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1859 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1860
1871 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1872 OperationState &state) const override {
1873 sim->ApplyCX(TwoQubitsGate<Time>::GetQubit(0),
1875 }
1876
1884 QuantumGateType GetGateType() const override {
1886 }
1887
1894 std::shared_ptr<IOperation<Time>> Clone() const override {
1895 return std::make_shared<CXGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1898 }
1899
1909 bool IsClifford() const override { return true; }
1910};
1911
1920template <typename Time = Types::time_type>
1921class CYGate : public TwoQubitsGate<Time> {
1922 public:
1933 CYGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
1934 : TwoQubitsGate<Time>(ctrl, target, delay) {}
1935
1946 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
1947 OperationState &state) const override {
1948 sim->ApplyCY(TwoQubitsGate<Time>::GetQubit(0),
1950 }
1951
1959 QuantumGateType GetGateType() const override {
1961 }
1962
1969 std::shared_ptr<IOperation<Time>> Clone() const override {
1970 return std::make_shared<CYGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
1973 }
1974
1984 bool IsClifford() const override { return true; }
1985};
1986
1995template <typename Time = Types::time_type>
1996class CZGate : public TwoQubitsGate<Time> {
1997 public:
2008 CZGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2009 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2010
2021 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2022 OperationState &state) const override {
2023 sim->ApplyCZ(TwoQubitsGate<Time>::GetQubit(0),
2025 }
2026
2034 QuantumGateType GetGateType() const override {
2036 }
2037
2044 std::shared_ptr<IOperation<Time>> Clone() const override {
2045 return std::make_shared<CZGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2048 }
2049
2059 bool IsClifford() const override { return true; }
2060};
2061
2070template <typename Time = Types::time_type>
2071class CPGate : public TwoQubitsGate<Time> {
2072 public:
2084 CPGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double lambda = 0,
2085 Time delay = 0)
2086 : TwoQubitsGate<Time>(ctrl, target, delay), lambda(lambda) {}
2087
2098 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2099 OperationState &state) const override {
2100 sim->ApplyCP(TwoQubitsGate<Time>::GetQubit(0),
2102 }
2103
2110 void SetLambda(double l) { lambda = l; }
2111
2118 double GetLambda() const { return lambda; }
2119
2127 QuantumGateType GetGateType() const override {
2129 }
2130
2137 std::shared_ptr<IOperation<Time>> Clone() const override {
2138 return std::make_shared<CPGate<Time>>(
2141 }
2142
2149 std::vector<double> GetParams() const override { return {lambda}; }
2150
2151 private:
2152 double lambda;
2153};
2154
2163template <typename Time = Types::time_type>
2165 public:
2179 double theta = 0, Time delay = 0)
2180 : TwoQubitsGate<Time>(ctrl, target, delay), theta(theta) {}
2181
2188 void SetTheta(double t) { theta = t; }
2189
2196 double GetTheta() const { return theta; }
2197
2204 std::vector<double> GetParams() const override { return {theta}; }
2205
2206 private:
2207 double theta;
2208};
2209
2218template <typename Time = Types::time_type>
2219class CRxGate : public ControlledRotationGate<Time> {
2220 public:
2232 CRxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2233 Time delay = 0)
2234 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2235
2246 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2247 OperationState &state) const override {
2248 sim->ApplyCRx(TwoQubitsGate<Time>::GetQubit(0),
2251 }
2252
2260 QuantumGateType GetGateType() const override {
2262 }
2263
2270 std::shared_ptr<IOperation<Time>> Clone() const override {
2271 return std::make_shared<CRxGate<Time>>(
2274 }
2275};
2276
2285template <typename Time = Types::time_type>
2286class CRyGate : public ControlledRotationGate<Time> {
2287 public:
2299 CRyGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2300 Time delay = 0)
2301 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2302
2313 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2314 OperationState &state) const override {
2315 sim->ApplyCRy(TwoQubitsGate<Time>::GetQubit(0),
2318 }
2319
2327 QuantumGateType GetGateType() const override {
2329 }
2330
2337 std::shared_ptr<IOperation<Time>> Clone() const override {
2338 return std::make_shared<CRyGate<Time>>(
2341 }
2342};
2343
2352template <typename Time = Types::time_type>
2353class CRzGate : public ControlledRotationGate<Time> {
2354 public:
2366 CRzGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2367 Time delay = 0)
2368 : ControlledRotationGate<Time>(ctrl, target, theta, delay) {}
2369
2380 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2381 OperationState &state) const override {
2382 sim->ApplyCRz(TwoQubitsGate<Time>::GetQubit(0),
2385 }
2386
2394 QuantumGateType GetGateType() const override {
2396 }
2397
2404 std::shared_ptr<IOperation<Time>> Clone() const override {
2405 return std::make_shared<CRzGate<Time>>(
2408 }
2409};
2410
2419template <typename Time = Types::time_type>
2420class CHGate : public TwoQubitsGate<Time> {
2421 public:
2432 CHGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2433 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2434
2445 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2446 OperationState &state) const override {
2447 sim->ApplyCH(TwoQubitsGate<Time>::GetQubit(0),
2449 }
2450
2458 QuantumGateType GetGateType() const override {
2460 }
2461
2468 std::shared_ptr<IOperation<Time>> Clone() const override {
2469 return std::make_shared<CHGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2472 }
2473};
2474
2483template <typename Time = Types::time_type>
2484class CSxGate : public TwoQubitsGate<Time> {
2485 public:
2496 CSxGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2497 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2498
2509 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2510 OperationState &state) const override {
2511 sim->ApplyCSx(TwoQubitsGate<Time>::GetQubit(0),
2513 }
2514
2522 QuantumGateType GetGateType() const override {
2524 }
2525
2532 std::shared_ptr<IOperation<Time>> Clone() const override {
2533 return std::make_shared<CSxGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2536 }
2537};
2538
2547template <typename Time = Types::time_type>
2548class CSxDagGate : public TwoQubitsGate<Time> {
2549 public:
2560 CSxDagGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, Time delay = 0)
2561 : TwoQubitsGate<Time>(ctrl, target, delay) {}
2562
2573 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2574 OperationState &state) const override {
2575 sim->ApplyCSxDAG(TwoQubitsGate<Time>::GetQubit(0),
2577 }
2578
2586 QuantumGateType GetGateType() const override {
2588 }
2589
2596 std::shared_ptr<IOperation<Time>> Clone() const override {
2597 return std::make_shared<CSxDagGate<Time>>(TwoQubitsGate<Time>::GetQubit(0),
2600 }
2601};
2602
2611template <typename Time = Types::time_type>
2612class CUGate : public TwoQubitsGate<Time> {
2613 public:
2628 CUGate(Types::qubit_t ctrl = 0, Types::qubit_t target = 1, double theta = 0,
2629 double phi = 0, double lambda = 0, double gamma = 0, Time delay = 0)
2630 : TwoQubitsGate<Time>(ctrl, target, delay),
2631 theta(theta),
2632 phi(phi),
2633 lambda(lambda),
2634 gamma(gamma) {}
2635
2646 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2647 OperationState &state) const override {
2648 sim->ApplyCU(TwoQubitsGate<Time>::GetQubit(0),
2650 GetLambda(), GetGamma());
2651 }
2652
2660 QuantumGateType GetGateType() const override {
2662 }
2663
2670 void SetTheta(double t) { theta = t; }
2671
2678 double GetTheta() const { return theta; }
2679
2686 void SetPhi(double p) { phi = p; }
2687
2694 double GetPhi() const { return phi; }
2695
2702 void SetLambda(double l) { lambda = l; }
2703
2710 double GetLambda() const { return lambda; }
2711
2718 void SetGamma(double g) { gamma = g; }
2719
2726 double GetGamma() const { return gamma; }
2727
2734 std::shared_ptr<IOperation<Time>> Clone() const override {
2735 return std::make_shared<CUGate<Time>>(
2737 GetTheta(), GetPhi(), GetLambda(), GetGamma(),
2739 }
2740
2747 std::vector<double> GetParams() const override {
2748 return {theta, phi, lambda, gamma};
2749 }
2750
2751 private:
2752 double theta;
2753 double phi;
2754 double lambda;
2755 double gamma;
2756};
2757
2758//**********************************************************************************************
2759// Three Qubit Gates
2760// those should be replaced by sets of gates with less qubits, to be able to
2761// distribute them
2762//**********************************************************************************************
2763
2772template <typename Time = Types::time_type>
2773class CCXGate : public ThreeQubitsGate<Time> {
2774 public:
2787 Types::qubit_t target = 2, Time delay = 0)
2788 : ThreeQubitsGate<Time>(ctrl1, ctrl2, target, delay) {}
2789
2800 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2801 OperationState &state) const override {
2802 sim->ApplyCCX(ThreeQubitsGate<Time>::GetQubit(0),
2805 }
2806
2814 QuantumGateType GetGateType() const override {
2816 }
2817
2824 std::shared_ptr<IOperation<Time>> Clone() const override {
2825 return std::make_shared<CCXGate<Time>>(
2828 }
2829};
2830
2839template <typename Time = Types::time_type>
2840class CSwapGate : public ThreeQubitsGate<Time> {
2841 public:
2854 Types::qubit_t target2 = 2, Time delay = 0)
2855 : ThreeQubitsGate<Time>(ctrl, target1, target2, delay) {}
2856
2867 void Execute(const std::shared_ptr<Simulators::ISimulator> &sim,
2868 OperationState &state) const override {
2869 sim->ApplyCSwap(ThreeQubitsGate<Time>::GetQubit(0),
2872 }
2873
2881 QuantumGateType GetGateType() const override {
2883 }
2884
2891 std::shared_ptr<IOperation<Time>> Clone() const override {
2892 return std::make_shared<CSwapGate<Time>>(
2895 }
2896};
2897} // namespace Circuits
2898
2899#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:604
Time GetDelay() const
Get the delay of the operation.
Definition Operations.h:497
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:63
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.
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:21
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
Definition Types.h:23