57 qbdt->GetQuantumState(sv.get());
59 engine->GetQuantumState(sv.get());
61 nEngine->SetQuantumState(sv.get());
63 qbdt = std::dynamic_pointer_cast<QBdt>(nEngine);
67 engine = std::dynamic_pointer_cast<QEngine>(nEngine);
73 double threshold = getenv(
"QRACK_QBDT_HYBRID_THRESHOLD")
80 const size_t count =
qbdt->CountBranches();
81 #if (QBCAPPOW > 6) && BOOST_AVAILABLE
82 if ((threshold *
maxQPower.convert_to<
double>()) < count) {
93 bool randomGlobalPhase =
true,
bool useHostMem =
false, int64_t deviceId = -1,
bool useHardwareRNG =
true,
94 bool useSparseStateVec =
false,
real1_f norm_thresh =
REAL1_EPSILON, std::vector<int64_t> devList = {},
99 bool doNorm =
false,
bool randomGlobalPhase =
true,
bool useHostMem =
false, int64_t deviceId = -1,
100 bool useHardwareRNG =
true,
bool useSparseStateVec =
false,
real1_f norm_thresh =
REAL1_EPSILON,
101 std::vector<int64_t> devList = {},
bitLenInt qubitThreshold = 0
U,
106 bool useHostMem =
false, int64_t deviceId = -1,
bool useHardwareRNG =
true,
bool useSparseStateVec =
false,
110 useHostMem, deviceId, useHardwareRNG, useSparseStateVec, norm_thresh, devList, qubitThreshold,
132 return qbdt->ProbReg(start, length, permutation);
134 return engine->ProbReg(start, length, permutation);
141 toCopy->SwitchMode(!
engine);
143 return engine->Compose(toCopy->engine);
155 toCopy->SwitchMode(!
engine);
157 return engine->Compose(toCopy->engine, start);
167 return Compose(std::dynamic_pointer_cast<QBdtHybrid>(toCopy), start);
172 toCopy->SwitchMode(!
engine);
174 return engine->ComposeNoClone(toCopy->engine);
184 return ComposeNoClone(std::dynamic_pointer_cast<QBdtHybrid>(toCopy));
193 q = std::dynamic_pointer_cast<QBdt>(
qbdt->Decompose(start, length));
196 e = std::dynamic_pointer_cast<QEngine>(
engine->Decompose(start, length));
205 Decompose(start, std::dynamic_pointer_cast<QBdtHybrid>(dest));
209 return TryDecompose(start, std::dynamic_pointer_cast<QBdtHybrid>(dest), error_tol);
214 dest->SwitchMode(
false);
215 if (
engine->TryDecompose(start, dest->engine, error_tol)) {
224 dest->SwitchMode(!
engine);
226 qbdt->Decompose(start, dest->qbdt);
229 engine->Decompose(start, dest->engine);
236 qbdt->Dispose(start, length);
239 engine->Dispose(start, length);
246 qbdt->Dispose(start, length, disposedPerm);
249 engine->Dispose(start, length, disposedPerm);
261 qbdt->Allocate(start, length);
263 engine->Allocate(start, length);
273 qbdt->SetQuantumState(inputState);
275 engine->SetQuantumState(inputState);
281 qbdt->GetQuantumState(outputState);
283 engine->GetQuantumState(outputState);
289 qbdt->GetProbs(outputProbs);
291 engine->GetProbs(outputProbs);
297 return qbdt->GetAmplitude(perm);
299 return engine->GetAmplitude(perm);
304 qbdt->SetAmplitude(perm, amp);
306 engine->SetAmplitude(perm, amp);
312 qbdt->SetPermutation(perm, phaseFac);
322 qbdt->Mtrx(mtrx, qubitIndex);
324 engine->Mtrx(mtrx, qubitIndex);
330 qbdt->Phase(topLeft, bottomRight, qubitIndex);
332 engine->Phase(topLeft, bottomRight, qubitIndex);
338 qbdt->Invert(topRight, bottomLeft, qubitIndex);
340 engine->Invert(topRight, bottomLeft, qubitIndex);
346 qbdt->MCMtrx(controls, mtrx, target);
349 engine->MCMtrx(controls, mtrx, target);
355 qbdt->MACMtrx(controls, mtrx, target);
358 engine->MACMtrx(controls, mtrx, target);
364 const complex* mtrxs,
const std::vector<bitCapInt> mtrxSkipPowers,
bitCapInt mtrxSkipValueMask)
367 qbdt->UniformlyControlledSingleBit(controls, qubitIndex, mtrxs, mtrxSkipPowers, mtrxSkipValueMask);
370 engine->UniformlyControlledSingleBit(controls, qubitIndex, mtrxs, mtrxSkipPowers, mtrxSkipValueMask);
385 qbdt->PhaseParity(radians, mask);
387 engine->PhaseParity(radians, mask);
394 return qbdt->CProb(control, target);
396 return engine->CProb(control, target);
401 return qbdt->ACProb(control, target);
403 return engine->ACProb(control, target);
409 qbdt->UniformParityRZ(mask, angle);
412 engine->UniformParityRZ(mask, angle);
418 qbdt->CUniformParityRZ(controls, mask, angle);
421 engine->CUniformParityRZ(controls, mask, angle);
428 qbdt->CSwap(controls, qubit1, qubit2);
430 engine->CSwap(controls, qubit1, qubit2);
436 qbdt->AntiCSwap(controls, qubit1, qubit2);
438 engine->AntiCSwap(controls, qubit1, qubit2);
444 qbdt->CSqrtSwap(controls, qubit1, qubit2);
447 engine->CSqrtSwap(controls, qubit1, qubit2);
453 qbdt->AntiCSqrtSwap(controls, qubit1, qubit2);
456 engine->AntiCSqrtSwap(controls, qubit1, qubit2);
462 qbdt->CISqrtSwap(controls, qubit1, qubit2);
465 engine->CISqrtSwap(controls, qubit1, qubit2);
471 qbdt->AntiCISqrtSwap(controls, qubit1, qubit2);
474 engine->AntiCISqrtSwap(controls, qubit1, qubit2);
481 return qbdt->ForceM(qubit, result, doForce, doApply);
483 return engine->ForceM(qubit, result, doForce, doApply);
520 qbdt->INC(toAdd, start, length);
522 engine->INC(toAdd, start, length);
528 qbdt->DEC(toSub, start, length);
530 engine->DEC(toSub, start, length);
536 qbdt->CDEC(toSub, inOutStart, length, controls);
538 engine->CDEC(toSub, inOutStart, length, controls);
544 qbdt->INCDECC(toAdd, start, length, carryIndex);
546 engine->INCDECC(toAdd, start, length, carryIndex);
552 qbdt->CINC(toAdd, inOutStart, length, controls);
555 engine->CINC(toAdd, inOutStart, length, controls);
561 qbdt->INCC(toAdd, start, length, carryIndex);
564 engine->INCC(toAdd, start, length, carryIndex);
570 qbdt->INCS(toAdd, start, length, overflowIndex);
573 engine->INCS(toAdd, start, length, overflowIndex);
579 qbdt->DECS(toAdd, start, length, overflowIndex);
582 engine->DECS(toAdd, start, length, overflowIndex);
588 engine->INCSC(toAdd, start, length, overflowIndex, carryIndex);
593 engine->INCSC(toAdd, start, length, carryIndex);
598 qbdt->DECC(toSub, start, length, carryIndex);
601 engine->DECC(toSub, start, length, carryIndex);
607 engine->DECSC(toSub, start, length, overflowIndex, carryIndex);
612 engine->DECSC(toSub, start, length, carryIndex);
617 engine->INCDECSC(toAdd, start, length, overflowIndex, carryIndex);
622 engine->INCDECSC(toAdd, start, length, carryIndex);
628 engine->INCBCD(toAdd, start, length);
633 engine->INCBCDC(toAdd, start, length, carryIndex);
638 engine->DECBCDC(toSub, start, length, carryIndex);
644 qbdt->MUL(toMul, inOutStart, carryStart, length);
647 engine->MUL(toMul, inOutStart, carryStart, length);
653 qbdt->DIV(toDiv, inOutStart, carryStart, length);
656 engine->DIV(toDiv, inOutStart, carryStart, length);
662 qbdt->MULModNOut(toMul, modN, inStart, outStart, length);
665 engine->MULModNOut(toMul, modN, inStart, outStart, length);
671 qbdt->IMULModNOut(toMul, modN, inStart, outStart, length);
674 engine->IMULModNOut(toMul, modN, inStart, outStart, length);
680 engine->POWModNOut(base, modN, inStart, outStart, length);
683 const std::vector<bitLenInt>& controls)
686 qbdt->CMUL(toMul, inOutStart, carryStart, length, controls);
689 engine->CMUL(toMul, inOutStart, carryStart, length, controls);
693 const std::vector<bitLenInt>& controls)
696 qbdt->CDIV(toDiv, inOutStart, carryStart, length, controls);
699 engine->CDIV(toDiv, inOutStart, carryStart, length, controls);
703 const std::vector<bitLenInt>& controls)
706 qbdt->CMULModNOut(toMul, modN, inStart, outStart, length, controls);
709 engine->CMULModNOut(toMul, modN, inStart, outStart, length, controls);
713 const std::vector<bitLenInt>& controls)
716 qbdt->CIMULModNOut(toMul, modN, inStart, outStart, length, controls);
719 engine->CIMULModNOut(toMul, modN, inStart, outStart, length, controls);
723 const std::vector<bitLenInt>& controls)
726 engine->CPOWModNOut(base, modN, inStart, outStart, length, controls);
730 const unsigned char* values,
bool resetValue =
true)
733 return engine->IndexedLDA(indexStart, indexLength, valueStart, valueLength, values, resetValue);
736 bitLenInt carryIndex,
const unsigned char* values)
739 return engine->IndexedADC(indexStart, indexLength, valueStart, valueLength, carryIndex, values);
742 bitLenInt carryIndex,
const unsigned char* values)
745 return engine->IndexedSBC(indexStart, indexLength, valueStart, valueLength, carryIndex, values);
750 engine->Hash(start, length, values);
756 engine->CPhaseFlipIfLess(greaterPerm, start, length, flagIndex);
761 engine->PhaseFlipIfLess(greaterPerm, start, length);
768 qbdt->Swap(qubitIndex1, qubitIndex2);
770 engine->Swap(qubitIndex1, qubitIndex2);
776 qbdt->ISwap(qubitIndex1, qubitIndex2);
779 engine->ISwap(qubitIndex1, qubitIndex2);
785 qbdt->IISwap(qubitIndex1, qubitIndex2);
788 engine->IISwap(qubitIndex1, qubitIndex2);
794 qbdt->SqrtSwap(qubitIndex1, qubitIndex2);
797 engine->SqrtSwap(qubitIndex1, qubitIndex2);
803 qbdt->ISqrtSwap(qubitIndex1, qubitIndex2);
806 engine->ISqrtSwap(qubitIndex1, qubitIndex2);
812 qbdt->FSim(theta, phi, qubitIndex1, qubitIndex2);
815 engine->FSim(theta, phi, qubitIndex1, qubitIndex2);
822 return qbdt->Prob(qubitIndex);
824 return engine->Prob(qubitIndex);
829 return qbdt->ProbAll(fullRegister);
831 return engine->ProbAll(fullRegister);
836 return qbdt->ProbMask(mask, permutation);
838 return engine->ProbMask(mask, permutation);
843 return qbdt->ProbParity(mask);
845 return engine->ProbParity(mask);
850 return qbdt->ForceMParity(mask, result, doForce);
852 return engine->ForceMParity(mask, result, doForce);
858 toCompare->SwitchMode(!
engine);
860 return qbdt->SumSqrDiff(toCompare->qbdt);
862 return engine->SumSqrDiff(toCompare->engine);
868 qbdt->UpdateRunningNorm(norm_thresh);
870 engine->UpdateRunningNorm(norm_thresh);
877 qbdt->NormalizeState(nrm, norm_thresh, phaseArg);
879 engine->NormalizeState(nrm, norm_thresh, phaseArg);
886 return qbdt->ExpectationBitsAll(bits, offset);
888 return engine->ExpectationBitsAll(bits, offset);
903 return qbdt->isFinished();
905 return engine->isFinished();
924 c->qbdt = std::dynamic_pointer_cast<QBdt>(
qbdt->Clone());
926 c->SwitchMode(
false);
927 c->engine->CopyStateVec(
engine);
937 qbdt->SetDevice(dID);
948 return qbdt->GetMaxSize();
950 return engine->GetMaxSize();
unsigned GetConcurrencyLevel()
Definition: parallel_for.hpp:38
A "Qrack::QBdtHybrid" internally switched between Qrack::QBdt and Qrack::QHybrid to maximize entangle...
Definition: qbdthybrid.hpp:26
void DIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Divide by integer.
Definition: qbdthybrid.hpp:650
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: qbdthybrid.hpp:735
bitCapInt MAll()
Measure permutation state of all coherent bits.
Definition: qbdthybrid.hpp:486
void Swap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register.
Definition: qbdthybrid.hpp:765
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: qbdthybrid.hpp:478
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: qbdthybrid.hpp:352
real1_f ACProb(bitLenInt control, bitLenInt target)
Direct measure of bit probability to be in |1> state, if control bit is |0>.
Definition: qbdthybrid.hpp:398
void Mtrx(const complex *mtrx, bitLenInt qubitIndex)
Apply an arbitrary single bit unitary transformation.
Definition: qbdthybrid.hpp:319
bitLenInt Compose(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qbdthybrid.hpp:151
void UniformlyControlledSingleBit(const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs, const std::vector< bitCapInt > mtrxSkipPowers, bitCapInt mtrxSkipValueMask)
Definition: qbdthybrid.hpp:363
bitLenInt ComposeNoClone(QBdtHybridPtr toCopy)
Definition: qbdthybrid.hpp:169
void Phase(complex topLeft, complex bottomRight, bitLenInt qubitIndex)
Apply a single bit transformation that only effects phase.
Definition: qbdthybrid.hpp:327
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: qbdthybrid.hpp:865
bitLenInt Compose(QInterfacePtr toCopy, bitLenInt start)
Definition: qbdthybrid.hpp:165
void MULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Multiplication modulo N by integer, (out of place)
Definition: qbdthybrid.hpp:659
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: qbdthybrid.hpp:712
bool TryDecompose(bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
Definition: qbdthybrid.hpp:207
real1_f ProbMask(bitCapInt mask, bitCapInt permutation)
Direct measure of masked permutation probability.
Definition: qbdthybrid.hpp:833
void AntiCSqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a square root of swap with arbitrary (anti) control bits.
Definition: qbdthybrid.hpp:450
void SqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Square root of Swap gate.
Definition: qbdthybrid.hpp:791
int64_t devID
Definition: qbdthybrid.hpp:36
QBdtHybrid(std::vector< QInterfaceEngine > eng, bitLenInt qBitCount, bitCapInt initState=0U, qrack_rand_gen_ptr rgp=nullptr, 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=FP_NORM_EPSILON_F)
Definition: qbdthybrid.cpp:17
QBdtPtr qbdt
Definition: qbdthybrid.hpp:37
void Decompose(bitLenInt start, QInterfacePtr dest)
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
Definition: qbdthybrid.hpp:203
virtual bitLenInt Compose(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qinterface.hpp:338
complex phaseFactor
Definition: qbdthybrid.hpp:39
void UniformParityRZ(bitCapInt mask, real1_f angle)
If the target qubit set parity is odd, this applies a phase factor of .
Definition: qbdthybrid.hpp:406
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: qbdthybrid.hpp:873
bitLenInt thresholdQubits
Definition: qbdthybrid.hpp:34
bitLenInt ComposeNoClone(QInterfacePtr toCopy)
Definition: qbdthybrid.hpp:182
void XMask(bitCapInt mask)
Masked X gate.
Definition: qbdthybrid.hpp:374
void CINC(bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Add integer (without sign, with controls)
Definition: qbdthybrid.hpp:549
void ISwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register, and apply phase factor of i if bits are different.
Definition: qbdthybrid.hpp:773
void Invert(complex topRight, complex bottomLeft, bitLenInt qubitIndex)
Apply a single bit transformation that reverses bit probability and might effect phase.
Definition: qbdthybrid.hpp:335
void DECSC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract a classical integer from the register, with sign and with carry.
Definition: qbdthybrid.hpp:609
void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: qbdthybrid.hpp:517
QInterfacePtr Decompose(bitLenInt start, bitLenInt length)
Schmidt decompose a length of qubits.
Definition: qbdthybrid.hpp:187
bitCapIntOcl GetMaxSize()
Definition: qbdthybrid.hpp:945
std::vector< int64_t > deviceIDs
Definition: qbdthybrid.hpp:40
void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract classical integer (without sign, with carry)
Definition: qbdthybrid.hpp:595
void CPOWModNOut(bitCapInt base, 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: qbdthybrid.hpp:722
void GetProbs(real1 *outputProbs)
Get the pure quantum state representation.
Definition: qbdthybrid.hpp:286
virtual void Decompose(bitLenInt start, QInterfacePtr dest)=0
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
real1_f ProbAll(bitCapInt fullRegister)
Direct measure of full permutation probability.
Definition: qbdthybrid.hpp:826
void DECSC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Subtract a classical integer from the register, with sign and with carry.
Definition: qbdthybrid.hpp:604
void PhaseFlipIfLess(bitCapInt greaterPerm, bitLenInt start, bitLenInt length)
This is an expedient for an adaptive Grover's search for a function's global minimum.
Definition: qbdthybrid.hpp:758
void SetConcurrency(uint32_t threadCount)
Set the number of threads in parallel for loops, per component QEngine.
Definition: qbdthybrid.hpp:119
void Dispose(bitLenInt start, bitLenInt length, bitCapInt disposedPerm)
Dispose a a contiguous set of qubits that are already in a permutation eigenstate.
Definition: qbdthybrid.hpp:242
QBdtHybrid(bitLenInt qBitCount, bitCapInt initState=0U, qrack_rand_gen_ptr rgp=nullptr, 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=FP_NORM_EPSILON_F)
Definition: qbdthybrid.hpp:104
void CPhaseFlipIfLess(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: qbdthybrid.hpp:753
real1_f separabilityThreshold
Definition: qbdthybrid.hpp:35
void IMULModNOut(bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Inverse of multiplication modulo N by integer, (out of place)
Definition: qbdthybrid.hpp:668
real1_f ProbReg(bitLenInt start, bitLenInt length, bitCapInt permutation)
Direct measure of register permutation probability.
Definition: qbdthybrid.hpp:129
void INCDECC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCC and DECC (without sign, with carry)
Definition: qbdthybrid.hpp:541
real1_f SumSqrDiff(QInterfacePtr toCompare)
Definition: qbdthybrid.hpp:855
void X(bitLenInt q)
Definition: qbdthybrid.hpp:509
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: qbdthybrid.hpp:741
QInterfacePtr Clone()
Clone this QInterface.
Definition: qbdthybrid.hpp:917
void MUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Multiply by integer.
Definition: qbdthybrid.hpp:641
void AntiCSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a swap with arbitrary (anti) control bits.
Definition: qbdthybrid.hpp:433
real1_f Prob(bitLenInt qubitIndex)
Direct measure of bit probability to be in |1> state.
Definition: qbdthybrid.hpp:819
void SetPermutation(bitCapInt perm, complex phaseFac=CMPLX_DEFAULT_ARG)
Set to a specific permutation of all qubits.
Definition: qbdthybrid.hpp:309
bool ForceMParity(bitCapInt mask, bool result, bool doForce=true)
Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usual...
Definition: qbdthybrid.hpp:847
void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: qbdthybrid.hpp:558
void INCDECSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Common driver method behind INCSC and DECSC (with overflow flag)
Definition: qbdthybrid.hpp:614
real1_f ExpectationBitsAll(const std::vector< bitLenInt > &bits, bitCapInt offset=0)
Get permutation expectation value of bits.
Definition: qbdthybrid.hpp:883
void MCMtrx(const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
Apply an arbitrary single bit unitary transformation, with arbitrary control bits.
Definition: qbdthybrid.hpp:343
QInterfacePtr MakeSimulator(bool isBdt, bitCapInt perm=0U, complex phaseFac=CMPLX_DEFAULT_ARG)
Definition: qbdthybrid.cpp:59
void ISqrtSwap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Inverse square root of Swap gate.
Definition: qbdthybrid.hpp:800
bool M(bitLenInt q)
Definition: qbdthybrid.hpp:501
complex GetAmplitude(bitCapInt perm)
Get the representational amplitude of a full permutation.
Definition: qbdthybrid.hpp:294
void Finish()
If asynchronous work is still running, block until it finishes.
Definition: qbdthybrid.hpp:891
void DECS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: qbdthybrid.hpp:576
bool useHostRam
Definition: qbdthybrid.hpp:33
bool isBinaryDecisionTree()
Returns "true" if current state representation is definitely a binary decision tree,...
Definition: qbdthybrid.hpp:117
real1_f SumSqrDiff(QBdtHybridPtr toCompare)
Definition: qbdthybrid.hpp:856
void INCBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add classical BCD integer (without sign)
Definition: qbdthybrid.hpp:625
void PhaseParity(real1_f radians, bitCapInt mask)
Parity phase gate.
Definition: qbdthybrid.hpp:382
void FSim(real1_f theta, real1_f phi, bitLenInt qubitIndex1, bitLenInt qubitIndex2)
The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics)
Definition: qbdthybrid.hpp:809
void SetAmplitude(bitCapInt perm, complex amp)
Sets the representational amplitude of a full permutation.
Definition: qbdthybrid.hpp:301
bitLenInt Compose(QBdtHybridPtr toCopy)
Definition: qbdthybrid.hpp:138
void Dump()
If asynchronous work is still running, let the simulator know that it can be aborted.
Definition: qbdthybrid.hpp:908
std::vector< QInterfaceEngine > engines
Definition: qbdthybrid.hpp:41
int64_t GetDevice()
Get the device index.
Definition: qbdthybrid.hpp:943
void Dispose(bitLenInt start, bitLenInt length)
Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separa...
Definition: qbdthybrid.hpp:232
void CISqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply an inverse square root of swap with arbitrary control bits.
Definition: qbdthybrid.hpp:459
void SwitchMode(bool useBdt)
Switches between QBdt and QEngine modes.
Definition: qbdthybrid.hpp:48
bool useRDRAND
Definition: qbdthybrid.hpp:31
real1_f CProb(bitLenInt control, bitLenInt target)
Direct measure of bit probability to be in |1> state, if control bit is |1>.
Definition: qbdthybrid.hpp:391
void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: qbdthybrid.hpp:567
void CSqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a square root of swap with arbitrary control bits.
Definition: qbdthybrid.hpp:441
void CheckThreshold()
Definition: qbdthybrid.hpp:71
void SetQuantumState(const complex *inputState)
Set an arbitrary pure quantum state representation.
Definition: qbdthybrid.hpp:270
void SetDevice(int64_t dID)
Set the device index, if more than one device is available.
Definition: qbdthybrid.hpp:933
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: qbdthybrid.hpp:702
void INCSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add a classical integer to the register, with sign and with (phase-based) carry.
Definition: qbdthybrid.hpp:590
void CDEC(bitCapInt toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Subtract integer (without sign, with controls)
Definition: qbdthybrid.hpp:533
void CUniformParityRZ(const std::vector< bitLenInt > &controls, bitCapInt mask, real1_f angle)
If the controls are set and the target qubit set parity is odd, this applies a phase factor of .
Definition: qbdthybrid.hpp:415
bool TryDecompose(bitLenInt start, QBdtHybridPtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
Definition: qbdthybrid.hpp:211
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: qbdthybrid.hpp:729
void Decompose(bitLenInt start, QBdtHybridPtr dest)
Definition: qbdthybrid.hpp:221
void INCDECSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Common driver method behind INCSC and DECSC (without overflow flag)
Definition: qbdthybrid.hpp:619
QEnginePtr engine
Definition: qbdthybrid.hpp:38
bool isSparse
Definition: qbdthybrid.hpp:32
void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add classical BCD integer (without sign, with carry)
Definition: qbdthybrid.hpp:630
void INCSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Add a classical integer to the register, with sign and with carry.
Definition: qbdthybrid.hpp:585
bitLenInt Compose(QBdtHybridPtr toCopy, bitLenInt start)
Definition: qbdthybrid.hpp:152
void AntiCISqrtSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply an inverse square root of swap with arbitrary (anti) control bits.
Definition: qbdthybrid.hpp:468
bool isFinished()
Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynch...
Definition: qbdthybrid.hpp:900
real1_f ProbParity(bitCapInt mask)
Overall probability of any odd permutation of the masked set of bits.
Definition: qbdthybrid.hpp:840
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: qbdthybrid.hpp:782
void DECBCDC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract BCD integer (without sign, with carry)
Definition: qbdthybrid.hpp:635
void Hash(bitLenInt start, bitLenInt length, const unsigned char *values)
Transform a length of qubit register via lookup through a hash table.
Definition: qbdthybrid.hpp:747
void POWModNOut(bitCapInt base, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
Raise a classical base to a quantum power, modulo N, (out of place)
Definition: qbdthybrid.hpp:677
bitLenInt Allocate(bitLenInt start, bitLenInt length)
Allocate new "length" count of |0> state qubits at specified qubit index start position.
Definition: qbdthybrid.hpp:254
void CMUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled multiplication by integer.
Definition: qbdthybrid.hpp:682
void GetQuantumState(complex *outputState)
Get the pure quantum state representation.
Definition: qbdthybrid.hpp:278
void CDIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)
Controlled division by power of integer.
Definition: qbdthybrid.hpp:692
void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: qbdthybrid.hpp:525
void CSwap(const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
Apply a swap with arbitrary control bits.
Definition: qbdthybrid.hpp:425
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:146
bitCapInt maxQPower
Definition: qinterface.hpp:154
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 bitLenInt Allocate(bitLenInt length)
Allocate new "length" count of |0> state qubits at end of qubit index position.
Definition: qinterface.hpp:434
virtual bitLenInt Compose(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qinterface.hpp:338
qrack_rand_gen_ptr rand_generator
Definition: qinterface.hpp:155
bool randGlobalPhase
Definition: qinterface.hpp:149
virtual void Decompose(bitLenInt start, QInterfacePtr dest)=0
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
virtual void SetQubitCount(bitLenInt qb)
Definition: qinterface.hpp:159
bitLenInt qubitCount
Definition: qinterface.hpp:151
bool doNormalize
Definition: qinterface.hpp:148
Definition: qparity.hpp:22
Half-precision floating-point type.
Definition: half.hpp:2222
virtual bool M(bitLenInt qubitIndex)
Measurement gate.
Definition: qinterface.hpp:976
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 X(bitLenInt qubit)
X gate.
Definition: qinterface.hpp:1054
virtual void U(bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
General unitary gate.
Definition: rotational.cpp:18
Definition: complex16x2simd.hpp:25
std::complex< half_float::half > complex
Definition: qrack_types.hpp:62
@ QINTERFACE_OPTIMAL_BASE
Definition: qinterface.hpp:129
std::shared_ptr< QEngine > QEnginePtr
Definition: qrack_types.hpp:141
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
constexpr real1_f FP_NORM_EPSILON_F
Definition: qrack_types.hpp:245
std::shared_ptr< QBdt > QBdtPtr
Definition: qbdt.hpp:28
std::shared_ptr< QBdtHybrid > QBdtHybridPtr
Definition: qbdthybrid.hpp:18
QRACK_CONST real1 FP_NORM_EPSILON
Definition: qrack_types.hpp:243
const real1 REAL1_DEFAULT_ARG
Definition: qrack_types.hpp:155
float real1_f
Definition: qrack_types.hpp:64
QRACK_CONST complex CMPLX_DEFAULT_ARG
Definition: qrack_types.hpp:242
const real1 REAL1_EPSILON
Definition: qrack_types.hpp:157
uint32 log2(uint32 m, unsigned int n=32)
Fixed point binary logarithm.
Definition: half.hpp:1700
#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