40 #if ENABLE_OPENCL || ENABLE_CUDA
60 throw std::invalid_argument(
"QTensorNetwork qubit index values must be within allocated qubit bounds!");
68 controls,
qubitCount,
"QTensorNetwork qubit index values must be within allocated qubit bounds!");
73 template <
typename Fn>
void RunAsAmplitudes(Fn fn, std::set<bitLenInt> qubits = std::set<bitLenInt>())
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 = {},
94 bool useHostMem =
false, int64_t deviceId = -1,
bool useHardwareRNG =
true,
bool useSparseStateVec =
false,
97 :
QTensorNetwork({}, qBitCount, initState, rgp, phaseFac, doNorm, randomGlobalPhase, useHostMem, deviceId,
98 useHardwareRNG, useSparseStateVec, norm_thresh, devList, qubitThreshold, separation_thresh)
102 bool AreFactorized(std::vector<bitLenInt> a, std::vector<bitLenInt> b,
bool flushCache =
false)
104 std::set<bitLenInt> q(a.begin(), a.end());
105 q.insert(b.begin(), b.end());
176 layerStack->NormalizeState(nrm, norm_thresh, phaseArg);
181 return SumSqrDiff(std::dynamic_pointer_cast<QTensorNetwork>(toCompare));
195 layerStack->SetPermutation(initState, phaseFac);
222 throw std::invalid_argument(
"QTensorNetwork::SetQuantumState() argument must match in qubit count!");
226 circuit = tnEng->circuit->Clone();
248 std::dynamic_pointer_cast<QTensorNetwork>(toCopy)->RunAsAmplitudes([&](
QInterfacePtr ls) {});
250 toRet = ls->Compose(std::dynamic_pointer_cast<QTensorNetwork>(toCopy)->
layerStack, start);
257 dest->SetPermutation(0
U);
258 std::dynamic_pointer_cast<QTensorNetwork>(dest)->MakeLayerStack();
260 ls->Decompose(start, std::dynamic_pointer_cast<QTensorNetwork>(dest)->
layerStack);
278 dest->SetPermutation(0
U);
280 toRet = ls->TryDecompose(start, std::dynamic_pointer_cast<QTensorNetwork>(dest)->
layerStack, error_tol);
287 return layerStack->TrySeparate(qubits, error_tol);
296 throw std::invalid_argument(
"QTensorNetwork::Allocate() 'start' argument is out-of-bounds!");
307 for (
bitLenInt i = 0
U; i < movedQubits; ++i) {
308 const bitLenInt q = start + movedQubits - (i + 1U);
337 std::map<bitCapInt, int> toRet;
338 std::set<bitLenInt> qubits;
340 qubits.insert(
log2(qPow));
345 void MultiShotMeasureMask(
const std::vector<bitCapInt>& qPowers,
unsigned shots,
unsigned long long* shotsArray)
347 std::map<bitCapInt, int> toRet;
348 std::set<bitLenInt> qubits;
350 qubits.insert(
log2(qPow));
358 circuit->AppendGate(std::make_shared<QCircuitGate>(target, mtrx));
366 std::make_shared<QCircuitGate>(target, mtrx, std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
371 circuit->AppendGate(std::make_shared<QCircuitGate>(
372 target, mtrx, std::set<bitLenInt>{ controls.begin(), controls.end() },
ZERO_BCI));
378 std::shared_ptr<complex> lMtrx(
new complex[4U], std::default_delete<
complex[]>());
379 lMtrx.get()[0
U] = topLeft;
382 lMtrx.get()[3U] = bottomRight;
385 circuit->AppendGate(std::make_shared<QCircuitGate>(
386 target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
392 std::shared_ptr<complex> lMtrx(
new complex[4U], std::default_delete<
complex[]>());
393 lMtrx.get()[0
U] = topLeft;
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));
404 std::shared_ptr<complex> lMtrx(
new complex[4U], std::default_delete<
complex[]>());
406 lMtrx.get()[1U] = topRight;
407 lMtrx.get()[2U] = bottomLeft;
411 circuit->AppendGate(std::make_shared<QCircuitGate>(
412 target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() }, m));
418 std::shared_ptr<complex> lMtrx(
new complex[4U], std::default_delete<
complex[]>());
420 lMtrx.get()[1U] = topRight;
421 lMtrx.get()[2U] = bottomLeft;
423 circuit->AppendGate(std::make_shared<QCircuitGate>(
424 target, lMtrx.get(), std::set<bitLenInt>{ controls.begin(), controls.end() },
ZERO_BCI));
467 bitLenInt length,
const std::vector<bitLenInt>& controls)
472 bitLenInt length,
const std::vector<bitLenInt>& controls)
484 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCC(toAdd, start, length, carryIndex); });
489 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCS(toAdd, start, length, overflowIndex); });
495 std::dynamic_pointer_cast<QAlu>(ls)->INCDECSC(toAdd, start, length, overflowIndex, carryIndex);
501 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->INCDECSC(toAdd, start, length, carryIndex); });
506 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->DECC(toSub, start, length, carryIndex); });
520 std::dynamic_pointer_cast<QAlu>(ls)->INCDECBCDC(toAdd, start, length, carryIndex);
527 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->MUL(toMul, inOutStart, carryStart, length); });
532 [&](
QInterfacePtr ls) { std::dynamic_pointer_cast<QAlu>(ls)->DIV(toDiv, inOutStart, carryStart, length); });
538 std::dynamic_pointer_cast<QAlu>(ls)->POWModNOut(base, modN, inStart, outStart, length);
542 const std::vector<bitLenInt>& controls)
545 std::dynamic_pointer_cast<QAlu>(ls)->CMUL(toMul, inOutStart, carryStart, length, controls);
549 const std::vector<bitLenInt>& controls)
552 std::dynamic_pointer_cast<QAlu>(ls)->CDIV(toDiv, inOutStart, carryStart, length, controls);
556 bitLenInt length,
const std::vector<bitLenInt>& controls)
559 std::dynamic_pointer_cast<QAlu>(ls)->CPOWModNOut(base, modN, inStart, outStart, length, controls);
563 const unsigned char* values,
bool resetValue =
true)
567 toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedLDA(
568 indexStart, indexLength, valueStart, valueLength, values, resetValue);
574 bitLenInt carryIndex,
const unsigned char* values)
578 toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedADC(
579 indexStart, indexLength, valueStart, valueLength, carryIndex, values);
585 bitLenInt carryIndex,
const unsigned char* values)
589 toRet = std::dynamic_pointer_cast<QAlu>(ls)->IndexedSBC(
590 indexStart, indexLength, valueStart, valueLength, carryIndex, values);
602 std::dynamic_pointer_cast<QAlu>(ls)->CPhaseFlipIfLess(greaterPerm, start, length, flagIndex);
608 std::dynamic_pointer_cast<QAlu>(ls)->PhaseFlipIfLess(greaterPerm, start, length);
void bi_decrement(BigInteger *pBigInt, const BIG_INTEGER_WORD &value)
Definition: big_integer.hpp:238
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 &)
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
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