Qrack  9.0
General classical-emulating-quantum development framework
qinterface.hpp
Go to the documentation of this file.
1 //
3 // (C) Daniel Strano and the Qrack contributors 2017-2023. All rights reserved.
4 //
5 // This is a multithreaded, universal quantum register simulation, allowing
6 // (nonphysical) register cloning and direct measurement of probability and
7 // phase, to leverage what advantages classical emulation of qubits can have.
8 //
9 // Licensed under the GNU Lesser General Public License V3.
10 // See LICENSE.md in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html
11 // for details.
12 
13 #pragma once
14 
15 #include "common/parallel_for.hpp"
16 #include "common/rdrandwrapper.hpp"
17 #include "hamiltonian.hpp"
18 
19 #include <map>
20 #include <random>
21 
22 #if ENABLE_UINT128
23 #include <ostream>
24 #endif
25 
26 namespace Qrack {
27 
28 class QInterface;
29 typedef std::shared_ptr<QInterface> QInterfacePtr;
30 
34 enum Pauli {
36  PauliI = 0,
38  PauliX = 1,
40  PauliY = 3,
42  PauliZ = 2
43 };
44 
51 
56 
61 
66 
71 
76 
81 
86 
91 
96 
105 
111 
116 
121 
122 #if ENABLE_OPENCL
124 
126 #else
128 
130 #endif
131 
133 
135 
137 };
138 
146 class QInterface : public ParallelFor {
147 protected:
150  bool useRDRAND;
152  uint32_t randomSeed;
156  std::uniform_real_distribution<real1_s> rand_distribution;
157  std::shared_ptr<RdRandom> hardware_rand_generator;
158 
159  virtual void SetQubitCount(bitLenInt qb)
160  {
161  qubitCount = qb;
163  }
164 
165  // Compilers have difficulty figuring out types and overloading if the "norm" handle is passed to std::transform. If
166  // you need a safe pointer to norm(), try this:
167  static inline real1_f normHelper(complex c) { return (real1_f)norm(c); }
168 
169  static inline real1_f clampProb(real1_f toClamp)
170  {
171  if (toClamp < ZERO_R1_F) {
172  toClamp = ZERO_R1_F;
173  }
174  if (toClamp > ONE_R1_F) {
175  toClamp = ONE_R1_F;
176  }
177  return toClamp;
178  }
179 
181  {
183  real1_f angle = Rand() * 2 * (real1_f)PI_R1;
184  return complex((real1)cos(angle), (real1)sin(angle));
185  } else {
186  return ONE_CMPLX;
187  }
188  }
189 
190  template <typename Fn> void MACWrapper(const std::vector<bitLenInt>& controls, Fn fn)
191  {
192  bitCapInt xMask = 0U;
193  for (size_t i = 0U; i < controls.size(); ++i) {
194  xMask |= pow2(controls[i]);
195  }
196 
197  XMask(xMask);
198  fn(controls);
199  XMask(xMask);
200  }
201 
202  bitCapInt SampleClone(const std::vector<bitCapInt>& qPowers)
203  {
204  QInterfacePtr clone = Clone();
205 
206  const bitCapInt rawSample = clone->MAll();
207  bitCapInt sample = 0U;
208  for (size_t i = 0U; i < qPowers.size(); ++i) {
209  if (rawSample & qPowers[i]) {
210  sample |= pow2(i);
211  }
212  }
213 
214  return sample;
215  }
216 
217 public:
218  QInterface(bitLenInt n, qrack_rand_gen_ptr rgp = nullptr, bool doNorm = false, bool useHardwareRNG = true,
219  bool randomGlobalPhase = true, real1_f norm_thresh = REAL1_EPSILON);
220 
223  : doNormalize(false)
224  , randGlobalPhase(true)
225  , useRDRAND(true)
226  , qubitCount(0U)
227  , randomSeed(0)
229  , maxQPower(1U)
230  , rand_distribution(0.0, 1.0)
232  {
233  // Intentionally left blank
234  }
235 
236  virtual ~QInterface()
237  {
238  // Virtual destructor for inheritance
239  }
240 
241  void SetRandomSeed(uint32_t seed)
242  {
243  if (rand_generator != NULL) {
244  rand_generator->seed(seed);
245  }
246  }
247 
249  virtual void SetConcurrency(uint32_t threadsPerEngine) { SetConcurrencyLevel(threadsPerEngine); }
250 
252  virtual bitLenInt GetQubitCount() { return qubitCount; }
253 
255  virtual bitCapInt GetMaxQPower() { return maxQPower; }
256 
257  virtual bool GetIsArbitraryGlobalPhase() { return randGlobalPhase; }
258 
261  {
262  if (hardware_rand_generator != NULL) {
263  return hardware_rand_generator->Next();
264  } else {
266  }
267  }
268 
273  virtual void SetQuantumState(const complex* inputState) = 0;
274 
279  virtual void GetQuantumState(complex* outputState) = 0;
280 
285  virtual void GetProbs(real1* outputProbs) = 0;
286 
291  virtual complex GetAmplitude(bitCapInt perm) = 0;
292 
297  virtual void SetAmplitude(bitCapInt perm, complex amp) = 0;
298 
300  virtual void SetPermutation(bitCapInt perm, complex phaseFac = CMPLX_DEFAULT_ARG);
301 
338  virtual bitLenInt Compose(QInterfacePtr toCopy) { return Compose(toCopy, qubitCount); }
339  virtual bitLenInt ComposeNoClone(QInterfacePtr toCopy) { return Compose(toCopy); }
340  virtual std::map<QInterfacePtr, bitLenInt> Compose(std::vector<QInterfacePtr> toCopy);
341  virtual bitLenInt Compose(QInterfacePtr toCopy, bitLenInt start);
342 
380  virtual void Decompose(bitLenInt start, QInterfacePtr dest) = 0;
381 
385  virtual QInterfacePtr Decompose(bitLenInt start, bitLenInt length) = 0;
386 
424  virtual void Dispose(bitLenInt start, bitLenInt length) = 0;
425 
429  virtual void Dispose(bitLenInt start, bitLenInt length, bitCapInt disposedPerm) = 0;
430 
434  virtual bitLenInt Allocate(bitLenInt length) { return Allocate(qubitCount, length); }
435 
439  virtual bitLenInt Allocate(bitLenInt start, bitLenInt length) = 0;
440 
449  virtual void Mtrx(const complex* mtrx, bitLenInt qubitIndex) = 0;
450 
454  virtual void MCMtrx(const std::vector<bitLenInt>& controls, const complex* mtrx, bitLenInt target) = 0;
455 
459  virtual void MACMtrx(const std::vector<bitLenInt>& controls, const complex* mtrx, bitLenInt target)
460  {
461  if (IS_NORM_0(mtrx[1U]) && IS_NORM_0(mtrx[2U])) {
462  MACPhase(controls, mtrx[0U], mtrx[3U], target);
463  } else if (IS_NORM_0(mtrx[0U]) && IS_NORM_0(mtrx[3U])) {
464  MACInvert(controls, mtrx[1U], mtrx[2U], target);
465  } else {
466  MACWrapper(controls, [this, mtrx, target](const std::vector<bitLenInt>& lc) { MCMtrx(lc, mtrx, target); });
467  }
468  }
469 
474  virtual void UCMtrx(
475  const std::vector<bitLenInt>& controls, const complex* mtrx, bitLenInt target, bitCapInt controlPerm);
476 
480  virtual void Phase(const complex topLeft, const complex bottomRight, bitLenInt qubitIndex)
481  {
482  if ((randGlobalPhase || IS_NORM_0(ONE_CMPLX - topLeft)) && IS_NORM_0(topLeft - bottomRight)) {
483  return;
484  }
485 
486  const complex mtrx[4U]{ topLeft, ZERO_CMPLX, ZERO_CMPLX, bottomRight };
487  Mtrx(mtrx, qubitIndex);
488  }
489 
493  virtual void Invert(const complex topRight, const complex bottomLeft, bitLenInt qubitIndex)
494  {
495  const complex mtrx[4U]{ ZERO_CMPLX, topRight, bottomLeft, ZERO_CMPLX };
496  Mtrx(mtrx, qubitIndex);
497  }
498 
502  virtual void MCPhase(const std::vector<bitLenInt>& controls, complex topLeft, complex bottomRight, bitLenInt target)
503  {
504  if (IS_NORM_0(ONE_CMPLX - topLeft) && IS_NORM_0(ONE_CMPLX - bottomRight)) {
505  return;
506  }
507 
508  const complex mtrx[4U]{ topLeft, ZERO_CMPLX, ZERO_CMPLX, bottomRight };
509  MCMtrx(controls, mtrx, target);
510  }
511 
516  virtual void MCInvert(
517  const std::vector<bitLenInt>& controls, complex topRight, complex bottomLeft, bitLenInt target)
518  {
519  const complex mtrx[4U]{ ZERO_CMPLX, topRight, bottomLeft, ZERO_CMPLX };
520  MCMtrx(controls, mtrx, target);
521  }
522 
526  virtual void MACPhase(
527  const std::vector<bitLenInt>& controls, complex topLeft, complex bottomRight, bitLenInt target)
528  {
529  if (IS_NORM_0(ONE_CMPLX - topLeft) && IS_NORM_0(ONE_CMPLX - bottomRight)) {
530  return;
531  }
532 
533  MACWrapper(controls, [this, topLeft, bottomRight, target](const std::vector<bitLenInt>& lc) {
534  MCPhase(lc, topLeft, bottomRight, target);
535  });
536  }
537 
542  virtual void MACInvert(
543  const std::vector<bitLenInt>& controls, complex topRight, complex bottomLeft, bitLenInt target)
544  {
545  MACWrapper(controls, [this, topRight, bottomLeft, target](const std::vector<bitLenInt>& lc) {
546  MCInvert(lc, topRight, bottomLeft, target);
547  });
548  }
549 
554  virtual void UCPhase(
555  const std::vector<bitLenInt>& controls, complex topLeft, complex bottomRight, bitLenInt target, bitCapInt perm)
556  {
557  if (IS_NORM_0(ONE_CMPLX - topLeft) && IS_NORM_0(ONE_CMPLX - bottomRight)) {
558  return;
559  }
560 
561  const complex mtrx[4U]{ topLeft, ZERO_CMPLX, ZERO_CMPLX, bottomRight };
562  UCMtrx(controls, mtrx, target, perm);
563  }
564 
569  virtual void UCInvert(
570  const std::vector<bitLenInt>& controls, complex topRight, complex bottomLeft, bitLenInt target, bitCapInt perm)
571  {
572  const complex mtrx[4U]{ ZERO_CMPLX, topRight, bottomLeft, ZERO_CMPLX };
573  UCMtrx(controls, mtrx, target, perm);
574  }
575 
591  const std::vector<bitLenInt>& controls, bitLenInt qubitIndex, const complex* mtrxs)
592  {
593  UniformlyControlledSingleBit(controls, qubitIndex, mtrxs, std::vector<bitCapInt>(), 0);
594  }
595  virtual void UniformlyControlledSingleBit(const std::vector<bitLenInt>& controls, bitLenInt qubitIndex,
596  const complex* mtrxs, const std::vector<bitCapInt>& mtrxSkipPowers, bitCapInt mtrxSkipValueMask);
597 
613  virtual void TimeEvolve(Hamiltonian h, real1_f timeDiff);
614 
618  virtual void CSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
619 
623  virtual void AntiCSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
624 
628  virtual void CSqrtSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
629 
633  virtual void AntiCSqrtSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
634 
638  virtual void CISqrtSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
639 
643  virtual void AntiCISqrtSwap(const std::vector<bitLenInt>& controls, bitLenInt qubit1, bitLenInt qubit2);
644 
650  virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
651  {
652  const std::vector<bitLenInt> controls{ control1, control2 };
653  MCInvert(controls, ONE_CMPLX, ONE_CMPLX, target);
654  }
655 
661  virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
662  {
663  const std::vector<bitLenInt> controls{ control1, control2 };
664  MACInvert(controls, ONE_CMPLX, ONE_CMPLX, target);
665  }
666 
672  virtual void CNOT(bitLenInt control, bitLenInt target)
673  {
674  const std::vector<bitLenInt> controls{ control };
675  MCInvert(controls, ONE_CMPLX, ONE_CMPLX, target);
676  }
677 
683  virtual void AntiCNOT(bitLenInt control, bitLenInt target)
684  {
685  const std::vector<bitLenInt> controls{ control };
686  MACInvert(controls, ONE_CMPLX, ONE_CMPLX, target);
687  }
688 
695  virtual void CY(bitLenInt control, bitLenInt target)
696  {
697  const std::vector<bitLenInt> controls{ control };
698  MCInvert(controls, -I_CMPLX, I_CMPLX, target);
699  }
700 
706  virtual void AntiCY(bitLenInt control, bitLenInt target)
707  {
708  const std::vector<bitLenInt> controls{ control };
709  MACInvert(controls, -I_CMPLX, I_CMPLX, target);
710  }
711 
718  virtual void CCY(bitLenInt control1, bitLenInt control2, bitLenInt target)
719  {
720  const std::vector<bitLenInt> controls{ control1, control2 };
721  MCInvert(controls, -I_CMPLX, I_CMPLX, target);
722  }
723 
729  virtual void AntiCCY(bitLenInt control1, bitLenInt control2, bitLenInt target)
730  {
731  const std::vector<bitLenInt> controls{ control1, control2 };
732  MACInvert(controls, -I_CMPLX, I_CMPLX, target);
733  }
734 
741  virtual void CZ(bitLenInt control, bitLenInt target)
742  {
743  const std::vector<bitLenInt> controls{ control };
744  MCPhase(controls, ONE_CMPLX, -ONE_CMPLX, target);
745  }
746 
752  virtual void AntiCZ(bitLenInt control, bitLenInt target)
753  {
754  const std::vector<bitLenInt> controls{ control };
755  MACPhase(controls, ONE_CMPLX, -ONE_CMPLX, target);
756  }
757 
764  virtual void CCZ(bitLenInt control1, bitLenInt control2, bitLenInt target)
765  {
766  const std::vector<bitLenInt> controls{ control1, control2 };
767  MCPhase(controls, ONE_CMPLX, -ONE_CMPLX, target);
768  }
769 
775  virtual void AntiCCZ(bitLenInt control1, bitLenInt control2, bitLenInt target)
776  {
777  const std::vector<bitLenInt> controls{ control1, control2 };
778  MACPhase(controls, ONE_CMPLX, -ONE_CMPLX, target);
779  }
780 
787  virtual void U(bitLenInt target, real1_f theta, real1_f phi, real1_f lambda);
788 
794  virtual void U2(bitLenInt target, real1_f phi, real1_f lambda) { U(target, (real1_f)(M_PI / 2), phi, lambda); }
795 
801  virtual void IU2(bitLenInt target, real1_f phi, real1_f lambda)
802  {
803  U(target, (real1_f)(M_PI / 2), (real1_f)(-lambda - PI_R1), (real1_f)(-phi + PI_R1));
804  }
805 
811  virtual void AI(bitLenInt target, real1_f azimuth, real1_f inclination);
812 
818  virtual void IAI(bitLenInt target, real1_f azimuth, real1_f inclination);
819 
825  virtual void CAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination);
826 
833  virtual void AntiCAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination);
834 
841  virtual void CIAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination);
842 
849  virtual void AntiCIAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination);
850 
858  virtual void CU(
859  const std::vector<bitLenInt>& controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda);
860 
868  virtual void AntiCU(
869  const std::vector<bitLenInt>& controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda);
870 
876  virtual void H(bitLenInt qubit)
877  {
881  Mtrx(mtrx, qubit);
882  }
883 
889  virtual void SqrtH(bitLenInt qubit)
890  {
891  QRACK_CONST complex m00 =
892  complex((real1)((ONE_R1 + SQRT2_R1) / (2 * SQRT2_R1)), (real1)((-ONE_R1 + SQRT2_R1) / (2 * SQRT2_R1)));
893  QRACK_CONST complex m01 = complex((real1)(SQRT1_2_R1 / 2), (real1)(-SQRT1_2_R1 / 2));
894  QRACK_CONST complex m10 = m01;
895  QRACK_CONST complex m11 =
896  complex((real1)((-ONE_R1 + SQRT2_R1) / (2 * SQRT2_R1)), (real1)((ONE_R1 + SQRT2_R1) / (2 * SQRT2_R1)));
897  QRACK_CONST complex mtrx[4]{ m00, m01, m10, m11 };
898  Mtrx(mtrx, qubit);
899  }
900 
906  virtual void SH(bitLenInt qubit)
907  {
910  QRACK_CONST complex C_I_SQRT1_2_NEG = complex(ZERO_R1, -SQRT1_2_R1);
911  QRACK_CONST complex mtrx[4]{ C_SQRT1_2, C_SQRT1_2, C_I_SQRT1_2, C_I_SQRT1_2_NEG };
912  Mtrx(mtrx, qubit);
913  }
914 
920  virtual void HIS(bitLenInt qubit)
921  {
924  QRACK_CONST complex C_I_SQRT1_2_NEG = complex(ZERO_R1, -SQRT1_2_R1);
925  QRACK_CONST complex mtrx[4]{ C_SQRT1_2, C_I_SQRT1_2_NEG, C_SQRT1_2, C_I_SQRT1_2 };
926  Mtrx(mtrx, qubit);
927  }
928 
976  virtual bool M(bitLenInt qubitIndex) { return ForceM(qubitIndex, false, false); };
977 
983  virtual bool ForceM(bitLenInt qubit, bool result, bool doForce = true, bool doApply = true) = 0;
984 
990  virtual void S(bitLenInt qubit) { Phase(ONE_CMPLX, I_CMPLX, qubit); }
991 
997  virtual void IS(bitLenInt qubit) { Phase(ONE_CMPLX, -I_CMPLX, qubit); }
998 
1004  virtual void T(bitLenInt qubit) { Phase(ONE_CMPLX, complex(SQRT1_2_R1, SQRT1_2_R1), qubit); }
1005 
1011  virtual void IT(bitLenInt qubit) { Phase(ONE_CMPLX, complex(SQRT1_2_R1, -SQRT1_2_R1), qubit); }
1012 
1018  virtual void PhaseRootN(bitLenInt n, bitLenInt qubit)
1019  {
1020  if (n == 0) {
1021  return;
1022  }
1023 
1024  Phase(ONE_CMPLX, pow(-ONE_CMPLX, (real1)(ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), qubit);
1025  }
1026 
1032  virtual void IPhaseRootN(bitLenInt n, bitLenInt qubit)
1033  {
1034  if (n == 0) {
1035  return;
1036  }
1037 
1038  Phase(ONE_CMPLX, pow(-ONE_CMPLX, (real1)(-ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), qubit);
1039  }
1040 
1046  virtual void PhaseParity(real1_f radians, bitCapInt mask);
1047 
1054  virtual void X(bitLenInt qubit) { Invert(ONE_CMPLX, ONE_CMPLX, qubit); }
1055 
1062  virtual void XMask(bitCapInt mask);
1063 
1071  virtual void Y(bitLenInt qubit) { Invert(-I_CMPLX, I_CMPLX, qubit); }
1072 
1079  virtual void YMask(bitCapInt mask);
1080 
1087  virtual void Z(bitLenInt qubit) { Phase(ONE_CMPLX, -ONE_CMPLX, qubit); }
1088 
1095  virtual void ZMask(bitCapInt mask);
1096 
1103  virtual void SqrtX(bitLenInt qubit)
1104  {
1105  QRACK_CONST complex ONE_PLUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(ONE_R1 / 2));
1106  QRACK_CONST complex ONE_MINUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1107  QRACK_CONST complex mtrx[4]{ ONE_PLUS_I_DIV_2, ONE_MINUS_I_DIV_2, ONE_MINUS_I_DIV_2, ONE_PLUS_I_DIV_2 };
1108  Mtrx(mtrx, qubit);
1109  }
1110 
1117  virtual void ISqrtX(bitLenInt qubit)
1118  {
1119  QRACK_CONST complex ONE_PLUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(ONE_R1 / 2));
1120  QRACK_CONST complex ONE_MINUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1121  QRACK_CONST complex mtrx[4]{ ONE_MINUS_I_DIV_2, ONE_PLUS_I_DIV_2, ONE_PLUS_I_DIV_2, ONE_MINUS_I_DIV_2 };
1122  Mtrx(mtrx, qubit);
1123  }
1124 
1132  virtual void SqrtY(bitLenInt qubit)
1133  {
1134  QRACK_CONST complex ONE_PLUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(ONE_R1 / 2));
1135  QRACK_CONST complex ONE_PLUS_I_DIV_2_NEG = complex((real1)(-ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1136  QRACK_CONST complex mtrx[4]{ ONE_PLUS_I_DIV_2, ONE_PLUS_I_DIV_2_NEG, ONE_PLUS_I_DIV_2, ONE_PLUS_I_DIV_2 };
1137  Mtrx(mtrx, qubit);
1138  }
1139 
1147  virtual void ISqrtY(bitLenInt qubit)
1148  {
1149  QRACK_CONST complex ONE_MINUS_I_DIV_2 = complex((real1)(ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1150  QRACK_CONST complex ONE_MINUS_I_DIV_2_NEG = complex((real1)(-ONE_R1 / 2), (real1)(ONE_R1 / 2));
1151  QRACK_CONST complex mtrx[4]{ ONE_MINUS_I_DIV_2, ONE_MINUS_I_DIV_2, ONE_MINUS_I_DIV_2_NEG, ONE_MINUS_I_DIV_2 };
1152  Mtrx(mtrx, qubit);
1153  }
1154 
1160  virtual void SqrtW(bitLenInt qubit)
1161  {
1163  QRACK_CONST complex m01 = complex((real1)(-ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1164  QRACK_CONST complex m10 = complex((real1)(ONE_R1 / 2), (real1)(-ONE_R1 / 2));
1165  QRACK_CONST complex mtrx[4]{ diag, m01, m10, diag };
1166  Mtrx(mtrx, qubit);
1167  }
1168 
1174  virtual void ISqrtW(bitLenInt qubit)
1175  {
1177  QRACK_CONST complex m01 = complex((real1)(ONE_R1 / 2), (real1)(ONE_R1 / 2));
1178  QRACK_CONST complex m10 = complex((real1)(-ONE_R1 / 2), (real1)(ONE_R1 / 2));
1179  QRACK_CONST complex mtrx[4]{ diag, m01, m10, diag };
1180  Mtrx(mtrx, qubit);
1181  }
1182 
1189  virtual void CH(bitLenInt control, bitLenInt target)
1190  {
1191  const std::vector<bitLenInt> controls{ control };
1195  MCMtrx(controls, mtrx, target);
1196  }
1197 
1204  virtual void AntiCH(bitLenInt control, bitLenInt target)
1205  {
1206  const std::vector<bitLenInt> controls{ control };
1210  MACMtrx(controls, mtrx, target);
1211  }
1212 
1219  virtual void CS(bitLenInt control, bitLenInt target)
1220  {
1221  const std::vector<bitLenInt> controls{ control };
1222  MCPhase(controls, ONE_CMPLX, I_CMPLX, target);
1223  }
1224 
1231  virtual void AntiCS(bitLenInt control, bitLenInt target)
1232  {
1233  const std::vector<bitLenInt> controls{ control };
1234  MACPhase(controls, ONE_CMPLX, I_CMPLX, target);
1235  }
1236 
1243  virtual void CIS(bitLenInt control, bitLenInt target)
1244  {
1245  const std::vector<bitLenInt> controls{ control };
1246  MCPhase(controls, ONE_CMPLX, -I_CMPLX, target);
1247  }
1248 
1255  virtual void AntiCIS(bitLenInt control, bitLenInt target)
1256  {
1257  const std::vector<bitLenInt> controls{ control };
1258  MACPhase(controls, ONE_CMPLX, -I_CMPLX, target);
1259  }
1260 
1267  virtual void CT(bitLenInt control, bitLenInt target)
1268  {
1269  const std::vector<bitLenInt> controls{ control };
1270  MCPhase(controls, ONE_CMPLX, complex(SQRT1_2_R1, SQRT1_2_R1), target);
1271  }
1272 
1279  virtual void CIT(bitLenInt control, bitLenInt target)
1280  {
1281  const std::vector<bitLenInt> controls{ control };
1282  MCPhase(controls, ONE_CMPLX, complex(SQRT1_2_R1, -SQRT1_2_R1), target);
1283  }
1284 
1291  virtual void CPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
1292  {
1293  if (n == 0) {
1294  return;
1295  }
1296 
1297  const std::vector<bitLenInt> controls{ control };
1298  MCPhase(controls, ONE_CMPLX, pow(-ONE_CMPLX, (real1)(ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), target);
1299  }
1300 
1307  virtual void AntiCPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
1308  {
1309  if (n == 0) {
1310  return;
1311  }
1312 
1313  const std::vector<bitLenInt> controls{ control };
1314  MACPhase(controls, ONE_CMPLX, pow(-ONE_CMPLX, (real1)(ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), target);
1315  }
1316 
1323  virtual void CIPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
1324  {
1325  if (n == 0) {
1326  return;
1327  }
1328 
1329  const std::vector<bitLenInt> controls{ control };
1330  MCPhase(controls, ONE_CMPLX, pow(-ONE_CMPLX, (real1)(-ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), target);
1331  }
1332 
1339  virtual void AntiCIPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
1340  {
1341  if (n == 0) {
1342  return;
1343  }
1344 
1345  const std::vector<bitLenInt> controls{ control };
1346  MACPhase(controls, ONE_CMPLX, pow(-ONE_CMPLX, (real1)(-ONE_R1 / (bitCapIntOcl)(pow2(n - 1U)))), target);
1347  }
1348 
1365  virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1366 
1372  virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1373 
1379  virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1380 
1385  virtual void CLAND(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1386 
1391  virtual void CLOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1392 
1397  virtual void CLXOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1398 
1404  virtual void NAND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1405 
1411  virtual void NOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1412 
1418  virtual void XNOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit);
1419 
1424  virtual void CLNAND(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1425 
1430  virtual void CLNOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1431 
1436  virtual void CLXNOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit);
1437 
1459  virtual void UniformlyControlledRY(
1460  const std::vector<bitLenInt>& controls, bitLenInt qubitIndex, real1 const* angles);
1461 
1472  virtual void UniformlyControlledRZ(
1473  const std::vector<bitLenInt>& controls, bitLenInt qubitIndex, real1 const* angles);
1474 
1480  virtual void RT(real1_f radians, bitLenInt qubitIndex);
1481 
1487  virtual void RX(real1_f radians, bitLenInt qubitIndex);
1488 
1494  virtual void RY(real1_f radians, bitLenInt qubitIndex);
1495 
1501  virtual void RZ(real1_f radians, bitLenInt qubitIndex);
1502 
1509  virtual void CRZ(real1_f radians, bitLenInt control, bitLenInt target);
1510 
1517  virtual void CRY(real1_f radians, bitLenInt control, bitLenInt target);
1518 
1519 #if ENABLE_ROT_API
1526  virtual void RTDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1527 
1533  virtual void RXDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1534 
1540  virtual void Exp(real1_f radians, bitLenInt qubitIndex);
1541 
1547  virtual void Exp(
1548  const std::vector<bitLenInt>& controls, bitLenInt qubit, const complex* matrix2x2, bool antiCtrled = false);
1549 
1556  virtual void ExpDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1557 
1563  virtual void ExpX(real1_f radians, bitLenInt qubitIndex);
1564 
1571  virtual void ExpXDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1572 
1578  virtual void ExpY(real1_f radians, bitLenInt qubitIndex);
1579 
1586  virtual void ExpYDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1587 
1593  virtual void ExpZ(real1_f radians, bitLenInt qubitIndex);
1594 
1601  virtual void ExpZDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1602 
1608  virtual void CRX(real1_f radians, bitLenInt control, bitLenInt target);
1609 
1615  virtual void CRXDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target);
1616 
1622  virtual void RYDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1623 
1630  virtual void CRYDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target);
1631 
1637  virtual void RZDyad(int numerator, int denomPower, bitLenInt qubitIndex);
1638 
1645  virtual void CRZDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target);
1646 
1654  virtual void CRT(real1_f radians, bitLenInt control, bitLenInt target);
1655 
1662  virtual void CRTDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target);
1663 #endif
1664 
1677  virtual void H(bitLenInt start, bitLenInt length);
1678 
1680  virtual void X(bitLenInt start, bitLenInt length) { XMask(bitRegMask(start, length)); }
1681 
1682 #if ENABLE_REG_GATES
1683 
1685  virtual void U(bitLenInt start, bitLenInt length, real1_f theta, real1_f phi, real1_f lambda);
1686 
1688  virtual void U2(bitLenInt start, bitLenInt length, real1_f phi, real1_f lambda);
1689 
1691  virtual void SH(bitLenInt start, bitLenInt length);
1692 
1694  virtual void HIS(bitLenInt start, bitLenInt length);
1695 
1697  virtual void SqrtH(bitLenInt start, bitLenInt length);
1698 
1700  virtual void S(bitLenInt start, bitLenInt length);
1701 
1703  virtual void IS(bitLenInt start, bitLenInt length);
1704 
1706  virtual void T(bitLenInt start, bitLenInt length);
1707 
1709  virtual void IT(bitLenInt start, bitLenInt length);
1710 
1712  virtual void PhaseRootN(bitLenInt n, bitLenInt start, bitLenInt length);
1713 
1715  virtual void IPhaseRootN(bitLenInt n, bitLenInt start, bitLenInt length);
1716 
1718  virtual void Y(bitLenInt start, bitLenInt length);
1719 
1721  virtual void SqrtX(bitLenInt start, bitLenInt length);
1722 
1724  virtual void ISqrtX(bitLenInt start, bitLenInt length);
1725 
1727  virtual void SqrtY(bitLenInt start, bitLenInt length);
1728 
1730  virtual void ISqrtY(bitLenInt start, bitLenInt length);
1731 
1733  virtual void Z(bitLenInt start, bitLenInt length);
1734 
1736  virtual void CNOT(bitLenInt inputBits, bitLenInt targetBits, bitLenInt length);
1737 
1739  virtual void AntiCNOT(bitLenInt inputBits, bitLenInt targetBits, bitLenInt length);
1740 
1742  virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1743 
1745  virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1746 
1748  virtual void CY(bitLenInt control, bitLenInt target, bitLenInt length);
1749 
1751  virtual void AntiCY(bitLenInt inputBits, bitLenInt targetBits, bitLenInt length);
1752 
1754  virtual void CCY(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1755 
1757  virtual void AntiCCY(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1758 
1760  virtual void CZ(bitLenInt control, bitLenInt target, bitLenInt length);
1761 
1763  virtual void AntiCZ(bitLenInt inputBits, bitLenInt targetBits, bitLenInt length);
1764 
1766  virtual void CCZ(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1767 
1769  virtual void AntiCCZ(bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length);
1770 
1772  virtual void Swap(bitLenInt start1, bitLenInt start2, bitLenInt length);
1773 
1775  virtual void ISwap(bitLenInt start1, bitLenInt start2, bitLenInt length);
1776 
1778  virtual void IISwap(bitLenInt start1, bitLenInt start2, bitLenInt length);
1779 
1781  virtual void SqrtSwap(bitLenInt start1, bitLenInt start2, bitLenInt length);
1782 
1784  virtual void ISqrtSwap(bitLenInt start1, bitLenInt start2, bitLenInt length);
1785 
1787  virtual void FSim(real1_f theta, real1_f phi, bitLenInt start1, bitLenInt start2, bitLenInt length);
1788 
1795  virtual void AND(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1796 
1803  virtual void CLAND(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1804 
1806  virtual void OR(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1807 
1809  virtual void CLOR(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1810 
1812  virtual void XOR(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1813 
1815  virtual void CLXOR(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1816 
1818  virtual void NAND(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1819 
1821  virtual void CLNAND(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1822 
1824  virtual void NOR(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1825 
1827  virtual void CLNOR(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1828 
1830  virtual void XNOR(bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length);
1831 
1833  virtual void CLXNOR(bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length);
1834 
1835 #if ENABLE_ROT_API
1841  virtual void RT(real1_f radians, bitLenInt start, bitLenInt length);
1842 
1849  virtual void RTDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1850 
1856  virtual void RX(real1_f radians, bitLenInt start, bitLenInt length);
1857 
1863  virtual void RXDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1864 
1870  virtual void CRX(real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length);
1871 
1877  virtual void CRXDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length);
1878 
1884  virtual void RY(real1_f radians, bitLenInt start, bitLenInt length);
1885 
1892  virtual void RYDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1893 
1900  virtual void CRY(real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length);
1901 
1908  virtual void CRYDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length);
1909 
1915  virtual void RZ(real1_f radians, bitLenInt start, bitLenInt length);
1916 
1922  virtual void RZDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1923 
1930  virtual void CRZ(real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length);
1931 
1938  virtual void CRZDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length);
1939 
1946  virtual void CRT(real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length);
1947 
1954  virtual void CRTDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length);
1955 
1961  virtual void Exp(real1_f radians, bitLenInt start, bitLenInt length);
1962 
1969  virtual void ExpDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1970 
1976  virtual void ExpX(real1_f radians, bitLenInt start, bitLenInt length);
1977 
1984  virtual void ExpXDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
1985 
1991  virtual void ExpY(real1_f radians, bitLenInt start, bitLenInt length);
1992 
1999  virtual void ExpYDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
2000 
2006  virtual void ExpZ(real1_f radians, bitLenInt start, bitLenInt length);
2007 
2014  virtual void ExpZDyad(int numerator, int denomPower, bitLenInt start, bitLenInt length);
2015 #endif
2016 
2023  virtual void CH(bitLenInt control, bitLenInt target, bitLenInt length);
2024 
2031  virtual void CS(bitLenInt control, bitLenInt target, bitLenInt length);
2032 
2039  virtual void CIS(bitLenInt control, bitLenInt target, bitLenInt length);
2040 
2047  virtual void CT(bitLenInt control, bitLenInt target, bitLenInt length);
2048 
2055  virtual void CIT(bitLenInt control, bitLenInt target, bitLenInt length);
2056 
2063  virtual void CPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target, bitLenInt length);
2064 
2071  virtual void CIPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target, bitLenInt length);
2072 
2074 #endif
2075 
2083  virtual void ROL(bitLenInt shift, bitLenInt start, bitLenInt length);
2084 
2086  virtual void ROR(bitLenInt shift, bitLenInt start, bitLenInt length);
2087 
2089  virtual void ASL(bitLenInt shift, bitLenInt start, bitLenInt length);
2090 
2092  virtual void ASR(bitLenInt shift, bitLenInt start, bitLenInt length);
2093 
2095  virtual void LSL(bitLenInt shift, bitLenInt start, bitLenInt length);
2096 
2098  virtual void LSR(bitLenInt shift, bitLenInt start, bitLenInt length);
2099 
2100 #if ENABLE_ALU
2102  virtual void INCDECC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex);
2103 
2105  virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex);
2106 
2108  virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex);
2109 
2111  virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length);
2112 
2114  virtual void CINC(bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector<bitLenInt>& controls);
2115 
2117  virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex);
2118 
2120  virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length);
2121 
2123  virtual void CDEC(bitCapInt toSub, bitLenInt inOutStart, bitLenInt length, const std::vector<bitLenInt>& controls);
2124 
2126  virtual void DECS(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex);
2127 
2129  virtual void MULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length);
2130 
2132  virtual void IMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length);
2133 
2135  virtual void CMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length,
2136  const std::vector<bitLenInt>& controls);
2137 
2139  virtual void CIMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length,
2140  const std::vector<bitLenInt>& controls);
2141 
2147  virtual void FullAdd(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut);
2148 
2154  virtual void IFullAdd(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut);
2155 
2161  virtual void CFullAdd(const std::vector<bitLenInt>& controls, bitLenInt inputBit1, bitLenInt inputBit2,
2162  bitLenInt carryInSumOut, bitLenInt carryOut);
2163 
2169  virtual void CIFullAdd(const std::vector<bitLenInt>& controls, bitLenInt inputBit1, bitLenInt inputBit2,
2170  bitLenInt carryInSumOut, bitLenInt carryOut);
2171 
2177  virtual void ADC(bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry);
2178 
2184  virtual void IADC(bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry);
2185 
2191  virtual void CADC(const std::vector<bitLenInt>& controls, bitLenInt input1, bitLenInt input2, bitLenInt output,
2192  bitLenInt length, bitLenInt carry);
2193 
2199  virtual void CIADC(const std::vector<bitLenInt>& controls, bitLenInt input1, bitLenInt input2, bitLenInt output,
2200  bitLenInt length, bitLenInt carry);
2201 #endif
2202 
2217  virtual void QFT(bitLenInt start, bitLenInt length, bool trySeparate = false);
2218 
2225  virtual void QFTR(const std::vector<bitLenInt>& qubits, bool trySeparate = false);
2226 
2233  virtual void IQFT(bitLenInt start, bitLenInt length, bool trySeparate = false);
2234 
2241  virtual void IQFTR(const std::vector<bitLenInt>& qubits, bool trySeparate = false);
2242 
2244  virtual void ZeroPhaseFlip(bitLenInt start, bitLenInt length);
2245 
2247  virtual void PhaseFlip() { Phase(-ONE_CMPLX, -ONE_CMPLX, 0); }
2248 
2250  virtual void SetReg(bitLenInt start, bitLenInt length, bitCapInt value);
2251 
2253  virtual bitCapInt MReg(bitLenInt start, bitLenInt length) { return ForceMReg(start, length, 0, false); }
2254 
2256  virtual bitCapInt MAll() { return MReg(0, qubitCount); }
2257 
2263  virtual bitCapInt ForceMReg(
2264  bitLenInt start, bitLenInt length, bitCapInt result, bool doForce = true, bool doApply = true);
2265 
2267  virtual bitCapInt M(const std::vector<bitLenInt>& bits) { return ForceM(bits, std::vector<bool>()); }
2268 
2270  virtual bitCapInt ForceM(const std::vector<bitLenInt>& bits, const std::vector<bool>& values, bool doApply = true);
2271 
2273  virtual void Swap(bitLenInt qubitIndex1, bitLenInt qubitIndex2);
2274 
2276  virtual void ISwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2);
2277 
2279  virtual void IISwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2);
2280 
2282  virtual void SqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2);
2283 
2285  virtual void ISqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2);
2286 
2288  virtual void FSim(real1_f theta, real1_f phi, bitLenInt qubitIndex1, bitLenInt qubitIndex2) = 0;
2289 
2291  virtual void Reverse(bitLenInt first, bitLenInt last)
2292  {
2293  while ((last > 0U) && (first < (last - 1U))) {
2294  --last;
2295  Swap(first, last);
2296  ++first;
2297  }
2298  }
2299 
2313  virtual real1_f Prob(bitLenInt qubitIndex) = 0;
2319  virtual real1_f CProb(bitLenInt control, bitLenInt target)
2320  {
2321  AntiCNOT(control, target);
2322  const real1_f prob = Prob(target);
2323  AntiCNOT(control, target);
2324 
2325  return prob;
2326  }
2332  virtual real1_f ACProb(bitLenInt control, bitLenInt target)
2333  {
2334  CNOT(control, target);
2335  const real1_f prob = Prob(target);
2336  CNOT(control, target);
2337 
2338  return prob;
2339  }
2340 
2346  virtual real1_f ProbAll(bitCapInt fullRegister) { return clampProb((real1_f)norm(GetAmplitude(fullRegister))); }
2347 
2353  virtual real1_f ProbReg(bitLenInt start, bitLenInt length, bitCapInt permutation);
2354 
2364  virtual real1_f ProbMask(bitCapInt mask, bitCapInt permutation);
2365 
2374  virtual void ProbMaskAll(bitCapInt mask, real1* probsArray);
2375 
2384  virtual void ProbBitsAll(const std::vector<bitLenInt>& bits, real1* probsArray);
2385 
2394  virtual real1_f ExpectationBitsAll(const std::vector<bitLenInt>& bits, bitCapInt offset = 0U)
2395  {
2396  std::vector<bitCapInt> perms;
2397  perms.reserve(bits.size() << 1U);
2398  for (size_t i = 0U; i < bits.size(); ++i) {
2399  perms.push_back(0U);
2400  perms.push_back(pow2(i));
2401  }
2402 
2403  return ExpectationBitsFactorized(bits, perms, offset);
2404  }
2405 
2415  const std::vector<bitLenInt>& bits, const std::vector<bitCapInt>& perms, bitCapInt offset = 0U);
2416 
2427  bool roundRz, const std::vector<bitLenInt>& bits, const std::vector<bitCapInt>& perms, bitCapInt offset = 0)
2428  {
2429  return ExpectationBitsFactorized(bits, perms, offset);
2430  }
2431 
2441  const std::vector<bitLenInt>& bits, const std::vector<real1_f>& weights);
2442 
2453  bool roundRz, const std::vector<bitLenInt>& bits, const std::vector<real1_f>& weights)
2454  {
2455  return ExpectationFloatsFactorized(bits, weights);
2456  }
2457 
2464  virtual real1_f ProbRdm(bitLenInt qubitIndex) { return Prob(qubitIndex); }
2470  virtual real1_f ProbAllRdm(bool roundRz, bitCapInt fullRegister) { return ProbAll(fullRegister); }
2480  virtual real1_f ProbMaskRdm(bool roundRz, bitCapInt mask, bitCapInt permutation)
2481  {
2482  return ProbMask(mask, permutation);
2483  }
2492  virtual real1_f ExpectationBitsAllRdm(bool roundRz, const std::vector<bitLenInt>& bits, bitCapInt offset = 0U)
2493  {
2494  return ExpectationBitsAll(bits, offset);
2495  }
2496 
2511  virtual std::map<bitCapInt, int> MultiShotMeasureMask(const std::vector<bitCapInt>& qPowers, unsigned shots);
2512 
2520  virtual void MultiShotMeasureMask(
2521  const std::vector<bitCapInt>& qPowers, unsigned shots, unsigned long long* shotsArray);
2522 
2532  virtual void SetBit(bitLenInt qubit, bool value)
2533  {
2534  if (value != M(qubit)) {
2535  X(qubit);
2536  }
2537  }
2538 
2545  virtual bool ApproxCompare(QInterfacePtr toCompare, real1_f error_tol = TRYDECOMPOSE_EPSILON)
2546  {
2547  return SumSqrDiff(toCompare) <= error_tol;
2548  }
2549 
2550  virtual real1_f SumSqrDiff(QInterfacePtr toCompare) = 0;
2551 
2552  virtual bool TryDecompose(bitLenInt start, QInterfacePtr dest, real1_f error_tol = TRYDECOMPOSE_EPSILON);
2553 
2560  virtual void UpdateRunningNorm(real1_f norm_thresh = REAL1_DEFAULT_ARG) = 0;
2561 
2568  virtual void NormalizeState(
2569  real1_f nrm = REAL1_DEFAULT_ARG, real1_f norm_thresh = REAL1_DEFAULT_ARG, real1_f phaseArg = ZERO_R1_F) = 0;
2570 
2576  virtual void Finish() {}
2577 
2582  virtual bool isFinished() { return true; }
2583 
2588  virtual void Dump() {}
2589 
2594  virtual bool isBinaryDecisionTree() { return false; }
2595 
2600  virtual bool isClifford() { return false; }
2601 
2606  virtual bool isClifford(bitLenInt qubit) { return false; }
2607 
2611  virtual bool isOpenCL() { return false; }
2612 
2626  virtual bool TrySeparate(const std::vector<bitLenInt>& qubits, real1_f error_tol) { return false; }
2630  virtual bool TrySeparate(bitLenInt qubit) { return false; }
2634  virtual bool TrySeparate(bitLenInt qubit1, bitLenInt qubit2) { return false; }
2644  virtual double GetUnitaryFidelity() { return 1.0; }
2648  virtual void ResetUnitaryFidelity() {}
2652  virtual void SetSdrp(real1_f sdrp){};
2660  virtual void SetReactiveSeparate(bool isAggSep) {}
2668  virtual bool GetReactiveSeparate() { return false; }
2676  virtual void SetTInjection(bool useGadget) {}
2684  virtual bool GetTInjection() { return false; }
2685 
2689  virtual QInterfacePtr Clone() = 0;
2690 
2694  virtual void SetDevice(int64_t dID) = 0;
2695 
2699  virtual int64_t GetDevice() { return -1; }
2700 
2704  bitCapIntOcl GetMaxSize() { return pow2Ocl(sizeof(bitCapInt) * 8); };
2705 
2710  {
2711  complex amp;
2712  bitCapInt perm = 0U;
2713  do {
2714  amp = GetAmplitude(perm);
2715  ++perm;
2716  } while ((abs(amp) <= REAL1_EPSILON) && (perm < maxQPower));
2717 
2718  return (real1_f)std::arg(amp);
2719  }
2720 
2726  virtual void DepolarizingChannelWeak1Qb(bitLenInt qubit, real1_f lambda);
2727 
2740 
2742 };
2743 } // namespace Qrack
Definition: parallel_for.hpp:19
void SetConcurrencyLevel(unsigned num)
Definition: parallel_for.hpp:28
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:146
virtual void GetQuantumState(complex *outputState)=0
Get the pure quantum state representation.
bitCapInt maxQPower
Definition: qinterface.hpp:154
void SetRandomSeed(uint32_t seed)
Definition: qinterface.hpp:241
virtual void SetConcurrency(uint32_t threadsPerEngine)
Set the number of threads in parallel for loops, per component QEngine.
Definition: qinterface.hpp:249
real1 amplitudeFloor
Definition: qinterface.hpp:153
virtual complex GetAmplitude(bitCapInt perm)=0
Get the representational amplitude of a full permutation.
void MACWrapper(const std::vector< bitLenInt > &controls, Fn fn)
Definition: qinterface.hpp:190
bool useRDRAND
Definition: qinterface.hpp:150
virtual bitLenInt Allocate(bitLenInt length)
Allocate new "length" count of |0> state qubits at end of qubit index position.
Definition: qinterface.hpp:434
virtual bitCapInt GetMaxQPower()
Get the maximum number of basis states, namely for qubits.
Definition: qinterface.hpp:255
std::shared_ptr< RdRandom > hardware_rand_generator
Definition: qinterface.hpp:157
virtual bitLenInt Compose(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qinterface.hpp:338
virtual QInterfacePtr Decompose(bitLenInt start, bitLenInt length)=0
Schmidt decompose a length of qubits.
qrack_rand_gen_ptr rand_generator
Definition: qinterface.hpp:155
virtual bitLenInt ComposeNoClone(QInterfacePtr toCopy)
Definition: qinterface.hpp:339
bool randGlobalPhase
Definition: qinterface.hpp:149
virtual void Dispose(bitLenInt start, bitLenInt length, bitCapInt disposedPerm)=0
Dispose a a contiguous set of qubits that are already in a permutation eigenstate.
virtual void SetAmplitude(bitCapInt perm, complex amp)=0
Sets the representational amplitude of a full permutation.
virtual void SetPermutation(bitCapInt perm, complex phaseFac=CMPLX_DEFAULT_ARG)
Set to a specific permutation of all qubits.
Definition: qinterface.cpp:97
static real1_f normHelper(complex c)
Definition: qinterface.hpp:167
virtual void Decompose(bitLenInt start, QInterfacePtr dest)=0
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
QInterface()
Default constructor, primarily for protected internal use.
Definition: qinterface.hpp:222
virtual void SetQubitCount(bitLenInt qb)
Definition: qinterface.hpp:159
std::uniform_real_distribution< real1_s > rand_distribution
Definition: qinterface.hpp:156
virtual bitLenInt Allocate(bitLenInt start, bitLenInt length)=0
Allocate new "length" count of |0> state qubits at specified qubit index start position.
virtual void SetQuantumState(const complex *inputState)=0
Set an arbitrary pure quantum state representation.
static real1_f clampProb(real1_f toClamp)
Definition: qinterface.hpp:169
bitLenInt qubitCount
Definition: qinterface.hpp:151
virtual bitLenInt GetQubitCount()
Get the count of bits in this register.
Definition: qinterface.hpp:252
uint32_t randomSeed
Definition: qinterface.hpp:152
real1_f Rand()
Generate a random real number between 0 and 1.
Definition: qinterface.hpp:260
virtual void Dispose(bitLenInt start, bitLenInt length)=0
Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separa...
virtual bool GetIsArbitraryGlobalPhase()
Definition: qinterface.hpp:257
bool doNormalize
Definition: qinterface.hpp:148
bitCapInt SampleClone(const std::vector< bitCapInt > &qPowers)
Definition: qinterface.hpp:202
complex GetNonunitaryPhase()
Definition: qinterface.hpp:180
virtual ~QInterface()
Definition: qinterface.hpp:236
virtual void GetProbs(real1 *outputProbs)=0
Get the pure quantum state representation.
Half-precision floating-point type.
Definition: half.hpp:2222
virtual void FullAdd(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
Quantum analog of classical "Full Adder" gate.
Definition: arithmetic.cpp:330
virtual void ASL(bitLenInt shift, bitLenInt start, bitLenInt length)
Arithmetic shift left, with last 2 bits as sign and carry.
Definition: qinterface.cpp:323
virtual void CMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:259
virtual void CIMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Inverse of controlled multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:296
virtual void CADC(const std::vector< bitLenInt > &controls, bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry)
Add a quantum integer to a quantum integer, with carry and with controls.
Definition: arithmetic.cpp:454
virtual void INCDECC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCC and DECC.
Definition: arithmetic.cpp:63
virtual void ADC(bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry)
Add a quantum integer to a quantum integer, with carry.
Definition: arithmetic.cpp:412
virtual void IMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Inverse of multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:226
virtual void CINC(bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Add integer (without sign, with controls)
Definition: arithmetic.cpp:114
virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: arithmetic.cpp:88
virtual void CFullAdd(const std::vector< bitLenInt > &controls, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
Controlled quantum analog of classical "Full Adder" gate.
Definition: arithmetic.cpp:358
virtual void LSR(bitLenInt shift, bitLenInt start, bitLenInt length)
Logical shift right, filling the extra bits with |0>
Definition: qinterface.cpp:374
virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract classical integer (without sign, with carry)
Definition: arithmetic.cpp:100
virtual void CIFullAdd(const std::vector< bitLenInt > &controls, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
Inverse of CFullAdd.
Definition: arithmetic.cpp:384
virtual void CIADC(const std::vector< bitLenInt > &controls, bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry)
Inverse of CADC.
Definition: arithmetic.cpp:476
virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: arithmetic.cpp:167
virtual void ROL(bitLenInt shift, bitLenInt start, bitLenInt length)
Circular shift left - shift bits left, and carry last bits.
Definition: qinterface.cpp:287
virtual void IFullAdd(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
Inverse of FullAdd.
Definition: arithmetic.cpp:343
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract classical integer (without sign)
Definition: arithmetic.cpp:57
virtual void IADC(bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry)
Inverse of ADC.
Definition: arithmetic.cpp:433
virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: arithmetic.cpp:24
virtual void ROR(bitLenInt shift, bitLenInt start, bitLenInt length)
Circular shift right - shift bits right, and carry first bits.
Definition: qinterface.cpp:305
virtual void LSL(bitLenInt shift, bitLenInt start, bitLenInt length)
Logical shift left, filling the extra bits with |0>
Definition: qinterface.cpp:359
virtual void ASR(bitLenInt shift, bitLenInt start, bitLenInt length)
Arithmetic shift right, with last 2 bits as sign and carry.
Definition: qinterface.cpp:341
virtual void DECS(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Subtract a classical integer from the register, with sign and without carry.
Definition: arithmetic.cpp:182
virtual void MULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:191
virtual void CDEC(bitCapInt toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Subtract classical integer (without sign, with controls)
Definition: arithmetic.cpp:160
virtual void CPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
Controlled "PhaseRootN" gate.
Definition: qinterface.hpp:1291
virtual void CIPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
Controlled inverse "PhaseRootN" gate.
Definition: qinterface.hpp:1323
virtual void AntiCIAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
(Anti-)Controlled inverse "Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:115
virtual void ISqrtX(bitLenInt qubit)
Inverse square root of X gate.
Definition: qinterface.hpp:1117
virtual void ISqrtY(bitLenInt qubit)
Inverse square root of Y gate.
Definition: qinterface.hpp:1147
virtual void YMask(bitCapInt mask)
Masked Y gate.
Definition: gates.cpp:112
virtual void CZ(bitLenInt control, bitLenInt target)
Controlled Z gate.
Definition: qinterface.hpp:741
virtual void CU(const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
Controlled general unitary gate.
Definition: rotational.cpp:29
virtual void SH(bitLenInt qubit)
Y-basis transformation gate.
Definition: qinterface.hpp:906
virtual void AntiCS(bitLenInt control, bitLenInt target)
(Anti-)controlled S gate
Definition: qinterface.hpp:1231
virtual void CCZ(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-Controlled Z gate.
Definition: qinterface.hpp:764
virtual void XMask(bitCapInt mask)
Masked X gate.
Definition: gates.cpp:102
virtual void UCInvert(const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target, bitCapInt perm)
Apply a single bit transformation that reverses bit probability and might effect phase,...
Definition: qinterface.hpp:569
virtual void CS(bitLenInt control, bitLenInt target)
Controlled S gate.
Definition: qinterface.hpp:1219
virtual void CIS(bitLenInt control, bitLenInt target)
Controlled inverse S gate.
Definition: qinterface.hpp:1243
virtual void SqrtY(bitLenInt qubit)
Square root of Y gate.
Definition: qinterface.hpp:1132
virtual void CNOT(bitLenInt control, bitLenInt target)
Controlled NOT gate.
Definition: qinterface.hpp:672
virtual void TimeEvolve(Hamiltonian h, real1_f timeDiff)
To define a Hamiltonian, give a vector of controlled single bit gates ("HamiltonianOp" instances) tha...
Definition: gates.cpp:414
virtual void SqrtW(bitLenInt qubit)
Square root of W gate.
Definition: qinterface.hpp:1160
virtual void IS(bitLenInt qubit)
Inverse S gate.
Definition: qinterface.hpp:997
virtual void MACMtrx(const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits.
Definition: qinterface.hpp:459
virtual void S(bitLenInt qubit)
S gate.
Definition: qinterface.hpp:990
virtual void CT(bitLenInt control, bitLenInt target)
Controlled T gate.
Definition: qinterface.hpp:1267
virtual void Invert(const complex topRight, const complex bottomLeft, bitLenInt qubitIndex)
Apply a single bit transformation that reverses bit probability and might effect phase.
Definition: qinterface.hpp:493
virtual void PhaseParity(real1_f radians, bitCapInt mask)
Parity phase gate.
Definition: gates.cpp:388
virtual void Y(bitLenInt qubit)
Y gate.
Definition: qinterface.hpp:1071
virtual bool ForceM(bitLenInt qubit, bool result, bool doForce=true, bool doApply=true)=0
Act as if is a measurement was applied, except force the (usually random) result.
virtual void CY(bitLenInt control, bitLenInt target)
Controlled Y gate.
Definition: qinterface.hpp:695
virtual void AntiCIPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
(Anti-)controlled inverse "PhaseRootN" gate
Definition: qinterface.hpp:1339
virtual void CH(bitLenInt control, bitLenInt target)
Controlled H gate.
Definition: qinterface.hpp:1189
virtual void AntiCAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
(Anti-)Controlled "Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:103
virtual void H(bitLenInt qubit)
Hadamard gate.
Definition: qinterface.hpp:876
virtual void CIAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
Controlled inverse "Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:89
virtual void CSqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a square root of swap with arbitrary control bits.
Definition: gates.cpp:270
virtual bool M(bitLenInt qubitIndex)
Measurement gate.
Definition: qinterface.hpp:976
virtual void AntiCSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a swap with arbitrary (anti) control bits.
Definition: gates.cpp:258
virtual void AI(bitLenInt target, real1_f azimuth, real1_f inclination)
"Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:53
virtual void AntiCPhaseRootN(bitLenInt n, bitLenInt control, bitLenInt target)
(Anti-)controlled "PhaseRootN" gate
Definition: qinterface.hpp:1307
virtual void MCPhase(const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
Apply a single bit transformation that only effects phase, with arbitrary control bits.
Definition: qinterface.hpp:502
virtual void MACPhase(const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits.
Definition: qinterface.hpp:526
virtual void HIS(bitLenInt qubit)
Y-basis (inverse) transformation gate.
Definition: qinterface.hpp:920
virtual void CAI(bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
Controlled "Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:77
virtual void CCY(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-Controlled Y gate.
Definition: qinterface.hpp:718
virtual void AntiCZ(bitLenInt control, bitLenInt target)
Anti controlled Z gate.
Definition: qinterface.hpp:752
virtual void UniformlyControlledSingleBit(const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs)
Apply a "uniformly controlled" arbitrary single bit unitary transformation.
Definition: qinterface.hpp:590
virtual void AntiCU(const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
(Anti-)Controlled general unitary gate
Definition: rotational.cpp:41
virtual void CISqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply an inverse square root of swap with arbitrary control bits.
Definition: gates.cpp:320
virtual void X(bitLenInt qubit)
X gate.
Definition: qinterface.hpp:1054
virtual void UCMtrx(const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, bitCapInt controlPerm)
Apply an arbitrary single bit unitary transformation, with arbitrary control bits,...
Definition: gates.cpp:23
virtual void U2(bitLenInt target, real1_f phi, real1_f lambda)
2-parameter unitary gate
Definition: qinterface.hpp:794
virtual void Z(bitLenInt qubit)
Z gate.
Definition: qinterface.hpp:1087
virtual void Mtrx(const complex *mtrx, bitLenInt qubitIndex)=0
Apply an arbitrary single bit unitary transformation.
virtual void AntiCNOT(bitLenInt control, bitLenInt target)
Anti controlled NOT gate.
Definition: qinterface.hpp:683
virtual void AntiCY(bitLenInt control, bitLenInt target)
Anti controlled Y gate.
Definition: qinterface.hpp:706
virtual void ISqrtW(bitLenInt qubit)
Inverse square root of W gate.
Definition: qinterface.hpp:1174
virtual void IPhaseRootN(bitLenInt n, bitLenInt qubit)
Inverse "PhaseRootN" gate.
Definition: qinterface.hpp:1032
virtual void IAI(bitLenInt target, real1_f azimuth, real1_f inclination)
Invert "Azimuth, Inclination" (RY-RZ)
Definition: rotational.cpp:64
virtual void AntiCISqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply an inverse square root of swap with arbitrary (anti) control bits.
Definition: gates.cpp:376
virtual void PhaseRootN(bitLenInt n, bitLenInt qubit)
"PhaseRootN" gate
Definition: qinterface.hpp:1018
virtual void U(bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
General unitary gate.
Definition: rotational.cpp:18
virtual void AntiCIS(bitLenInt control, bitLenInt target)
(Anti-)controlled inverse S gate
Definition: qinterface.hpp:1255
virtual void SqrtX(bitLenInt qubit)
Square root of X gate.
Definition: qinterface.hpp:1103
virtual void IU2(bitLenInt target, real1_f phi, real1_f lambda)
Inverse 2-parameter unitary gate.
Definition: qinterface.hpp:801
virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Anti doubly-controlled NOT gate.
Definition: qinterface.hpp:661
virtual void ZMask(bitCapInt mask)
Masked Z gate.
Definition: gates.cpp:143
virtual void SqrtH(bitLenInt qubit)
Square root of Hadamard gate.
Definition: qinterface.hpp:889
virtual void Phase(const complex topLeft, const complex bottomRight, bitLenInt qubitIndex)
Apply a single bit transformation that only effects phase.
Definition: qinterface.hpp:480
virtual void AntiCCY(bitLenInt control1, bitLenInt control2, bitLenInt target)
Anti doubly-controlled Y gate.
Definition: qinterface.hpp:729
virtual void AntiCSqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a square root of swap with arbitrary (anti) control bits.
Definition: gates.cpp:364
virtual void MCMtrx(const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)=0
Apply an arbitrary single bit unitary transformation, with arbitrary control bits.
virtual void CIT(bitLenInt control, bitLenInt target)
Controlled inverse T gate.
Definition: qinterface.hpp:1279
virtual void IT(bitLenInt qubit)
Inverse T gate.
Definition: qinterface.hpp:1011
virtual void MACInvert(const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
Apply a single bit transformation that reverses bit probability and might effect phase,...
Definition: qinterface.hpp:542
virtual void AntiCCZ(bitLenInt control1, bitLenInt control2, bitLenInt target)
Anti doubly-controlled Z gate.
Definition: qinterface.hpp:775
virtual void CSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a swap with arbitrary control bits.
Definition: gates.cpp:234
virtual void T(bitLenInt qubit)
T gate.
Definition: qinterface.hpp:1004
virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-controlled NOT gate.
Definition: qinterface.hpp:650
virtual void AntiCH(bitLenInt control, bitLenInt target)
(Anti-)controlled H gate
Definition: qinterface.hpp:1204
virtual void UCPhase(const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target, bitCapInt perm)
Apply a single bit transformation that only effects phase, with arbitrary control bits,...
Definition: qinterface.hpp:554
virtual void MCInvert(const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
Apply a single bit transformation that reverses bit probability and might effect phase,...
Definition: qinterface.hpp:516
virtual void FSim(real1_f theta, real1_f phi, bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics)
virtual void SetReg(bitLenInt start, bitLenInt length, bitCapInt value)
Set register bits to given permutation.
Definition: qinterface.cpp:189
virtual void IQFTR(const std::vector< bitLenInt > &qubits, bool trySeparate=false)
Inverse Quantum Fourier Transform (random access) - Apply the inverse quantum Fourier transform to th...
Definition: qinterface.cpp:170
virtual void Reverse(bitLenInt first, bitLenInt last)
Reverse all of the bits in a sequence.
Definition: qinterface.hpp:2291
virtual void ISqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Inverse square root of Swap gate.
Definition: gates.cpp:211
virtual void QFTR(const std::vector< bitLenInt > &qubits, bool trySeparate=false)
Quantum Fourier Transform (random access) - Apply the quantum Fourier transform to the register.
Definition: qinterface.cpp:150
virtual bitCapInt ForceMReg(bitLenInt start, bitLenInt length, bitCapInt result, bool doForce=true, bool doApply=true)
Act as if is a measurement was applied, except force the (usually random) result.
Definition: qinterface.cpp:212
virtual void Swap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register.
Definition: gates.cpp:153
virtual void IISwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Inverse ISwap - Swap values of two bits in register, and apply phase factor of -i if bits are differe...
Definition: gates.cpp:176
virtual bitCapInt MAll()
Measure permutation state of all coherent bits.
Definition: qinterface.hpp:2256
virtual void QFT(bitLenInt start, bitLenInt length, bool trySeparate=false)
Quantum Fourier Transform - Apply the quantum Fourier transform to the register.
Definition: qinterface.cpp:108
virtual void PhaseFlip()
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Definition: qinterface.hpp:2247
virtual bitCapInt M(const std::vector< bitLenInt > &bits)
Measure bits with indices in array, and return a mask of the results.
Definition: qinterface.hpp:2267
virtual void ISwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register, and apply phase factor of i if bits are different.
Definition: gates.cpp:164
virtual void ZeroPhaseFlip(bitLenInt start, bitLenInt length)
Reverse the phase of the state where the register equals zero.
Definition: gates.cpp:84
virtual void SqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Square root of Swap gate.
Definition: gates.cpp:188
virtual bitCapInt MReg(bitLenInt start, bitLenInt length)
Measure permutation state of a register.
Definition: qinterface.hpp:2253
virtual void IQFT(bitLenInt start, bitLenInt length, bool trySeparate=false)
Inverse Quantum Fourier Transform - Apply the inverse quantum Fourier transform to the register.
Definition: qinterface.cpp:130
virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "XOR" gate.
Definition: logic.cpp:55
virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "OR" gate.
Definition: logic.cpp:36
virtual void XNOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "XNOR" gate.
Definition: logic.cpp:84
virtual void CLXNOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "XNOR" gate.
Definition: logic.cpp:130
virtual void CLNAND(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "NAND" gate.
Definition: logic.cpp:118
virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "AND" gate.
Definition: logic.cpp:18
virtual void CLAND(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "AND" gate.
Definition: logic.cpp:90
virtual void CLOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "OR" gate.
Definition: logic.cpp:97
virtual void NAND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "NAND" gate.
Definition: logic.cpp:72
virtual void CLNOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "NOR" gate.
Definition: logic.cpp:124
virtual void CLXOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
Quantum analog of classical "XOR" gate.
Definition: logic.cpp:106
virtual void NOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
Quantum analog of classical "NOR" gate.
Definition: logic.cpp:78
virtual void X(bitLenInt start, bitLenInt length)
Bitwise Pauli X (or logical "NOT") operator.
Definition: qinterface.hpp:1680
virtual void H(bitLenInt start, bitLenInt length)
Bitwise Hadamard.
virtual void RTDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction phase shift gate.
Definition: qinterface.cpp:898
virtual void ExpZ(real1_f radians, bitLenInt qubitIndex)
Pauli Z exponentiation gate.
Definition: rotational.cpp:262
virtual void RX(real1_f radians, bitLenInt qubitIndex)
X axis rotation gate.
Definition: rotational.cpp:177
virtual void ExpYDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction Pauli Y exponentiation gate.
Definition: qinterface.cpp:913
virtual void CRTDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target)
Controlled dyadic fraction "phase shift gate".
Definition: qinterface.cpp:935
virtual void RZ(real1_f radians, bitLenInt qubitIndex)
Z axis rotation gate.
Definition: rotational.cpp:196
virtual void ExpZDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction Pauli Z exponentiation gate.
Definition: qinterface.cpp:919
virtual void CRZDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target)
Controlled dyadic fraction Z axis rotation gate.
Definition: qinterface.cpp:953
virtual void RT(real1_f radians, bitLenInt qubitIndex)
Phase shift gate.
Definition: rotational.cpp:171
virtual void RXDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction X axis rotation gate.
Definition: qinterface.cpp:925
virtual void CRZ(real1_f radians, bitLenInt control, bitLenInt target)
Controlled Z axis rotation gate.
Definition: rotational.cpp:204
virtual void Exp(real1_f radians, bitLenInt qubitIndex)
(Identity) Exponentiation gate
Definition: rotational.cpp:225
virtual void RYDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction Y axis rotation gate.
Definition: qinterface.cpp:928
virtual void CRT(real1_f radians, bitLenInt control, bitLenInt target)
Controlled "phase shift gate".
Definition: rotational.cpp:269
virtual void CRY(real1_f radians, bitLenInt control, bitLenInt target)
Controlled Y axis rotation gate.
Definition: rotational.cpp:213
virtual void ExpX(real1_f radians, bitLenInt qubitIndex)
Pauli X exponentiation gate.
Definition: rotational.cpp:248
virtual void CRX(real1_f radians, bitLenInt control, bitLenInt target)
Controlled X axis rotation gate.
Definition: rotational.cpp:276
virtual void ExpDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction (identity) exponentiation gate.
Definition: qinterface.cpp:901
virtual void UniformlyControlledRZ(const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, real1 const *angles)
Apply a "uniformly controlled" rotation of a bit around the Pauli Z axis.
Definition: rotational.cpp:151
virtual void ExpY(real1_f radians, bitLenInt qubitIndex)
Pauli Y exponentiation gate.
Definition: rotational.cpp:255
virtual void RZDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction Z axis rotation gate.
Definition: qinterface.cpp:931
virtual void UniformlyControlledRY(const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, real1 const *angles)
Apply a "uniformly controlled" rotation of a bit around the Pauli Y axis.
Definition: rotational.cpp:130
virtual void RY(real1_f radians, bitLenInt qubitIndex)
Y axis rotation gate.
Definition: rotational.cpp:187
virtual void CRYDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target)
Controlled dyadic fraction y axis rotation gate.
Definition: qinterface.cpp:947
virtual void ExpXDyad(int numerator, int denomPower, bitLenInt qubitIndex)
Dyadic fraction Pauli X exponentiation gate.
Definition: qinterface.cpp:907
virtual void CRXDyad(int numerator, int denomPower, bitLenInt control, bitLenInt target)
Controlled dyadic fraction X axis rotation gate.
Definition: qinterface.cpp:941
virtual void Dump()
If asynchronous work is still running, let the simulator know that it can be aborted.
Definition: qinterface.hpp:2588
virtual bool isBinaryDecisionTree()
Returns "true" if current state representation is definitely a binary decision tree,...
Definition: qinterface.hpp:2594
virtual real1_f ExpectationBitsAll(const std::vector< bitLenInt > &bits, bitCapInt offset=0U)
Get permutation expectation value of bits.
Definition: qinterface.hpp:2394
virtual real1_f ProbMask(bitCapInt mask, bitCapInt permutation)
Direct measure of masked permutation probability.
Definition: qinterface.cpp:270
virtual bool ApproxCompare(QInterfacePtr toCompare, real1_f error_tol=TRYDECOMPOSE_EPSILON)
Compare state vectors approximately, component by component, to determine whether this state vector i...
Definition: qinterface.hpp:2545
virtual bool isClifford(bitLenInt qubit)
Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is no...
Definition: qinterface.hpp:2606
virtual real1_f FirstNonzeroPhase()
Get phase of lowest permutation nonzero amplitude.
Definition: qinterface.hpp:2709
virtual real1_f ExpectationBitsFactorizedRdm(bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0)
Get (reduced density matrix) expectation value of bits, given an array of qubit weights.
Definition: qinterface.hpp:2426
virtual real1_f CProb(bitLenInt control, bitLenInt target)
Direct measure of bit probability to be in |1> state, if control bit is |1>.
Definition: qinterface.hpp:2319
virtual double GetUnitaryFidelity()
When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1....
Definition: qinterface.hpp:2644
virtual void SetSdrp(real1_f sdrp)
Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1)
Definition: qinterface.hpp:2652
virtual bool TrySeparate(bitLenInt qubit1, bitLenInt qubit2)
Two-qubit TrySeparate()
Definition: qinterface.hpp:2634
virtual bool isClifford()
Returns "true" if current state is identifiably within the Clifford set, or "false" if it is not or c...
Definition: qinterface.hpp:2600
virtual real1_f Prob(bitLenInt qubitIndex)=0
Direct measure of bit probability to be in |1> state.
virtual real1_f ProbAll(bitCapInt fullRegister)
Direct measure of full permutation probability.
Definition: qinterface.hpp:2346
virtual QInterfacePtr Clone()=0
Clone this QInterface.
virtual bitLenInt DepolarizingChannelStrong1Qb(bitLenInt qubit, real1_f lambda)
Simulate a local qubit depolarizing noise channel, under a "strong simulation condition....
Definition: gates.cpp:500
virtual real1_f ACProb(bitLenInt control, bitLenInt target)
Direct measure of bit probability to be in |1> state, if control bit is |0>.
Definition: qinterface.hpp:2332
virtual real1_f ProbAllRdm(bool roundRz, bitCapInt fullRegister)
Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate...
Definition: qinterface.hpp:2470
virtual void Finish()
If asynchronous work is still running, block until it finishes.
Definition: qinterface.hpp:2576
virtual real1_f ProbMaskRdm(bool roundRz, bitCapInt mask, bitCapInt permutation)
Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T ga...
Definition: qinterface.hpp:2480
virtual bool GetReactiveSeparate()
Get reactive separation option.
Definition: qinterface.hpp:2668
virtual std::map< bitCapInt, int > MultiShotMeasureMask(const std::vector< bitCapInt > &qPowers, unsigned shots)
Statistical measure of masked permutation probability.
Definition: qinterface.cpp:541
virtual void SetTInjection(bool useGadget)
Set the option to use T-injection gadgets (off by default)
Definition: qinterface.hpp:2676
virtual void ResetUnitaryFidelity()
Reset the internal fidelity calculation tracker to 1.0.
Definition: qinterface.hpp:2648
virtual bool TryDecompose(bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
Definition: qinterface.cpp:569
virtual void ProbBitsAll(const std::vector< bitLenInt > &bits, real1 *probsArray)
Direct measure of listed permutation probability.
Definition: qinterface.cpp:436
bitCapIntOcl GetMaxSize()
Get maximum number of amplitudes that can be allocated on current device.
Definition: qinterface.hpp:2704
virtual bool GetTInjection()
Get the option to use T-injection gadgets.
Definition: qinterface.hpp:2684
virtual void SetReactiveSeparate(bool isAggSep)
Set reactive separation option (on by default if available)
Definition: qinterface.hpp:2660
virtual real1_f ExpectationBitsAllRdm(bool roundRz, const std::vector< bitLenInt > &bits, bitCapInt offset=0U)
Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadg...
Definition: qinterface.hpp:2492
virtual void UpdateRunningNorm(real1_f norm_thresh=REAL1_DEFAULT_ARG)=0
Force a calculation of the norm of the state vector, in order to make it unit length before the next ...
virtual void DepolarizingChannelWeak1Qb(bitLenInt qubit, real1_f lambda)
Simulate a local qubit depolarizing noise channel, under a stochastic "weak simulation condition....
Definition: gates.cpp:475
virtual bool isOpenCL()
Returns "true" if current simulation is OpenCL-based.
Definition: qinterface.hpp:2611
virtual real1_f ExpectationFloatsFactorized(const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
Get expectation value of bits, given a (floating-point) array of qubit weights.
Definition: qinterface.cpp:510
virtual int64_t GetDevice()
Get the device index.
Definition: qinterface.hpp:2699
virtual real1_f ProbReg(bitLenInt start, bitLenInt length, bitCapInt permutation)
Direct measure of register permutation probability.
Definition: qinterface.cpp:254
virtual bool TrySeparate(const std::vector< bitLenInt > &qubits, real1_f error_tol)
Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory us...
Definition: qinterface.hpp:2626
virtual real1_f SumSqrDiff(QInterfacePtr toCompare)=0
virtual void SetBit(bitLenInt qubit, bool value)
Set individual bit to pure |0> (false) or |1> (true) state.
Definition: qinterface.hpp:2532
virtual void NormalizeState(real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)=0
Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate.
virtual real1_f ExpectationFloatsFactorizedRdm(bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weigh...
Definition: qinterface.hpp:2452
virtual real1_f ExpectationBitsFactorized(const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U)
Get expectation value of bits, given an array of qubit weights.
Definition: qinterface.cpp:469
virtual void ProbMaskAll(bitCapInt mask, real1 *probsArray)
Direct measure of masked permutation probability.
Definition: qinterface.cpp:413
virtual real1_f ProbRdm(bitLenInt qubitIndex)
Direct measure of bit probability to be in |1> state, treating all ancillary qubits as post-selected ...
Definition: qinterface.hpp:2464
virtual void SetDevice(int64_t dID)=0
Set the device index, if more than one device is available.
virtual bool TrySeparate(bitLenInt qubit)
Single-qubit TrySeparate()
Definition: qinterface.hpp:2630
virtual bool isFinished()
Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynch...
Definition: qinterface.hpp:2582
Definition: complex16x2simd.hpp:25
bitCapInt bitRegMask(const bitLenInt &start, const bitLenInt &length)
Definition: qrack_functions.hpp:53
std::complex< half_float::half > complex
Definition: qrack_types.hpp:62
QInterfaceEngine
Enumerated list of supported engines.
Definition: qinterface.hpp:50
@ QINTERFACE_OPTIMAL_BASE
Definition: qinterface.hpp:129
@ QINTERFACE_QPAGER
Create a QPager, which breaks up the work of a QEngine into equally sized "pages.".
Definition: qinterface.hpp:95
@ QINTERFACE_OPTIMAL_SCHROEDINGER
Definition: qinterface.hpp:127
@ QINTERFACE_OPTIMAL_MULTI
Definition: qinterface.hpp:134
@ QINTERFACE_CUDA
Create a QEngineCUDA, leveraging CUDA hardware to increase the speed of certain calculations.
Definition: qinterface.hpp:65
@ QINTERFACE_STABILIZER_HYBRID
Create a QStabilizerHybrid, switching between a QStabilizer and a QHybrid as efficient.
Definition: qinterface.hpp:90
@ QINTERFACE_HYBRID
Create a QHybrid, switching between QEngineCPU and QEngineOCL as efficient.
Definition: qinterface.hpp:70
@ QINTERFACE_OPTIMAL
Definition: qinterface.hpp:132
@ QINTERFACE_BDT_HYBRID
Create a QBinaryDecisionTree, (CPU-based).
Definition: qinterface.hpp:80
@ QINTERFACE_BDT
Create a QBinaryDecisionTree, (CPU-based).
Definition: qinterface.hpp:75
@ QINTERFACE_TENSOR_NETWORK
Circuit-simplification layer, with (optional) recourse to cuTensorNetwork.
Definition: qinterface.hpp:120
@ QINTERFACE_QUNIT_CLIFFORD
Clifford-specialized QUnit.
Definition: qinterface.hpp:115
@ QINTERFACE_OPENCL
Create a QEngineOCL, leveraging OpenCL hardware to increase the speed of certain calculations.
Definition: qinterface.hpp:60
@ QINTERFACE_STABILIZER
Create a QStabilizer, limited to Clifford/Pauli operations, but efficient.
Definition: qinterface.hpp:85
@ QINTERFACE_QUNIT
Create a QUnit, which utilizes other QInterface classes to minimize the amount of work that's needed ...
Definition: qinterface.hpp:104
@ QINTERFACE_QUNIT_MULTI
Create a QUnitMulti, which distributes the explicitly separated "shards" of a QUnit across available ...
Definition: qinterface.hpp:110
@ QINTERFACE_MAX
Definition: qinterface.hpp:136
@ QINTERFACE_CPU
Create a QEngineCPU leveraging only local CPU and memory resources.
Definition: qinterface.hpp:55
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:28
QRACK_CONST real1_f TRYDECOMPOSE_EPSILON
Definition: qrack_types.hpp:244
constexpr real1_f ZERO_R1_F
Definition: qrack_types.hpp:152
QRACK_CONST complex C_SQRT1_2_NEG
Definition: gates.cpp:21
const real1 ONE_R1
Definition: qrack_types.hpp:153
constexpr real1_f ONE_R1_F
Definition: qrack_types.hpp:154
const real1 SQRT2_R1
Definition: qrack_types.hpp:159
bitCapInt pow2(const bitLenInt &p)
Definition: qrack_functions.hpp:22
double norm(const complex2 &c)
Definition: complex16x2simd.hpp:101
const real1 REAL1_DEFAULT_ARG
Definition: qrack_types.hpp:155
const real1 PI_R1
Definition: qrack_types.hpp:158
QRACK_CONST complex ONE_CMPLX
Definition: qrack_types.hpp:239
std::vector< HamiltonianOpPtr > Hamiltonian
Definition: hamiltonian.hpp:121
const real1 ZERO_R1
Definition: qrack_types.hpp:151
float real1_f
Definition: qrack_types.hpp:64
QRACK_CONST complex CMPLX_DEFAULT_ARG
Definition: qrack_types.hpp:242
QRACK_CONST complex I_CMPLX
Definition: qrack_types.hpp:241
QRACK_CONST complex C_SQRT1_2
Definition: gates.cpp:17
const real1 REAL1_EPSILON
Definition: qrack_types.hpp:157
Pauli
Enumerated list of Pauli bases.
Definition: qinterface.hpp:34
@ PauliX
Pauli X operator. Corresponds to Q# constant "PauliX.".
Definition: qinterface.hpp:38
@ PauliY
Pauli Y operator. Corresponds to Q# constant "PauliY.".
Definition: qinterface.hpp:40
@ PauliZ
Pauli Z operator. Corresponds to Q# constant "PauliZ.".
Definition: qinterface.hpp:42
@ PauliI
Pauli Identity operator. Corresponds to Q# constant "PauliI.".
Definition: qinterface.hpp:36
QRACK_CONST complex ZERO_CMPLX
Definition: qrack_types.hpp:240
bitCapIntOcl pow2Ocl(const bitLenInt &p)
Definition: qrack_functions.hpp:23
const real1 SQRT1_2_R1
Definition: qrack_types.hpp:160
HALF_CONSTEXPR half abs(half arg)
Absolute value.
Definition: half.hpp:2975
half sin(half arg)
Sine function.
Definition: half.hpp:3885
half cos(half arg)
Cosine function.
Definition: half.hpp:3922
half pow(half x, half y)
Power function.
Definition: half.hpp:3738
MICROSOFT_QUANTUM_DECL void seed(_In_ uintq sid, _In_ uintq s)
(External API) Set RNG seed for simulator ID
Definition: pinvoke_api.cpp:922
#define QRACK_CONST
Definition: qrack_types.hpp:150
#define bitLenInt
Definition: qrack_types.hpp:44
#define qrack_rand_gen_ptr
Definition: qrack_types.hpp:146
#define bitCapInt
Definition: qrack_types.hpp:105
#define bitCapIntOcl
Definition: qrack_types.hpp:91
#define IS_NORM_0(c)
Definition: qrack_types.hpp:27
#define C_I_SQRT1_2
Definition: qstabilizer.cpp:359