Qrack  10.0
General classical-emulating-quantum development framework
qtensornetwork.hpp
Go to the documentation of this file.
1 //
3 // (C) Daniel Strano and the Qrack contributors 2017-2023. All rights reserved.
4 //
5 // QTensorNetwork is a gate-based QInterface descendant wrapping cuQuantum.
6 //
7 // Licensed under the GNU Lesser General Public License V3.
8 // See LICENSE.md in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html
9 // for details.
10 
11 #pragma once
12 
13 #include "qcircuit.hpp"
14 
15 namespace Qrack {
16 
17 class QTensorNetwork;
18 typedef std::shared_ptr<QTensorNetwork> QTensorNetworkPtr;
19 
20 // #if ENABLE_CUDA
21 // struct TensorMeta {
22 // std::vector<std::vector<int32_t>> modes;
23 // std::vector<std::vector<int64_t>> extents;
24 // };
25 // typedef std::vector<TensorMeta> TensorNetworkMeta;
26 // typedef std::shared_ptr<TensorNetworkMeta> TensorNetworkMetaPtr;
27 // #endif
28 
29 #if ENABLE_ALU
30 class QTensorNetwork : public QAlu, public QInterface {
31 #else
32 class QTensorNetwork : public QInterface {
33 #endif
34 protected:
35  bool useHostRam;
36  bool isSparse;
38  bool useTGadget;
40 #if ENABLE_OPENCL || ENABLE_CUDA
41  bool isCpu;
42 #endif
43 #if ENABLE_QBDT
44  bool isQBdt;
45 #endif
46  int64_t devID;
47  size_t aceMb;
53  std::vector<int64_t> deviceIDs;
54  std::vector<QInterfaceEngine> engines;
56 
58  {
59  if (target >= qubitCount) {
60  throw std::invalid_argument("QTensorNetwork qubit index values must be within allocated qubit bounds!");
61  }
62  }
63 
64  void CheckQubitCount(bitLenInt target, const std::vector<bitLenInt>& controls)
65  {
66  CheckQubitCount(target);
68  controls, qubitCount, "QTensorNetwork qubit index values must be within allocated qubit bounds!");
69  }
70 
71  void MakeLayerStack();
72 
73  template <typename Fn> void RunAsAmplitudes(Fn fn, std::set<bitLenInt> qubits = std::set<bitLenInt>())
74  {
75  if (qubits.size()) {
76  circuit->RemovePastLightCone(qubits)->Run(layerStack);
77  } else {
78  circuit->Run(layerStack);
79  circuit = std::make_shared<QCircuit>(true, isNearClifford);
80  }
81 
82  return fn(layerStack);
83  }
84 
85 public:
86  QTensorNetwork(std::vector<QInterfaceEngine> eng, bitLenInt qBitCount, const bitCapInt& initState = ZERO_BCI,
87  qrack_rand_gen_ptr rgp = nullptr, const complex& phaseFac = CMPLX_DEFAULT_ARG, bool doNorm = false,
88  bool randomGlobalPhase = true, bool useHostMem = false, int64_t deviceId = -1, bool useHardwareRNG = true,
89  bool useSparseStateVec = false, real1_f norm_thresh = REAL1_EPSILON, std::vector<int64_t> ignored = {},
90  bitLenInt qubitThreshold = 0, real1_f separation_thresh = _qrack_qunit_sep_thresh);
91 
92  QTensorNetwork(bitLenInt qBitCount, const bitCapInt& initState = ZERO_BCI, qrack_rand_gen_ptr rgp = nullptr,
93  const complex& phaseFac = CMPLX_DEFAULT_ARG, bool doNorm = false, bool randomGlobalPhase = true,
94  bool useHostMem = false, int64_t deviceId = -1, bool useHardwareRNG = true, bool useSparseStateVec = false,
95  real1_f norm_thresh = REAL1_EPSILON, std::vector<int64_t> devList = {}, bitLenInt qubitThreshold = 0U,
96  real1_f separation_thresh = _qrack_qunit_sep_thresh)
97  : QTensorNetwork({}, qBitCount, initState, rgp, phaseFac, doNorm, randomGlobalPhase, useHostMem, deviceId,
98  useHardwareRNG, useSparseStateVec, norm_thresh, devList, qubitThreshold, separation_thresh)
99  {
100  }
101 
102  bool AreFactorized(std::vector<bitLenInt> a, std::vector<bitLenInt> b, bool flushCache = false)
103  {
104  std::set<bitLenInt> q(a.begin(), a.end());
105  q.insert(b.begin(), b.end());
106 
107  bool toRet;
108  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->AreFactorized(a, b, flushCache); }, q);
109 
110  return toRet;
111  }
112 
113  void SetSdrp(real1_f sdrp)
114  {
115  separabilityThreshold = sdrp;
117  layerStack->SetSdrp(sdrp);
118  }
119 
120  void SetReactiveSeparate(bool isAggSep) { isReactiveSeparate = isAggSep; }
121 
122  void SetTInjection(bool useGadget)
123  {
124  useTGadget = useGadget;
125  layerStack->SetTInjection(useTGadget);
126  }
127 
128  void SetNcrp(real1_f rp)
129  {
130  ncrp = rp;
131  layerStack->SetNcrp(ncrp);
132  }
133 
135  {
136  aceQubits = qb;
137  layerStack->SetAceMaxQubits(aceQubits);
138  }
139 
140  void SetSparseAceMaxMb(size_t mb)
141  {
142  aceMb = mb;
143  layerStack->SetSparseAceMaxMb(aceMb);
144  }
145 
147  {
148  double toRet;
149  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->GetUnitaryFidelity(); });
150  return toRet;
151  }
152 
154  {
155  bitCapInt toRet;
156  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->HighestProbAll(); });
157  return toRet;
158  }
159 
160  void SetDevice(int64_t dID) { devID = dID; }
161  void SetDeviceList(std::vector<int64_t> dIDs) { deviceIDs = dIDs; }
162  int64_t GetDevice() { return devID; }
163  std::vector<int64_t> GetDeviceList() { return deviceIDs; }
164 
165  void Finish() { layerStack->Finish(); };
166 
167  bool isFinished() { return layerStack->isFinished(); }
168 
169  void Dump() { layerStack->Dump(); }
170 
171  void UpdateRunningNorm(real1_f norm_thresh = REAL1_DEFAULT_ARG) { layerStack->UpdateRunningNorm(norm_thresh); }
172 
174  real1_f nrm = REAL1_DEFAULT_ARG, real1_f norm_thresh = REAL1_DEFAULT_ARG, real1_f phaseArg = ZERO_R1_F)
175  {
176  layerStack->NormalizeState(nrm, norm_thresh, phaseArg);
177  }
178 
180  {
181  return SumSqrDiff(std::dynamic_pointer_cast<QTensorNetwork>(toCompare));
182  }
184  {
185  real1_f toRet;
186  toCompare->RunAsAmplitudes([&](QInterfacePtr ls) {});
187  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->SumSqrDiff(toCompare->layerStack); });
188  return toRet;
189  }
190 
191  void SetPermutation(const bitCapInt& initState, const complex& phaseFac = CMPLX_DEFAULT_ARG)
192  {
193  circuit = std::make_shared<QCircuit>(true, isNearClifford);
194  MakeLayerStack();
195  layerStack->SetPermutation(initState, phaseFac);
196  }
197 
199 
200  void LossySaveStateVector(std::string f, int p = 6, int b = 4)
201  {
202  RunAsAmplitudes([&](QInterfacePtr ls) { ls->LossySaveStateVector(f, p, b); });
203  }
204  void LossyLoadStateVector(std::string f)
205  {
206  RunAsAmplitudes([&](QInterfacePtr ls) { ls->LossyLoadStateVector(f); });
207  }
208 
210  {
211  RunAsAmplitudes([&](QInterfacePtr ls) { ls->GetQuantumState(state); });
212  }
213  void SetQuantumState(const complex* state)
214  {
215  RunAsAmplitudes([&](QInterfacePtr ls) { ls->SetQuantumState(state); });
216  }
218  {
219  const QTensorNetworkPtr tnEng = std::dynamic_pointer_cast<QTensorNetwork>(eng);
220 
221  if (tnEng->qubitCount != qubitCount) {
222  throw std::invalid_argument("QTensorNetwork::SetQuantumState() argument must match in qubit count!");
223  }
224 
225  layerStack = tnEng->layerStack->Clone();
226  circuit = tnEng->circuit->Clone();
227  }
228  void GetProbs(real1* outputProbs)
229  {
230  RunAsAmplitudes([&](QInterfacePtr ls) { ls->GetProbs(outputProbs); });
231  }
232 
234  {
235  complex toRet;
236  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->GetAmplitude(perm); });
237  return toRet;
238  }
239  void SetAmplitude(const bitCapInt& perm, const complex& amp)
240  {
241  RunAsAmplitudes([&](QInterfacePtr ls) { ls->SetAmplitude(perm, amp); });
242  }
243 
244  using QInterface::Compose;
246  {
247  bitLenInt toRet;
248  std::dynamic_pointer_cast<QTensorNetwork>(toCopy)->RunAsAmplitudes([&](QInterfacePtr ls) {});
250  toRet = ls->Compose(std::dynamic_pointer_cast<QTensorNetwork>(toCopy)->layerStack, start);
251  });
252  SetQubitCount(qubitCount + toCopy->GetQubitCount());
253  return toRet;
254  }
256  {
257  dest->SetPermutation(0U);
258  std::dynamic_pointer_cast<QTensorNetwork>(dest)->MakeLayerStack();
260  ls->Decompose(start, std::dynamic_pointer_cast<QTensorNetwork>(dest)->layerStack);
261  });
262  SetQubitCount(qubitCount - dest->GetQubitCount());
263  }
265  void Dispose(bitLenInt start, bitLenInt length)
266  {
267  RunAsAmplitudes([&](QInterfacePtr ls) { ls->Dispose(start, length); });
268  SetQubitCount(qubitCount - length);
269  }
270  void Dispose(bitLenInt start, bitLenInt length, const bitCapInt& disposedPerm)
271  {
272  RunAsAmplitudes([&](QInterfacePtr ls) { ls->Dispose(start, length, disposedPerm); });
273  SetQubitCount(qubitCount - length);
274  }
276  {
277  bool toRet;
278  dest->SetPermutation(0U);
280  toRet = ls->TryDecompose(start, std::dynamic_pointer_cast<QTensorNetwork>(dest)->layerStack, error_tol);
281  });
282  SetQubitCount(qubitCount - dest->GetQubitCount());
283  return toRet;
284  }
285  bool TrySeparate(const std::vector<bitLenInt>& qubits, real1_f error_tol)
286  {
287  return layerStack->TrySeparate(qubits, error_tol);
288  }
289  bool TrySeparate(bitLenInt qubit) { return layerStack->TrySeparate(qubit); }
290  bool TrySeparate(bitLenInt qubit1, bitLenInt qubit2) { return layerStack->TrySeparate(qubit1, qubit2); }
291 
292  using QInterface::Allocate;
294  {
295  if (start > qubitCount) {
296  throw std::invalid_argument("QTensorNetwork::Allocate() 'start' argument is out-of-bounds!");
297  }
298 
299  if (!length) {
300  return start;
301  }
302 
303  layerStack->Allocate(length);
304  const bitLenInt movedQubits = qubitCount - start;
305  SetQubitCount(qubitCount + length);
306 
307  for (bitLenInt i = 0U; i < movedQubits; ++i) {
308  const bitLenInt q = start + movedQubits - (i + 1U);
309  Swap(q, q + length);
310  }
311 
312  return start;
313  }
314 
316  {
317  real1_f toRet;
318  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->Prob(qubit); }, { qubit });
319  return toRet;
320  }
321  real1_f ProbAll(const bitCapInt& fullRegister)
322  {
323  real1_f toRet;
324  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->ProbAll(fullRegister); });
325  return toRet;
326  }
327 
328  bool ForceM(bitLenInt qubit, bool result, bool doForce = true, bool doApply = true)
329  {
330  bool toRet;
331  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->ForceM(qubit, result, doForce, doApply); }, { qubit });
332  return toRet;
333  }
334 
335  std::map<bitCapInt, int> MultiShotMeasureMask(const std::vector<bitCapInt>& qPowers, unsigned shots)
336  {
337  std::map<bitCapInt, int> toRet;
338  std::set<bitLenInt> qubits;
339  for (const bitCapInt& qPow : qPowers) {
340  qubits.insert(log2(qPow));
341  }
342  RunAsAmplitudes([&](QInterfacePtr ls) { toRet = ls->MultiShotMeasureMask(qPowers, shots); }, qubits);
343  return toRet;
344  }
345  void MultiShotMeasureMask(const std::vector<bitCapInt>& qPowers, unsigned shots, unsigned long long* shotsArray)
346  {
347  std::map<bitCapInt, int> toRet;
348  std::set<bitLenInt> qubits;
349  for (const bitCapInt& qPow : qPowers) {
350  qubits.insert(log2(qPow));
351  }
352  RunAsAmplitudes([&](QInterfacePtr ls) { ls->MultiShotMeasureMask(qPowers, shots, shotsArray); }, qubits);
353  }
354 
355  void Mtrx(const complex mtrx[4U], bitLenInt target)
356  {
357  CheckQubitCount(target);
358  circuit->AppendGate(std::make_shared<QCircuitGate>(target, mtrx));
359  }
360  void MCMtrx(const std::vector<bitLenInt>& controls, const complex mtrx[4U], bitLenInt target)
361  {
362  CheckQubitCount(target, controls);
363  bitCapInt m = pow2(controls.size());
364  bi_decrement(&m, 1U);
365  circuit->AppendGate(
366  std::make_shared<QCircuitGate>(target, mtrx, std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
367  }
368  void MACMtrx(const std::vector<bitLenInt>& controls, const complex mtrx[4U], bitLenInt target)
369  {
370  CheckQubitCount(target, controls);
371  circuit->AppendGate(std::make_shared<QCircuitGate>(
372  target, mtrx, std::set<bitLenInt>{ controls.begin(), controls.end() }, ZERO_BCI));
373  }
374  void MCPhase(
375  const std::vector<bitLenInt>& controls, const complex& topLeft, const complex& bottomRight, bitLenInt target)
376  {
377  CheckQubitCount(target, controls);
378  std::shared_ptr<complex> lMtrx(new complex[4U], std::default_delete<complex[]>());
379  lMtrx.get()[0U] = topLeft;
380  lMtrx.get()[1U] = ZERO_CMPLX;
381  lMtrx.get()[2U] = ZERO_CMPLX;
382  lMtrx.get()[3U] = bottomRight;
383  bitCapInt m = pow2(controls.size());
384  bi_decrement(&m, 1U);
385  circuit->AppendGate(std::make_shared<QCircuitGate>(
386  target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
387  }
388  void MACPhase(
389  const std::vector<bitLenInt>& controls, const complex& topLeft, const complex& bottomRight, bitLenInt target)
390  {
391  CheckQubitCount(target, controls);
392  std::shared_ptr<complex> lMtrx(new complex[4U], std::default_delete<complex[]>());
393  lMtrx.get()[0U] = topLeft;
394  lMtrx.get()[1U] = ZERO_CMPLX;
395  lMtrx.get()[2U] = ZERO_CMPLX;
396  lMtrx.get()[3U] = bottomRight;
397  circuit->AppendGate(std::make_shared<QCircuitGate>(
398  target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, ZERO_BCI));
399  }
400  void MCInvert(
401  const std::vector<bitLenInt>& controls, const complex& topRight, const complex& bottomLeft, bitLenInt target)
402  {
403  CheckQubitCount(target, controls);
404  std::shared_ptr<complex> lMtrx(new complex[4U], std::default_delete<complex[]>());
405  lMtrx.get()[0U] = ZERO_CMPLX;
406  lMtrx.get()[1U] = topRight;
407  lMtrx.get()[2U] = bottomLeft;
408  lMtrx.get()[3U] = ZERO_CMPLX;
409  bitCapInt m = pow2(controls.size());
410  bi_decrement(&m, 1U);
411  circuit->AppendGate(std::make_shared<QCircuitGate>(
412  target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
413  }
414  void MACInvert(
415  const std::vector<bitLenInt>& controls, const complex& topRight, const complex& bottomLeft, bitLenInt target)
416  {
417  CheckQubitCount(target, controls);
418  std::shared_ptr<complex> lMtrx(new complex[4U], std::default_delete<complex[]>());
419  lMtrx.get()[0U] = ZERO_CMPLX;
420  lMtrx.get()[1U] = topRight;
421  lMtrx.get()[2U] = bottomLeft;
422  lMtrx.get()[3U] = ZERO_CMPLX;
423  circuit->AppendGate(std::make_shared<QCircuitGate>(
424  target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, ZERO_BCI));
425  }
426 
427 #if ENABLE_ALU
428  using QInterface::M;
429  bool M(bitLenInt q) { return QInterface::M(q); }
430  using QInterface::X;
431  void X(bitLenInt q) { QInterface::X(q); }
432 
439  void DEC(const bitCapInt& toSub, bitLenInt start, bitLenInt length) { QInterface::DEC(toSub, start, length); }
440  void DECS(const bitCapInt& toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
441  {
442  QInterface::DECS(toSub, start, length, overflowIndex);
443  }
444  void CINC(const bitCapInt& toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector<bitLenInt>& controls)
445  {
446  QInterface::CINC(toAdd, inOutStart, length, controls);
447  }
448  void CDEC(const bitCapInt& toSub, bitLenInt inOutStart, bitLenInt length, const std::vector<bitLenInt>& controls)
449  {
450  QInterface::CDEC(toSub, inOutStart, length, controls);
451  }
452  void INCDECC(const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
453  {
454  QInterface::INCDECC(toAdd, start, length, carryIndex);
455  }
457  const bitCapInt& toMul, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
458  {
459  QInterface::MULModNOut(toMul, modN, inStart, outStart, length);
460  }
462  const bitCapInt& toMul, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
463  {
464  QInterface::IMULModNOut(toMul, modN, inStart, outStart, length);
465  }
466  void CMULModNOut(const bitCapInt& toMul, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart,
467  bitLenInt length, const std::vector<bitLenInt>& controls)
468  {
469  QInterface::CMULModNOut(toMul, modN, inStart, outStart, length, controls);
470  }
471  void CIMULModNOut(const bitCapInt& toMul, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart,
472  bitLenInt length, const std::vector<bitLenInt>& controls)
473  {
474  QInterface::CIMULModNOut(toMul, modN, inStart, outStart, length, controls);
475  }
476 
477  void INC(const bitCapInt& toAdd, bitLenInt start, bitLenInt length)
478  {
479  RunAsAmplitudes([&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INC(toAdd, start, length); });
480  }
481  void INCC(const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
482  {
484  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCC(toAdd, start, length, carryIndex); });
485  }
486  void INCS(const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
487  {
489  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCS(toAdd, start, length, overflowIndex); });
490  }
491  void INCDECSC(
492  const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
493  {
495  std::dynamic_pointer_cast<QAlu>(ls)->INCDECSC(toAdd, start, length, overflowIndex, carryIndex);
496  });
497  }
498  void INCDECSC(const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
499  {
501  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCDECSC(toAdd, start, length, carryIndex); });
502  }
503  void DECC(const bitCapInt& toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
504  {
506  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->DECC(toSub, start, length, carryIndex); });
507  }
508 #if ENABLE_BCD
509  void INCBCD(const bitCapInt& toAdd, bitLenInt start, bitLenInt length)
510  {
511  RunAsAmplitudes([&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCBCD(toAdd, start, length); });
512  }
513  void DECBCD(const bitCapInt& toAdd, bitLenInt start, bitLenInt length)
514  {
515  RunAsAmplitudes([&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->DECBCD(toAdd, start, length); });
516  }
517  void INCDECBCDC(const bitCapInt& toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
518  {
520  std::dynamic_pointer_cast<QAlu>(ls)->INCDECBCDC(toAdd, start, length, carryIndex);
521  });
522  }
523 #endif
524  void MUL(const bitCapInt& toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
525  {
527  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->MUL(toMul, inOutStart, carryStart, length); });
528  }
529  void DIV(const bitCapInt& toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
530  {
532  [&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->DIV(toDiv, inOutStart, carryStart, length); });
533  }
535  const bitCapInt& base, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
536  {
538  std::dynamic_pointer_cast<QAlu>(ls)->POWModNOut(base, modN, inStart, outStart, length);
539  });
540  }
541  void CMUL(const bitCapInt& toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length,
542  const std::vector<bitLenInt>& controls)
543  {
545  std::dynamic_pointer_cast<QAlu>(ls)->CMUL(toMul, inOutStart, carryStart, length, controls);
546  });
547  }
548  void CDIV(const bitCapInt& toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length,
549  const std::vector<bitLenInt>& controls)
550  {
552  std::dynamic_pointer_cast<QAlu>(ls)->CDIV(toDiv, inOutStart, carryStart, length, controls);
553  });
554  }
555  void CPOWModNOut(const bitCapInt& base, const bitCapInt& modN, bitLenInt inStart, bitLenInt outStart,
556  bitLenInt length, const std::vector<bitLenInt>& controls)
557  {
559  std::dynamic_pointer_cast<QAlu>(ls)->CPOWModNOut(base, modN, inStart, outStart, length, controls);
560  });
561  }
562  bitCapInt IndexedLDA(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength,
563  const unsigned char* values, bool resetValue = true)
564  {
565  bitCapInt toRet;
567  toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedLDA(
568  indexStart, indexLength, valueStart, valueLength, values, resetValue);
569  });
570 
571  return toRet;
572  }
573  bitCapInt IndexedADC(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength,
574  bitLenInt carryIndex, const unsigned char* values)
575  {
576  bitCapInt toRet;
578  toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedADC(
579  indexStart, indexLength, valueStart, valueLength, carryIndex, values);
580  });
581 
582  return toRet;
583  }
584  bitCapInt IndexedSBC(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength,
585  bitLenInt carryIndex, const unsigned char* values)
586  {
587  bitCapInt toRet;
589  toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedSBC(
590  indexStart, indexLength, valueStart, valueLength, carryIndex, values);
591  });
592 
593  return toRet;
594  }
595  void Hash(bitLenInt start, bitLenInt length, const unsigned char* values)
596  {
597  RunAsAmplitudes([&](QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->Hash(start, length, values); });
598  }
599  void CPhaseFlipIfLess(const bitCapInt& greaterPerm, bitLenInt start, bitLenInt length, bitLenInt flagIndex)
600  {
602  std::dynamic_pointer_cast<QAlu>(ls)->CPhaseFlipIfLess(greaterPerm, start, length, flagIndex);
603  });
604  }
605  void PhaseFlipIfLess(const bitCapInt& greaterPerm, bitLenInt start, bitLenInt length)
606  {
608  std::dynamic_pointer_cast<QAlu>(ls)->PhaseFlipIfLess(greaterPerm, start, length);
609  });
610  }
611 
613 #endif
614 };
615 } // namespace Qrack
void bi_decrement(BigInteger *pBigInt, const BIG_INTEGER_WORD &value)
Definition: big_integer.hpp:238
Definition: qalu.hpp:22
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:141
virtual bitLenInt Allocate(bitLenInt length)
Allocate new "length" count of |0> state qubits at end of qubit index position.
Definition: qinterface.hpp:488
virtual bitLenInt Compose(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qinterface.hpp:382
virtual void SetQubitCount(bitLenInt qb)
Definition: qinterface.hpp:268
bitLenInt qubitCount
Definition: qinterface.hpp:146
Definition: qtensornetwork.hpp:30
void GetProbs(real1 *outputProbs)
Get the pure quantum state representation.
Definition: qtensornetwork.hpp:228
QTensorNetwork(bitLenInt qBitCount, const bitCapInt &initState=ZERO_BCI, qrack_rand_gen_ptr rgp=nullptr, const complex &phaseFac=CMPLX_DEFAULT_ARG, bool doNorm=false, bool randomGlobalPhase=true, bool useHostMem=false, int64_t deviceId=-1, bool useHardwareRNG=true, bool useSparseStateVec=false, real1_f norm_thresh=REAL1_EPSILON, std::vector< int64_t > devList={}, bitLenInt qubitThreshold=0U, real1_f separation_thresh=_qrack_qunit_sep_thresh)
Definition: qtensornetwork.hpp:92
bool useTGadget
Definition: qtensornetwork.hpp:38
void SetQuantumState(const complex *state)
Set an arbitrary pure quantum state representation.
Definition: qtensornetwork.hpp:213
void Decompose(bitLenInt start, QInterfacePtr dest)
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
Definition: qtensornetwork.hpp:255
void LossyLoadStateVector(std::string f)
Read the quantum state from disk with lossy compression.
Definition: qtensornetwork.hpp:204
bool isSparse
Definition: qtensornetwork.hpp:36
bool TrySeparate(bitLenInt qubit)
Single-qubit TrySeparate()
Definition: qtensornetwork.hpp:289
bool useHostRam
Definition: qtensornetwork.hpp:35
void SetTInjection(bool useGadget)
Set the option to use T-injection gadgets (off by default)
Definition: qtensornetwork.hpp:122
void SetDeviceList(std::vector< int64_t > dIDs)
Set the device index list, if more than one device is available.
Definition: qtensornetwork.hpp:161
bool TrySeparate(bitLenInt qubit1, bitLenInt qubit2)
Two-qubit TrySeparate()
Definition: qtensornetwork.hpp:290
void CheckQubitCount(bitLenInt target)
Definition: qtensornetwork.hpp:57
real1_f Prob(bitLenInt qubit)
Direct measure of bit probability to be in |1> state.
Definition: qtensornetwork.hpp:315
real1_f ncrp
Definition: qtensornetwork.hpp:51
void X(bitLenInt q)
Definition: qtensornetwork.hpp:431
void MCInvert(const std::vector< bitLenInt > &controls, const complex &topRight, const complex &bottomLeft, bitLenInt target)
Apply a single bit transformation that reverses bit probability and might effect phase,...
Definition: qtensornetwork.hpp:400
void MCPhase(const std::vector< bitLenInt > &controls, const complex &topLeft, const complex &bottomRight, bitLenInt target)
Apply a single bit transformation that only effects phase, with arbitrary control bits.
Definition: qtensornetwork.hpp:374
QInterfacePtr Clone()
Clone this QInterface.
Definition: qtensornetwork.cpp:134
bool isReactiveSeparate
Definition: qtensornetwork.hpp:37
bitLenInt Allocate(bitLenInt start, bitLenInt length)
Allocate new "length" count of |0> state qubits at specified qubit index start position.
Definition: qtensornetwork.hpp:293
real1_f SumSqrDiff(QInterfacePtr toCompare)
Calculates (1 - <\psi_e|\psi_c>) between states |\psi_c> and |\psi_e>.
Definition: qtensornetwork.hpp:179
void SetNcrp(real1_f rp)
Set the "Near-clifford rounding parameter" value, (between 0 and 1)
Definition: qtensornetwork.hpp:128
void MACPhase(const std::vector< bitLenInt > &controls, const complex &topLeft, const complex &bottomRight, bitLenInt target)
Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits.
Definition: qtensornetwork.hpp:388
bool isNearClifford
Definition: qtensornetwork.hpp:39
void MACInvert(const std::vector< bitLenInt > &controls, const complex &topRight, const complex &bottomLeft, bitLenInt target)
Apply a single bit transformation that reverses bit probability and might effect phase,...
Definition: qtensornetwork.hpp:414
std::map< bitCapInt, int > MultiShotMeasureMask(const std::vector< bitCapInt > &qPowers, unsigned shots)
Statistical measure of masked permutation probability.
Definition: qtensornetwork.hpp:335
bool AreFactorized(std::vector< bitLenInt > a, std::vector< bitLenInt > b, bool flushCache=false)
Check if two vectors of qubit indices are factorized, in internal representation.
Definition: qtensornetwork.hpp:102
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: qtensornetwork.hpp:285
bitLenInt aceQubits
Definition: qtensornetwork.hpp:48
complex GetAmplitude(const bitCapInt &perm)
Get the representational amplitude of a full permutation.
Definition: qtensornetwork.hpp:233
real1_f ProbAll(const bitCapInt &fullRegister)
Direct measure of full permutation probability.
Definition: qtensornetwork.hpp:321
void GetQuantumState(complex *state)
Get the pure quantum state representation.
Definition: qtensornetwork.hpp:209
void SetPermutation(const bitCapInt &initState, const complex &phaseFac=CMPLX_DEFAULT_ARG)
Set to a specific permutation of all qubits.
Definition: qtensornetwork.hpp:191
void SetAmplitude(const bitCapInt &perm, const complex &amp)
Sets the representational amplitude of a full permutation.
Definition: qtensornetwork.hpp:239
bitLenInt qbThreshold
Definition: qtensornetwork.hpp:49
int64_t GetDevice()
Get the device index.
Definition: qtensornetwork.hpp:162
QCircuitPtr circuit
Definition: qtensornetwork.hpp:55
void SetSparseAceMaxMb(size_t mb)
Set the (sparse-simulation) "automatic circuit elision" (ACE) maximum memory megabytes.
Definition: qtensornetwork.hpp:140
int64_t devID
Definition: qtensornetwork.hpp:46
void MCMtrx(const std::vector< bitLenInt > &controls, const complex mtrx[4U], bitLenInt target)
Apply an arbitrary single bit unitary transformation, with arbitrary control bits.
Definition: qtensornetwork.hpp:360
void NormalizeState(real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)
Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate.
Definition: qtensornetwork.hpp:173
void SetDevice(int64_t dID)
Set the device index, if more than one device is available.
Definition: qtensornetwork.hpp:160
void LossySaveStateVector(std::string f, int p=6, int b=4)
Write the quantum state to disk with lossy compression.
Definition: qtensornetwork.hpp:200
void CheckQubitCount(bitLenInt target, const std::vector< bitLenInt > &controls)
Definition: qtensornetwork.hpp:64
void RunAsAmplitudes(Fn fn, std::set< bitLenInt > qubits=std::set< bitLenInt >())
Definition: qtensornetwork.hpp:73
void SetQuantumState(QInterfacePtr eng)
Definition: qtensornetwork.hpp:217
void SetReactiveSeparate(bool isAggSep)
Set reactive separation option (on by default if available)
Definition: qtensornetwork.hpp:120
void SetSdrp(real1_f sdrp)
Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1)
Definition: qtensornetwork.hpp:113
real1_f separabilityThreshold
Definition: qtensornetwork.hpp:50
void MACMtrx(const std::vector< bitLenInt > &controls, const complex mtrx[4U], bitLenInt target)
Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits.
Definition: qtensornetwork.hpp:368
double GetUnitaryFidelity()
When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1....
Definition: qtensornetwork.hpp:146
bool M(bitLenInt q)
Definition: qtensornetwork.hpp:429
void MultiShotMeasureMask(const std::vector< bitCapInt > &qPowers, unsigned shots, unsigned long long *shotsArray)
Statistical measure of masked permutation probability (returned as array)
Definition: qtensornetwork.hpp:345
bitLenInt Compose(QInterfacePtr toCopy, bitLenInt start)
Compose() a QInterface peer, inserting its qubit into index order at start index.
Definition: qtensornetwork.hpp:245
std::vector< int64_t > deviceIDs
Definition: qtensornetwork.hpp:53
bitCapInt HighestProbAll()
Get highest probability permutation.
Definition: qtensornetwork.hpp:153
QTensorNetwork(std::vector< QInterfaceEngine > eng, bitLenInt qBitCount, const bitCapInt &initState=ZERO_BCI, qrack_rand_gen_ptr rgp=nullptr, const complex &phaseFac=CMPLX_DEFAULT_ARG, bool doNorm=false, bool randomGlobalPhase=true, bool useHostMem=false, int64_t deviceId=-1, bool useHardwareRNG=true, bool useSparseStateVec=false, real1_f norm_thresh=REAL1_EPSILON, std::vector< int64_t > ignored={}, bitLenInt qubitThreshold=0, real1_f separation_thresh=_qrack_qunit_sep_thresh)
Definition: qtensornetwork.cpp:35
bool TryDecompose(bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
Attempt to Decompose() a bit range.
Definition: qtensornetwork.hpp:275
QInterfacePtr layerStack
Definition: qtensornetwork.hpp:52
real1_f SumSqrDiff(QTensorNetworkPtr toCompare)
Definition: qtensornetwork.hpp:183
void Finish()
If asynchronous work is still running, block until it finishes.
Definition: qtensornetwork.hpp:165
bool isFinished()
Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynch...
Definition: qtensornetwork.hpp:167
void Mtrx(const complex mtrx[4U], bitLenInt target)
Apply an arbitrary single bit unitary transformation.
Definition: qtensornetwork.hpp:355
void Dispose(bitLenInt start, bitLenInt length)
Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separa...
Definition: qtensornetwork.hpp:265
bool ForceM(bitLenInt qubit, bool result, bool doForce=true, bool doApply=true)
Act as if is a measurement was applied, except force the (usually random) result.
Definition: qtensornetwork.hpp:328
std::vector< int64_t > GetDeviceList()
Get the device index.
Definition: qtensornetwork.hpp:163
void SetAceMaxQubits(bitLenInt qb)
Set the "automatic circuit elision" (ACE) maximum entangled subsystem qubit count.
Definition: qtensornetwork.hpp:134
void Dispose(bitLenInt start, bitLenInt length, const bitCapInt &disposedPerm)
Dispose a a contiguous set of qubits that are already in a permutation eigenstate.
Definition: qtensornetwork.hpp:270
size_t aceMb
Definition: qtensornetwork.hpp:47
std::vector< QInterfaceEngine > engines
Definition: qtensornetwork.hpp:54
void MakeLayerStack()
Definition: qtensornetwork.cpp:115
void Dump()
If asynchronous work is still running, let the simulator know that it can be aborted.
Definition: qtensornetwork.hpp:169
void UpdateRunningNorm(real1_f norm_thresh=REAL1_DEFAULT_ARG)
Force a calculation of the norm of the state vector, in order to make it unit length before the next ...
Definition: qtensornetwork.hpp:171
Half-precision floating-point type.
Definition: half.hpp:2206
virtual void MULModNOut(const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:127
void INCS(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: qtensornetwork.hpp:486
void PhaseFlipIfLess(const bitCapInt &greaterPerm, bitLenInt start, bitLenInt length)
This is an expedient for an adaptive Grover's search for a function's global minimum.
Definition: qtensornetwork.hpp:605
void DECS(const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: qtensornetwork.hpp:440
virtual void DECS(const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Subtract a classical integer from the register, with sign and without carry.
Definition: qinterface.hpp:2225
void DEC(const bitCapInt &toSub, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: qtensornetwork.hpp:439
void CMULModNOut(const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled multiplication modulo N by integer, (out of place)
Definition: qtensornetwork.hpp:466
bitCapInt IndexedSBC(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, const unsigned char *values)
Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classi...
Definition: qtensornetwork.hpp:584
void INC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: qtensornetwork.hpp:477
virtual void INCDECC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCC and DECC.
Definition: arithmetic.cpp:53
void INCDECSC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCSC and DECSC (without overflow flag)
Definition: qtensornetwork.hpp:498
virtual void CINC(const bitCapInt &toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Add integer (without sign, with controls)
Definition: arithmetic.cpp:79
void DECBCD(const bitCapInt &toAdd, bitLenInt start, bitLenInt length)
Subtract classical BCD integer (without sign)
Definition: qtensornetwork.hpp:513
void Hash(bitLenInt start, bitLenInt length, const unsigned char *values)
Transform a length of qubit register via lookup through a hash table.
Definition: qtensornetwork.hpp:595
void DIV(const bitCapInt &toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Divide by integer.
Definition: qtensornetwork.hpp:529
void MUL(const bitCapInt &toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Multiply by integer.
Definition: qtensornetwork.hpp:524
virtual void DEC(const bitCapInt &toSub, bitLenInt start, bitLenInt length)
Subtract classical integer (without sign)
Definition: qinterface.hpp:2166
void CIMULModNOut(const bitCapInt &toMul, const 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: qtensornetwork.hpp:471
void INCDECBCDC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCSC and DECSC (without overflow flag)
Definition: qtensornetwork.hpp:517
void POWModNOut(const bitCapInt &base, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Raise a classical base to a quantum power, modulo N, (out of place)
Definition: qtensornetwork.hpp:534
void CMUL(const bitCapInt &toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled multiplication by integer.
Definition: qtensornetwork.hpp:541
void CDIV(const bitCapInt &toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled division by power of integer.
Definition: qtensornetwork.hpp:548
void DECC(const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract classical integer (without sign, with carry)
Definition: qtensornetwork.hpp:503
bitCapInt IndexedADC(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, const unsigned char *values)
Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory...
Definition: qtensornetwork.hpp:573
virtual void IMULModNOut(const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Inverse of multiplication modulo N by integer, (out of place)
Definition: arithmetic.cpp:165
void MULModNOut(const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Multiplication modulo N by integer, (out of place)
Definition: qtensornetwork.hpp:456
void CINC(const bitCapInt &toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Add integer (without sign, with controls)
Definition: qtensornetwork.hpp:444
void INCBCD(const bitCapInt &toAdd, bitLenInt start, bitLenInt length)
Add classical BCD integer (without sign)
Definition: qtensornetwork.hpp:509
virtual void CDEC(const bitCapInt &toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Subtract classical integer (without sign, with controls)
Definition: qinterface.hpp:2206
void CDEC(const bitCapInt &toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Subtract integer (without sign, with controls)
Definition: qtensornetwork.hpp:448
void CPOWModNOut(const bitCapInt &base, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled, raise a classical base to a quantum power, modulo N, (out of place)
Definition: qtensornetwork.hpp:555
void INCC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: qtensornetwork.hpp:481
virtual void CMULModNOut(const bitCapInt &toMul, const 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:201
virtual void CIMULModNOut(const bitCapInt &toMul, const 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:240
void IMULModNOut(const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Inverse of multiplication modulo N by integer, (out of place)
Definition: qtensornetwork.hpp:461
void INCDECSC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Common driver method behind INCSC and DECSC (with overflow flag)
Definition: qtensornetwork.hpp:491
void INCDECC(const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCC and DECC (without sign, with carry)
Definition: qtensornetwork.hpp:452
bitCapInt IndexedLDA(bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, const unsigned char *values, bool resetValue=true)
Set 8 bit register bits by a superposed index-offset-based read from classical memory.
Definition: qtensornetwork.hpp:562
void CPhaseFlipIfLess(const bitCapInt &greaterPerm, bitLenInt start, bitLenInt length, bitLenInt flagIndex)
The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation.
Definition: qtensornetwork.hpp:599
virtual void X(bitLenInt qubit)
X gate.
Definition: qinterface.hpp:1116
virtual void U(bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
General unitary gate.
Definition: rotational.cpp:18
virtual bool M(bitLenInt qubit)
Measurement gate.
Definition: qinterface.hpp:1031
virtual void Swap(bitLenInt qubit1, bitLenInt qubit2)
Swap values of two bits in register.
Definition: gates.cpp:166
GLOSSARY: bitLenInt - "bit-length integer" - unsigned integer ID of qubit position in register bitCap...
Definition: complex16x2simd.hpp:25
void ThrowIfQbIdArrayIsBad(const std::vector< bitLenInt > &controls, const bitLenInt &qubitCount, std::string message)
Definition: qrack_functions.hpp:198
QRACK_CONST real1_f FP_NORM_EPSILON_F
Definition: qrack_types.hpp:264
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:29
const real1_f _qrack_qunit_sep_thresh
Definition: qrack_functions.hpp:258
QRACK_CONST real1_f TRYDECOMPOSE_EPSILON
Definition: qrack_types.hpp:265
std::complex< real1 > complex
Definition: qrack_types.hpp:140
bitCapInt pow2(const bitLenInt &p)
Definition: qrack_functions.hpp:156
std::shared_ptr< QTensorNetwork > QTensorNetworkPtr
Definition: qtensornetwork.hpp:17
QRACK_CONST real1 REAL1_EPSILON
Definition: qrack_types.hpp:203
float real1_f
Definition: qrack_types.hpp:107
QRACK_CONST complex CMPLX_DEFAULT_ARG
Definition: qrack_types.hpp:262
std::shared_ptr< QCircuit > QCircuitPtr
Definition: qcircuit.hpp:607
QRACK_CONST complex ZERO_CMPLX
Definition: qrack_types.hpp:258
const bitCapInt ZERO_BCI
Definition: qrack_types.hpp:142
bitLenInt log2(bitCapInt n)
Definition: qrack_functions.hpp:154
#define REAL1_DEFAULT_ARG
Definition: qrack_types.hpp:179
#define bitLenInt
Definition: qrack_types.hpp:41
#define ZERO_R1_F
Definition: qrack_types.hpp:162
#define qrack_rand_gen_ptr
Definition: qrack_types.hpp:158
#define bitCapInt
Definition: qrack_types.hpp:65