Qrack
9.0
General classical-emulating-quantum development framework
|
A "Qrack::QStabilizerHybrid" internally switched between Qrack::QStabilizer and Qrack::QEngine to maximize performance. More...
#include <qstabilizerhybrid.hpp>
Public Member Functions | |
QStabilizerHybrid (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) | |
QStabilizerHybrid (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) | |
void | SetTInjection (bool useGadget) |
Set the option to use T-injection gadgets (off by default) More... | |
bool | GetTInjection () |
Get the option to use T-injection gadgets. More... | |
void | Finish () |
If asynchronous work is still running, block until it finishes. More... | |
bool | isFinished () |
Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done. More... | |
void | Dump () |
If asynchronous work is still running, let the simulator know that it can be aborted. More... | |
void | SetConcurrency (uint32_t threadCount) |
Set the number of threads in parallel for loops, per component QEngine. More... | |
real1_f | ProbRdm (bitLenInt qubit) |
Direct measure of bit probability to be in |1> state, treating all ancillary qubits as post-selected T gate gadgets. More... | |
real1_f | CProbRdm (bitLenInt control, bitLenInt target) |
real1_f | ACProbRdm (bitLenInt control, bitLenInt target) |
void | SwitchToEngine () |
Switches between CPU and GPU used modes. More... | |
bool | isClifford () |
Returns "true" if current state is identifiably within the Clifford set, or "false" if it is not or cannot be determined. More... | |
bool | isClifford (bitLenInt qubit) |
Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is not or cannot be determined. More... | |
bool | isBinaryDecisionTree () |
Returns "true" if current state representation is definitely a binary decision tree, "false" if it is definitely not, or "true" if it cannot be determined. More... | |
bitLenInt | Compose (QStabilizerHybridPtr toCopy) |
bitLenInt | Compose (QInterfacePtr toCopy) |
Combine another QInterface with this one, after the last bit index of this one. More... | |
bitLenInt | Compose (QStabilizerHybridPtr toCopy, bitLenInt start) |
bitLenInt | Compose (QInterfacePtr toCopy, bitLenInt start) |
bitLenInt | ComposeNoClone (QStabilizerHybridPtr toCopy) |
bitLenInt | ComposeNoClone (QInterfacePtr toCopy) |
bitLenInt | ComposeEither (QStabilizerHybridPtr toCopy, bool willDestroy) |
void | Decompose (bitLenInt start, QInterfacePtr dest) |
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination". More... | |
void | Decompose (bitLenInt start, QStabilizerHybridPtr dest) |
QInterfacePtr | Decompose (bitLenInt start, bitLenInt length) |
Schmidt decompose a length of qubits. More... | |
void | Dispose (bitLenInt start, bitLenInt length) |
Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separable bits from index "start" for "length.". More... | |
void | Dispose (bitLenInt start, bitLenInt length, bitCapInt disposedPerm) |
Dispose a a contiguous set of qubits that are already in a permutation eigenstate. More... | |
bitLenInt | Allocate (bitLenInt start, bitLenInt length) |
Allocate new "length" count of |0> state qubits at specified qubit index start position. More... | |
void | GetQuantumState (complex *outputState) |
Get the pure quantum state representation. More... | |
void | GetProbs (real1 *outputProbs) |
Get the pure quantum state representation. More... | |
complex | GetAmplitude (bitCapInt perm) |
Get the representational amplitude of a full permutation. More... | |
real1_f | ProbAll (bitCapInt perm) |
Direct measure of full permutation probability. More... | |
void | SetQuantumState (const complex *inputState) |
Set an arbitrary pure quantum state representation. More... | |
void | SetAmplitude (bitCapInt perm, complex amp) |
Sets the representational amplitude of a full permutation. More... | |
void | SetPermutation (bitCapInt perm, complex phaseFac=CMPLX_DEFAULT_ARG) |
Set to a specific permutation of all qubits. More... | |
void | Swap (bitLenInt qubit1, bitLenInt qubit2) |
Swap values of two bits in register. More... | |
void | ISwap (bitLenInt qubit1, bitLenInt qubit2) |
Swap values of two bits in register, and apply phase factor of i if bits are different. More... | |
void | IISwap (bitLenInt qubit1, bitLenInt qubit2) |
Inverse ISwap - Swap values of two bits in register, and apply phase factor of -i if bits are different. More... | |
void | CSwap (const std::vector< bitLenInt > &lControls, bitLenInt qubit1, bitLenInt qubit2) |
Apply a swap with arbitrary control bits. More... | |
void | CSqrtSwap (const std::vector< bitLenInt > &lControls, bitLenInt qubit1, bitLenInt qubit2) |
Apply a square root of swap with arbitrary control bits. More... | |
void | AntiCSqrtSwap (const std::vector< bitLenInt > &lControls, bitLenInt qubit1, bitLenInt qubit2) |
Apply a square root of swap with arbitrary (anti) control bits. More... | |
void | CISqrtSwap (const std::vector< bitLenInt > &lControls, bitLenInt qubit1, bitLenInt qubit2) |
Apply an inverse square root of swap with arbitrary control bits. More... | |
void | AntiCISqrtSwap (const std::vector< bitLenInt > &lControls, bitLenInt qubit1, bitLenInt qubit2) |
Apply an inverse square root of swap with arbitrary (anti) control bits. More... | |
void | XMask (bitCapInt mask) |
Masked X gate. More... | |
void | YMask (bitCapInt mask) |
Masked Y gate. More... | |
void | ZMask (bitCapInt mask) |
Masked Z gate. More... | |
real1_f | Prob (bitLenInt qubit) |
Direct measure of bit probability to be in |1> state. More... | |
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. More... | |
bitCapInt | MAll () |
Measure permutation state of all coherent bits. More... | |
void | Mtrx (const complex *mtrx, bitLenInt target) |
Apply an arbitrary single bit unitary transformation. More... | |
void | MCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target) |
Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More... | |
void | MCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target) |
Apply a single bit transformation that only effects phase, with arbitrary control bits. More... | |
void | MCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target) |
Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits. More... | |
void | MACMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target) |
Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More... | |
void | MACPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target) |
Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits. More... | |
void | MACInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target) |
Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits. More... | |
void | UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs) |
Apply a "uniformly controlled" arbitrary single bit unitary transformation. More... | |
std::map< bitCapInt, int > | MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots) |
Statistical measure of masked permutation probability. More... | |
void | MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots, unsigned long long *shotsArray) |
Statistical measure of masked permutation probability (returned as array) More... | |
real1_f | ProbParity (bitCapInt mask) |
Overall probability of any odd permutation of the masked set of bits. More... | |
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 (usually random) result. More... | |
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 \(e^{i angle}\). More... | |
bool | M (bitLenInt q) |
void | X (bitLenInt q) |
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. More... | |
void | PhaseFlipIfLess (bitCapInt greaterPerm, bitLenInt start, bitLenInt length) |
This is an expedient for an adaptive Grover's search for a function's global minimum. More... | |
void | INC (bitCapInt toAdd, bitLenInt start, bitLenInt length) |
Add integer (without sign) More... | |
void | DEC (bitCapInt toSub, bitLenInt start, bitLenInt length) |
Add integer (without sign) More... | |
void | DECS (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex) |
Add a classical integer to the register, with sign and without carry. More... | |
void | CINC (bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls) |
Add integer (without sign, with controls) More... | |
void | INCS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex) |
Add a classical integer to the register, with sign and without carry. More... | |
void | INCDECC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Common driver method behind INCC and DECC (without sign, with carry) More... | |
void | INCDECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex) |
Common driver method behind INCSC and DECSC (with overflow flag) More... | |
void | INCDECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Common driver method behind INCSC and DECSC (without overflow flag) More... | |
void | INCBCD (bitCapInt toAdd, bitLenInt start, bitLenInt length) |
Add classical BCD integer (without sign) More... | |
void | INCDECBCDC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Common driver method behind INCSC and DECSC (without overflow flag) More... | |
void | MUL (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length) |
Multiply by integer. More... | |
void | DIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length) |
Divide by integer. More... | |
void | MULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length) |
Multiplication modulo N by integer, (out of place) More... | |
void | IMULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length) |
Inverse of multiplication modulo N by integer, (out of place) More... | |
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) More... | |
void | CMUL (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls) |
Controlled multiplication by integer. More... | |
void | CDIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls) |
Controlled division by power of integer. More... | |
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) More... | |
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) More... | |
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) More... | |
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. More... | |
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. More... | |
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 classical memory. More... | |
void | Hash (bitLenInt start, bitLenInt length, const unsigned char *values) |
Transform a length of qubit register via lookup through a hash table. More... | |
void | PhaseFlip () |
Phase flip always - equivalent to Z X Z X on any bit in the QInterface. More... | |
void | ZeroPhaseFlip (bitLenInt start, bitLenInt length) |
Reverse the phase of the state where the register equals zero. More... | |
void | SqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2) |
Square root of Swap gate. More... | |
void | ISqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2) |
Inverse square root of Swap gate. More... | |
void | FSim (real1_f theta, real1_f phi, bitLenInt qubit1, bitLenInt qubit2) |
The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics) More... | |
real1_f | ProbMask (bitCapInt mask, bitCapInt permutation) |
Direct measure of masked permutation probability. More... | |
real1_f | SumSqrDiff (QInterfacePtr toCompare) |
bool | ApproxCompare (QInterfacePtr toCompare, real1_f error_tol=TRYDECOMPOSE_EPSILON) |
Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target. More... | |
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 probability or measurement operation. More... | |
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. More... | |
real1_f | ProbAllRdm (bool roundRz, bitCapInt fullRegister) |
Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More... | |
real1_f | ProbMaskRdm (bool roundRz, bitCapInt mask, bitCapInt permutation) |
Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More... | |
real1_f | ExpectationBitsAll (const std::vector< bitLenInt > &bits, bitCapInt offset=0) |
Get permutation expectation value of bits. More... | |
real1_f | ExpectationBitsAllRdm (bool roundRz, const std::vector< bitLenInt > &bits, bitCapInt offset=0U) |
Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadgets. More... | |
real1_f | ExpectationBitsFactorized (const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U) |
Get expectation value of bits, given an array of qubit weights. More... | |
real1_f | ExpectationBitsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U) |
Get (reduced density matrix) expectation value of bits, given an array of qubit weights. More... | |
real1_f | ExpectationFloatsFactorized (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights) |
Get expectation value of bits, given a (floating-point) array of qubit weights. More... | |
real1_f | ExpectationFloatsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights) |
Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weights. More... | |
bool | TrySeparate (bitLenInt qubit) |
Single-qubit TrySeparate() More... | |
bool | TrySeparate (bitLenInt qubit1, bitLenInt qubit2) |
Two-qubit TrySeparate() More... | |
bool | TrySeparate (const std::vector< bitLenInt > &qubits, real1_f error_tol) |
Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed. More... | |
QInterfacePtr | Clone () |
Clone this QInterface. More... | |
void | SetDevice (int64_t dID) |
Set the device index, if more than one device is available. More... | |
int64_t | GetDeviceID () |
bitCapIntOcl | GetMaxSize () |
virtual bitLenInt | Compose (QInterfacePtr toCopy) |
Combine another QInterface with this one, after the last bit index of this one. More... | |
virtual std::map< QInterfacePtr, bitLenInt > | Compose (std::vector< QInterfacePtr > toCopy) |
virtual bitLenInt | Compose (QInterfacePtr toCopy, bitLenInt start) |
virtual bitLenInt | Allocate (bitLenInt length) |
Allocate new "length" count of |0> state qubits at end of qubit index position. More... | |
virtual bitLenInt | Allocate (bitLenInt start, bitLenInt length)=0 |
Allocate new "length" count of |0> state qubits at specified qubit index start position. More... | |
virtual void | UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs) |
Apply a "uniformly controlled" arbitrary single bit unitary transformation. More... | |
virtual void | UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs, const std::vector< bitCapInt > &mtrxSkipPowers, bitCapInt mtrxSkipValueMask) |
virtual bool | M (bitLenInt qubitIndex) |
Measurement gate. More... | |
virtual bitCapInt | M (const std::vector< bitLenInt > &bits) |
Measure bits with indices in array, and return a mask of the results. More... | |
virtual void | X (bitLenInt qubit) |
X gate. More... | |
virtual void | X (bitLenInt start, bitLenInt length) |
Bitwise Pauli X (or logical "NOT") operator. More... | |
Public Member Functions inherited from Qrack::QAlu | |
virtual void | CDEC (bitCapInt toSub, bitLenInt start, bitLenInt length, const std::vector< bitLenInt > &controls) |
Subtract integer (without sign, with controls) More... | |
virtual void | INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Add integer (without sign, with carry) More... | |
virtual void | DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract classical integer (without sign, with carry) More... | |
virtual void | INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex) |
Add a classical integer to the register, with sign and with carry. More... | |
virtual void | INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Add a classical integer to the register, with sign and with (phase-based) carry. More... | |
virtual void | DECSC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex) |
Subtract a classical integer from the register, with sign and with carry. More... | |
virtual void | DECSC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract a classical integer from the register, with sign and with carry. More... | |
virtual void | DECBCD (bitCapInt toSub, bitLenInt start, bitLenInt length) |
Subtract classical BCD integer (without sign) More... | |
virtual void | INCBCDC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Add classical BCD integer (without sign, with carry) More... | |
virtual void | DECBCDC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract BCD integer (without sign, with carry) More... | |
Public Member Functions inherited from Qrack::QParity | |
virtual bool | MParity (bitCapInt mask) |
Measure (and collapse) parity of the masked set of qubits. More... | |
virtual void | UniformParityRZ (bitCapInt mask, real1_f angle) |
If the target qubit set parity is odd, this applies a phase factor of \(e^{i angle}\). More... | |
Public Member Functions inherited from Qrack::QInterface | |
QInterface (bitLenInt n, qrack_rand_gen_ptr rgp=nullptr, bool doNorm=false, bool useHardwareRNG=true, bool randomGlobalPhase=true, real1_f norm_thresh=REAL1_EPSILON) | |
QInterface () | |
Default constructor, primarily for protected internal use. More... | |
virtual | ~QInterface () |
void | SetRandomSeed (uint32_t seed) |
virtual bitLenInt | GetQubitCount () |
Get the count of bits in this register. More... | |
virtual bitCapInt | GetMaxQPower () |
Get the maximum number of basis states, namely \( 2^n \) for \( n \) qubits. More... | |
virtual bool | GetIsArbitraryGlobalPhase () |
real1_f | Rand () |
Generate a random real number between 0 and 1. More... | |
virtual std::map< QInterfacePtr, bitLenInt > | Compose (std::vector< QInterfacePtr > toCopy) |
virtual bitLenInt | Allocate (bitLenInt length) |
Allocate new "length" count of |0> state qubits at end of qubit index position. More... | |
virtual void | UCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, bitCapInt controlPerm) |
Apply an arbitrary single bit unitary transformation, with arbitrary control bits, with arbitary control permutation. More... | |
virtual void | Phase (const complex topLeft, const complex bottomRight, bitLenInt qubitIndex) |
Apply a single bit transformation that only effects phase. More... | |
virtual void | Invert (const complex topRight, const complex bottomLeft, bitLenInt qubitIndex) |
Apply a single bit transformation that reverses bit probability and might effect phase. More... | |
virtual void | UCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target, bitCapInt perm) |
Apply a single bit transformation that only effects phase, with arbitrary control bits, with arbitrary control permutation. More... | |
virtual void | UCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target, bitCapInt perm) |
Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits, with arbitrary control permutation. More... | |
virtual void | UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs, const std::vector< bitCapInt > &mtrxSkipPowers, bitCapInt mtrxSkipValueMask) |
virtual void | TimeEvolve (Hamiltonian h, real1_f timeDiff) |
To define a Hamiltonian, give a vector of controlled single bit gates ("HamiltonianOp" instances) that are applied by left-multiplication in low-to-high vector index order on the state vector. More... | |
virtual void | AntiCSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2) |
Apply a swap with arbitrary (anti) control bits. More... | |
virtual void | CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Doubly-controlled NOT gate. More... | |
virtual void | AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Anti doubly-controlled NOT gate. More... | |
virtual void | CNOT (bitLenInt control, bitLenInt target) |
Controlled NOT gate. More... | |
virtual void | AntiCNOT (bitLenInt control, bitLenInt target) |
Anti controlled NOT gate. More... | |
virtual void | CY (bitLenInt control, bitLenInt target) |
Controlled Y gate. More... | |
virtual void | AntiCY (bitLenInt control, bitLenInt target) |
Anti controlled Y gate. More... | |
virtual void | CCY (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Doubly-Controlled Y gate. More... | |
virtual void | AntiCCY (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Anti doubly-controlled Y gate. More... | |
virtual void | CZ (bitLenInt control, bitLenInt target) |
Controlled Z gate. More... | |
virtual void | AntiCZ (bitLenInt control, bitLenInt target) |
Anti controlled Z gate. More... | |
virtual void | CCZ (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Doubly-Controlled Z gate. More... | |
virtual void | AntiCCZ (bitLenInt control1, bitLenInt control2, bitLenInt target) |
Anti doubly-controlled Z gate. More... | |
virtual void | U (bitLenInt target, real1_f theta, real1_f phi, real1_f lambda) |
General unitary gate. More... | |
virtual void | U2 (bitLenInt target, real1_f phi, real1_f lambda) |
2-parameter unitary gate More... | |
virtual void | IU2 (bitLenInt target, real1_f phi, real1_f lambda) |
Inverse 2-parameter unitary gate. More... | |
virtual void | AI (bitLenInt target, real1_f azimuth, real1_f inclination) |
"Azimuth, Inclination" (RY-RZ) More... | |
virtual void | IAI (bitLenInt target, real1_f azimuth, real1_f inclination) |
Invert "Azimuth, Inclination" (RY-RZ) More... | |
virtual void | CAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination) |
Controlled "Azimuth, Inclination" (RY-RZ) More... | |
virtual void | AntiCAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination) |
(Anti-)Controlled "Azimuth, Inclination" (RY-RZ) More... | |
virtual void | CIAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination) |
Controlled inverse "Azimuth, Inclination" (RY-RZ) More... | |
virtual void | AntiCIAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination) |
(Anti-)Controlled inverse "Azimuth, Inclination" (RY-RZ) More... | |
virtual void | CU (const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda) |
Controlled general unitary gate. More... | |
virtual void | AntiCU (const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda) |
(Anti-)Controlled general unitary gate More... | |
virtual void | H (bitLenInt qubit) |
Hadamard gate. More... | |
virtual void | SqrtH (bitLenInt qubit) |
Square root of Hadamard gate. More... | |
virtual void | SH (bitLenInt qubit) |
Y-basis transformation gate. More... | |
virtual void | HIS (bitLenInt qubit) |
Y-basis (inverse) transformation gate. More... | |
virtual void | S (bitLenInt qubit) |
S gate. More... | |
virtual void | IS (bitLenInt qubit) |
Inverse S gate. More... | |
virtual void | T (bitLenInt qubit) |
T gate. More... | |
virtual void | IT (bitLenInt qubit) |
Inverse T gate. More... | |
virtual void | PhaseRootN (bitLenInt n, bitLenInt qubit) |
"PhaseRootN" gate More... | |
virtual void | IPhaseRootN (bitLenInt n, bitLenInt qubit) |
Inverse "PhaseRootN" gate. More... | |
virtual void | PhaseParity (real1_f radians, bitCapInt mask) |
Parity phase gate. More... | |
virtual void | Y (bitLenInt qubit) |
Y gate. More... | |
virtual void | Z (bitLenInt qubit) |
Z gate. More... | |
virtual void | SqrtX (bitLenInt qubit) |
Square root of X gate. More... | |
virtual void | ISqrtX (bitLenInt qubit) |
Inverse square root of X gate. More... | |
virtual void | SqrtY (bitLenInt qubit) |
Square root of Y gate. More... | |
virtual void | ISqrtY (bitLenInt qubit) |
Inverse square root of Y gate. More... | |
virtual void | SqrtW (bitLenInt qubit) |
Square root of W gate. More... | |
virtual void | ISqrtW (bitLenInt qubit) |
Inverse square root of W gate. More... | |
virtual void | CH (bitLenInt control, bitLenInt target) |
Controlled H gate. More... | |
virtual void | AntiCH (bitLenInt control, bitLenInt target) |
(Anti-)controlled H gate More... | |
virtual void | CS (bitLenInt control, bitLenInt target) |
Controlled S gate. More... | |
virtual void | AntiCS (bitLenInt control, bitLenInt target) |
(Anti-)controlled S gate More... | |
virtual void | CIS (bitLenInt control, bitLenInt target) |
Controlled inverse S gate. More... | |
virtual void | AntiCIS (bitLenInt control, bitLenInt target) |
(Anti-)controlled inverse S gate More... | |
virtual void | CT (bitLenInt control, bitLenInt target) |
Controlled T gate. More... | |
virtual void | CIT (bitLenInt control, bitLenInt target) |
Controlled inverse T gate. More... | |
virtual void | CPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target) |
Controlled "PhaseRootN" gate. More... | |
virtual void | AntiCPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target) |
(Anti-)controlled "PhaseRootN" gate More... | |
virtual void | CIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target) |
Controlled inverse "PhaseRootN" gate. More... | |
virtual void | AntiCIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target) |
(Anti-)controlled inverse "PhaseRootN" gate More... | |
virtual void | AND (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "AND" gate. More... | |
virtual void | OR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "OR" gate. More... | |
virtual void | XOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "XOR" gate. More... | |
virtual void | CLAND (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "AND" gate. More... | |
virtual void | CLOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "OR" gate. More... | |
virtual void | CLXOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "XOR" gate. More... | |
virtual void | NAND (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "NAND" gate. More... | |
virtual void | NOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "NOR" gate. More... | |
virtual void | XNOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit) |
Quantum analog of classical "XNOR" gate. More... | |
virtual void | CLNAND (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "NAND" gate. More... | |
virtual void | CLNOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "NOR" gate. More... | |
virtual void | CLXNOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit) |
Quantum analog of classical "XNOR" gate. More... | |
virtual void | UniformlyControlledRY (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, real1 const *angles) |
Apply a "uniformly controlled" rotation of a bit around the Pauli Y axis. More... | |
virtual void | UniformlyControlledRZ (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, real1 const *angles) |
Apply a "uniformly controlled" rotation of a bit around the Pauli Z axis. More... | |
virtual void | RT (real1_f radians, bitLenInt qubitIndex) |
Phase shift gate. More... | |
virtual void | RX (real1_f radians, bitLenInt qubitIndex) |
X axis rotation gate. More... | |
virtual void | RY (real1_f radians, bitLenInt qubitIndex) |
Y axis rotation gate. More... | |
virtual void | RZ (real1_f radians, bitLenInt qubitIndex) |
Z axis rotation gate. More... | |
virtual void | CRZ (real1_f radians, bitLenInt control, bitLenInt target) |
Controlled Z axis rotation gate. More... | |
virtual void | CRY (real1_f radians, bitLenInt control, bitLenInt target) |
Controlled Y axis rotation gate. More... | |
virtual void | RTDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction phase shift gate. More... | |
virtual void | RXDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction X axis rotation gate. More... | |
virtual void | Exp (real1_f radians, bitLenInt qubitIndex) |
(Identity) Exponentiation gate More... | |
virtual void | Exp (const std::vector< bitLenInt > &controls, bitLenInt qubit, const complex *matrix2x2, bool antiCtrled=false) |
Imaginary exponentiation of arbitrary 2x2 gate. More... | |
virtual void | ExpDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction (identity) exponentiation gate. More... | |
virtual void | ExpX (real1_f radians, bitLenInt qubitIndex) |
Pauli X exponentiation gate. More... | |
virtual void | ExpXDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli X exponentiation gate. More... | |
virtual void | ExpY (real1_f radians, bitLenInt qubitIndex) |
Pauli Y exponentiation gate. More... | |
virtual void | ExpYDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli Y exponentiation gate. More... | |
virtual void | ExpZ (real1_f radians, bitLenInt qubitIndex) |
Pauli Z exponentiation gate. More... | |
virtual void | ExpZDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Pauli Z exponentiation gate. More... | |
virtual void | CRX (real1_f radians, bitLenInt control, bitLenInt target) |
Controlled X axis rotation gate. More... | |
virtual void | CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction X axis rotation gate. More... | |
virtual void | RYDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Y axis rotation gate. More... | |
virtual void | CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction y axis rotation gate. More... | |
virtual void | RZDyad (int numerator, int denomPower, bitLenInt qubitIndex) |
Dyadic fraction Z axis rotation gate. More... | |
virtual void | CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction Z axis rotation gate. More... | |
virtual void | CRT (real1_f radians, bitLenInt control, bitLenInt target) |
Controlled "phase shift gate". More... | |
virtual void | CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target) |
Controlled dyadic fraction "phase shift gate". More... | |
virtual void | H (bitLenInt start, bitLenInt length) |
Bitwise Hadamard. More... | |
virtual void | X (bitLenInt start, bitLenInt length) |
Bitwise Pauli X (or logical "NOT") operator. More... | |
virtual void | ROL (bitLenInt shift, bitLenInt start, bitLenInt length) |
Circular shift left - shift bits left, and carry last bits. More... | |
virtual void | ROR (bitLenInt shift, bitLenInt start, bitLenInt length) |
Circular shift right - shift bits right, and carry first bits. More... | |
virtual void | ASL (bitLenInt shift, bitLenInt start, bitLenInt length) |
Arithmetic shift left, with last 2 bits as sign and carry. More... | |
virtual void | ASR (bitLenInt shift, bitLenInt start, bitLenInt length) |
Arithmetic shift right, with last 2 bits as sign and carry. More... | |
virtual void | LSL (bitLenInt shift, bitLenInt start, bitLenInt length) |
Logical shift left, filling the extra bits with |0> More... | |
virtual void | LSR (bitLenInt shift, bitLenInt start, bitLenInt length) |
Logical shift right, filling the extra bits with |0> More... | |
virtual void | INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Add integer (without sign, with carry) More... | |
virtual void | DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex) |
Subtract classical integer (without sign, with carry) More... | |
virtual void | CDEC (bitCapInt toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls) |
Subtract classical integer (without sign, with controls) More... | |
virtual void | FullAdd (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut) |
Quantum analog of classical "Full Adder" gate. More... | |
virtual void | IFullAdd (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut) |
Inverse of FullAdd. More... | |
virtual void | CFullAdd (const std::vector< bitLenInt > &controls, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut) |
Controlled quantum analog of classical "Full Adder" gate. More... | |
virtual void | CIFullAdd (const std::vector< bitLenInt > &controls, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut) |
Inverse of CFullAdd. More... | |
virtual void | ADC (bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry) |
Add a quantum integer to a quantum integer, with carry. More... | |
virtual void | IADC (bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry) |
Inverse of ADC. More... | |
virtual void | CADC (const std::vector< bitLenInt > &controls, bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry) |
Add a quantum integer to a quantum integer, with carry and with controls. More... | |
virtual void | CIADC (const std::vector< bitLenInt > &controls, bitLenInt input1, bitLenInt input2, bitLenInt output, bitLenInt length, bitLenInt carry) |
Inverse of CADC. More... | |
virtual void | QFT (bitLenInt start, bitLenInt length, bool trySeparate=false) |
Quantum Fourier Transform - Apply the quantum Fourier transform to the register. More... | |
virtual void | QFTR (const std::vector< bitLenInt > &qubits, bool trySeparate=false) |
Quantum Fourier Transform (random access) - Apply the quantum Fourier transform to the register. More... | |
virtual void | IQFT (bitLenInt start, bitLenInt length, bool trySeparate=false) |
Inverse Quantum Fourier Transform - Apply the inverse quantum Fourier transform to the register. More... | |
virtual void | IQFTR (const std::vector< bitLenInt > &qubits, bool trySeparate=false) |
Inverse Quantum Fourier Transform (random access) - Apply the inverse quantum Fourier transform to the register. More... | |
virtual void | SetReg (bitLenInt start, bitLenInt length, bitCapInt value) |
Set register bits to given permutation. More... | |
virtual bitCapInt | MReg (bitLenInt start, bitLenInt length) |
Measure permutation state of a register. More... | |
virtual bitCapInt | ForceMReg (bitLenInt start, bitLenInt length, bitCapInt result, bool doForce=true, bool doApply=true) |
Act as if is a measurement was applied, except force the (usually random) result. More... | |
virtual bitCapInt | M (const std::vector< bitLenInt > &bits) |
Measure bits with indices in array, and return a mask of the results. More... | |
virtual bitCapInt | ForceM (const std::vector< bitLenInt > &bits, const std::vector< bool > &values, bool doApply=true) |
Measure bits with indices in array, and return a mask of the results. More... | |
virtual void | Reverse (bitLenInt first, bitLenInt last) |
Reverse all of the bits in a sequence. More... | |
virtual real1_f | CProb (bitLenInt control, bitLenInt target) |
Direct measure of bit probability to be in |1> state, if control bit is |1>. More... | |
virtual real1_f | ACProb (bitLenInt control, bitLenInt target) |
Direct measure of bit probability to be in |1> state, if control bit is |0>. More... | |
virtual real1_f | ProbReg (bitLenInt start, bitLenInt length, bitCapInt permutation) |
Direct measure of register permutation probability. More... | |
virtual void | ProbMaskAll (bitCapInt mask, real1 *probsArray) |
Direct measure of masked permutation probability. More... | |
virtual void | ProbBitsAll (const std::vector< bitLenInt > &bits, real1 *probsArray) |
Direct measure of listed permutation probability. More... | |
virtual void | SetBit (bitLenInt qubit, bool value) |
Set individual bit to pure |0> (false) or |1> (true) state. More... | |
virtual bool | TryDecompose (bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON) |
virtual bool | isOpenCL () |
Returns "true" if current simulation is OpenCL-based. More... | |
virtual double | GetUnitaryFidelity () |
When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1.0 fidelity, we compound the "unitary fidelity" by successive multiplication by one minus two times the true unitary probability discarded in each single rounding event. More... | |
virtual void | ResetUnitaryFidelity () |
Reset the internal fidelity calculation tracker to 1.0. More... | |
virtual void | SetSdrp (real1_f sdrp) |
Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1) More... | |
virtual void | SetReactiveSeparate (bool isAggSep) |
Set reactive separation option (on by default if available) More... | |
virtual bool | GetReactiveSeparate () |
Get reactive separation option. More... | |
virtual int64_t | GetDevice () |
Get the device index. More... | |
bitCapIntOcl | GetMaxSize () |
Get maximum number of amplitudes that can be allocated on current device. More... | |
virtual real1_f | FirstNonzeroPhase () |
Get phase of lowest permutation nonzero amplitude. More... | |
virtual void | DepolarizingChannelWeak1Qb (bitLenInt qubit, real1_f lambda) |
Simulate a local qubit depolarizing noise channel, under a stochastic "weak simulation condition." Under "weak" condition, sampling and exact state queries are not accurate, but sampling can be achieved via repeated full execution of a noisy circuit, for each hardware-realistic measurement sample. More... | |
virtual bitLenInt | DepolarizingChannelStrong1Qb (bitLenInt qubit, real1_f lambda) |
Simulate a local qubit depolarizing noise channel, under a "strong simulation condition." "Strong" condition supports measurement sampling and direct queries of state, but the expression of state is in terms of one retained ancillary qubit per applied noise channel. More... | |
Public Member Functions inherited from Qrack::ParallelFor | |
ParallelFor () | |
void | SetConcurrencyLevel (unsigned num) |
unsigned | GetConcurrencyLevel () |
bitCapIntOcl | GetStride () |
bitLenInt | GetPreferredConcurrencyPower () |
void | par_for_inc (const bitCapIntOcl begin, const bitCapIntOcl itemCount, IncrementFunc, ParallelFunc fn) |
Iterate through the permutations a maximum of end-begin times, allowing the caller to control the incrementation offset through 'inc'. More... | |
void | par_for (const bitCapIntOcl begin, const bitCapIntOcl end, ParallelFunc fn) |
Call fn once for every numerical value between begin and end. More... | |
void | par_for_skip (const bitCapIntOcl begin, const bitCapIntOcl end, const bitCapIntOcl skipPower, const bitLenInt skipBitCount, ParallelFunc fn) |
Skip over the skipPower bits. More... | |
void | par_for_mask (const bitCapIntOcl, const bitCapIntOcl, const std::vector< bitCapIntOcl > &maskArray, ParallelFunc fn) |
Skip over the bits listed in maskArray in the same fashion as par_for_skip. More... | |
void | par_for_set (const std::set< bitCapIntOcl > &sparseSet, ParallelFunc fn) |
Iterate over a sparse state vector. More... | |
void | par_for_set (const std::vector< bitCapIntOcl > &sparseSet, ParallelFunc fn) |
Iterate over a sparse state vector. More... | |
void | par_for_sparse_compose (const std::vector< bitCapIntOcl > &lowSet, const std::vector< bitCapIntOcl > &highSet, const bitLenInt &highStart, ParallelFunc fn) |
Iterate over the power set of 2 sparse state vectors. More... | |
real1_f | par_norm (const bitCapIntOcl maxQPower, const StateVectorPtr stateArray, real1_f norm_thresh=ZERO_R1_F) |
Calculate the normal for the array, (with flooring). More... | |
real1_f | par_norm_exact (const bitCapIntOcl maxQPower, const StateVectorPtr stateArray) |
Calculate the normal for the array, (without flooring.) More... | |
Protected Member Functions | |
QUnitCliffordPtr | MakeStabilizer (bitCapInt perm=0U) |
QInterfacePtr | MakeEngine (bitCapInt perm=0U) |
QInterfacePtr | MakeEngine (bitCapInt perm, bitLenInt qbCount) |
void | InvertBuffer (bitLenInt qubit) |
void | FlushH (bitLenInt qubit) |
void | FlushIfBlocked (bitLenInt control, bitLenInt target, bool isPhase=false) |
bool | CollapseSeparableShard (bitLenInt qubit) |
bool | TrimControls (const std::vector< bitLenInt > &lControls, std::vector< bitLenInt > &output, bool anti=false) |
void | CacheEigenstate (bitLenInt target) |
void | FlushBuffers () |
void | DumpBuffers () |
bool | EitherIsBuffered (bool logical) |
bool | IsBuffered () |
bool | IsLogicalBuffered () |
bool | EitherIsProbBuffered (bool logical) |
bool | IsProbBuffered () |
bool | IsLogicalProbBuffered () |
std::unique_ptr< complex[]> | GetQubitReducedDensityMatrix (bitLenInt qubit) |
template<typename F > | |
void | CheckShots (unsigned shots, bitCapInt m, real1_f partProb, const std::vector< bitCapInt > &qPowers, std::vector< real1_f > &rng, F fn) |
std::vector< real1_f > | GenerateShotProbs (unsigned shots) |
real1_f | FractionalRzAngleWithFlush (bitLenInt i, real1_f angle, bool isGateSuppressed=false) |
void | FlushCliffordFromBuffers () |
void | CombineAncillae () |
QStabilizerHybridPtr | RdmCloneHelper () |
void | RdmCloneFlush (real1_f threshold=FP_NORM_EPSILON) |
Flush non-Clifford phase gate gadgets with angle below a threshold. More... | |
real1_f | ExpectationFactorized (bool isFloat, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, const std::vector< real1_f > &weights, bitCapInt offset, bool roundRz) |
void | ClearAncilla (bitLenInt i) |
real1_f | ApproxCompareHelper (QStabilizerHybridPtr toCompare, bool isDiscreteBool, real1_f error_tol=TRYDECOMPOSE_EPSILON) |
void | ISwapHelper (bitLenInt qubit1, bitLenInt qubit2, bool inverse) |
complex | GetAmplitudeOrProb (bitCapInt perm, bool isProb=false) |
Protected Member Functions inherited from Qrack::QInterface | |
virtual void | SetQubitCount (bitLenInt qb) |
complex | GetNonunitaryPhase () |
template<typename Fn > | |
void | MACWrapper (const std::vector< bitLenInt > &controls, Fn fn) |
bitCapInt | SampleClone (const std::vector< bitCapInt > &qPowers) |
Protected Attributes | |
bool | useHostRam |
bool | doNormalize |
bool | isSparse |
bool | useTGadget |
bool | isRoundingFlushed |
bitLenInt | thresholdQubits |
bitLenInt | ancillaCount |
bitLenInt | deadAncillaCount |
bitLenInt | maxEngineQubitCount |
bitLenInt | maxAncillaCount |
bitLenInt | maxStateMapCacheQubitCount |
real1_f | separabilityThreshold |
int64_t | devID |
complex | phaseFactor |
QInterfacePtr | engine |
QUnitCliffordPtr | stabilizer |
std::vector< int64_t > | deviceIDs |
std::vector< QInterfaceEngine > | engineTypes |
std::vector< QInterfaceEngine > | cloneEngineTypes |
std::vector< MpsShardPtr > | shards |
std::map< bitCapInt, complex > | stateMapCache |
Protected Attributes inherited from Qrack::QInterface | |
bool | doNormalize |
bool | randGlobalPhase |
bool | useRDRAND |
bitLenInt | qubitCount |
uint32_t | randomSeed |
real1 | amplitudeFloor |
bitCapInt | maxQPower |
qrack_rand_gen_ptr | rand_generator |
std::uniform_real_distribution< real1_s > | rand_distribution |
std::shared_ptr< RdRandom > | hardware_rand_generator |
Friends | |
std::ostream & | operator<< (std::ostream &os, const QStabilizerHybridPtr s) |
std::istream & | operator>> (std::istream &is, const QStabilizerHybridPtr s) |
Additional Inherited Members | |
Static Protected Member Functions inherited from Qrack::QInterface | |
static real1_f | normHelper (complex c) |
static real1_f | clampProb (real1_f toClamp) |
A "Qrack::QStabilizerHybrid" internally switched between Qrack::QStabilizer and Qrack::QEngine to maximize performance.
Qrack::QStabilizerHybrid::QStabilizerHybrid | ( | 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 |
||
) |
|
inline |
|
inline |
Allocate new "length" count of |0> state qubits at end of qubit index position.
Allocate new "length" count of |0> state qubits at specified qubit index start position.
Implements Qrack::QInterface.
virtual bitLenInt Qrack::QInterface::Allocate |
Allocate new "length" count of |0> state qubits at specified qubit index start position.
|
virtual |
Apply an inverse square root of swap with arbitrary (anti) control bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply a square root of swap with arbitrary (anti) control bits.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target.
Reimplemented from Qrack::QInterface.
|
protected |
|
protected |
|
inlinevirtual |
Controlled division by power of integer.
Implements Qrack::QAlu.
|
inlineprotected |
|
inlinevirtual |
Inverse of controlled multiplication modulo N by integer, (out of place)
Implements Qrack::QAlu.
|
inlinevirtual |
Add integer (without sign, with controls)
Implements Qrack::QAlu.
|
virtual |
Apply an inverse square root of swap with arbitrary control bits.
Reimplemented from Qrack::QInterface.
|
inlineprotected |
|
virtual |
Clone this QInterface.
Implements Qrack::QInterface.
|
inlinevirtual |
Controlled multiplication by integer.
Implements Qrack::QAlu.
|
inlinevirtual |
Controlled multiplication modulo N by integer, (out of place)
Implements Qrack::QAlu.
|
protected |
|
protected |
|
inline |
Combine another QInterface with this one, after the last bit index of this one.
"Compose" combines the quantum description of state of two independent QInterface objects into one object, containing the full permutation basis of the full object. The "inputState" bits are added after the last qubit index of the QInterface to which we "Compose." Informally, "Compose" is equivalent to "just setting another group of qubits down next to the first" without interacting them. Schroedinger's equation can form a description of state for two independent subsystems at once or "separable quantum subsystems" without interacting them. Once the description of state of the independent systems is combined, we can interact them, and we can describe their entanglements to each other, in which case they are no longer independent. A full entangled description of quantum state is not possible for two independent quantum subsystems until we "Compose" them.
"Compose" multiplies the probabilities of the indepedent permutation states of the two subsystems to find the probabilites of the entire set of combined permutations, by simple combinatorial reasoning. If the probablity of the "left-hand" subsystem being in |00> is 1/4, and the probablity of the "right-hand" subsystem being in |101> is 1/8, than the probability of the combined |00101> permutation state is 1/32, and so on for all permutations of the new combined state.
If the programmer doesn't want to "cheat" quantum mechanically, then the original copy of the state which is duplicated into the larger QInterface should be "thrown away" to satisfy "no clone theorem." This is not semantically enforced in Qrack, because optimization of an emulator might be acheived by "cloning" "under-the-hood" while only exposing a quantum mechanically consistent API or instruction set.
Returns the quantum bit offset that the QInterface was appended at, such that bit 5 in toCopy is equal to offset+5 in this object.
|
inlinevirtual |
Combine another QInterface with this one, after the last bit index of this one.
"Compose" combines the quantum description of state of two independent QInterface objects into one object, containing the full permutation basis of the full object. The "inputState" bits are added after the last qubit index of the QInterface to which we "Compose." Informally, "Compose" is equivalent to "just setting another group of qubits down next to the first" without interacting them. Schroedinger's equation can form a description of state for two independent subsystems at once or "separable quantum subsystems" without interacting them. Once the description of state of the independent systems is combined, we can interact them, and we can describe their entanglements to each other, in which case they are no longer independent. A full entangled description of quantum state is not possible for two independent quantum subsystems until we "Compose" them.
"Compose" multiplies the probabilities of the indepedent permutation states of the two subsystems to find the probabilites of the entire set of combined permutations, by simple combinatorial reasoning. If the probablity of the "left-hand" subsystem being in |00> is 1/4, and the probablity of the "right-hand" subsystem being in |101> is 1/8, than the probability of the combined |00101> permutation state is 1/32, and so on for all permutations of the new combined state.
If the programmer doesn't want to "cheat" quantum mechanically, then the original copy of the state which is duplicated into the larger QInterface should be "thrown away" to satisfy "no clone theorem." This is not semantically enforced in Qrack, because optimization of an emulator might be acheived by "cloning" "under-the-hood" while only exposing a quantum mechanically consistent API or instruction set.
Returns the quantum bit offset that the QInterface was appended at, such that bit 5 in toCopy is equal to offset+5 in this object.
Reimplemented from Qrack::QInterface.
bitLenInt Qrack::QInterface::Compose |
|
inlinevirtual |
Reimplemented from Qrack::QInterface.
|
inline |
bitLenInt Qrack::QStabilizerHybrid::Compose | ( | QStabilizerHybridPtr | toCopy, |
bitLenInt | start | ||
) |
std::map< QInterfacePtr, bitLenInt > Qrack::QInterface::Compose |
bitLenInt Qrack::QStabilizerHybrid::ComposeEither | ( | QStabilizerHybridPtr | toCopy, |
bool | willDestroy | ||
) |
|
inlinevirtual |
Reimplemented from Qrack::QInterface.
|
inline |
|
inlinevirtual |
The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation.
Implements Qrack::QAlu.
|
inlinevirtual |
Controlled, raise a classical base to a quantum power, modulo N, (out of place)
Implements Qrack::QAlu.
|
virtual |
Apply a square root of swap with arbitrary control bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply a swap with arbitrary control bits.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
If the controls are set and the target qubit set parity is odd, this applies a phase factor of \(e^{i angle}\).
If the controls are set and the target qubit set parity is even, this applies the conjugate, \(e^{-i angle}\). Otherwise, do nothing if any control is not set.
Implements Qrack::QParity.
|
virtual |
Schmidt decompose a length of qubits.
Implements Qrack::QInterface.
|
inlinevirtual |
Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".
Minimally decompose a set of contigious bits from the separably composed unit. The length of this separable unit is reduced by the length of bits decomposed, and the bits removed are output in the destination QInterface pointer. The destination object must be initialized to the correct number of bits, in 0 permutation state. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."
Like how "Compose" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Decompose" is like "just moving a few qubits away from the rest." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state. (This is equivalent to a "Schmidt decomposition.")
If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:
\( P(|1000>|xy>) = P(|1000 00>) + P(|1000 10>) + P(|1000 01>) + P(|1000 11>). \)
If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.
Implements Qrack::QInterface.
void Qrack::QStabilizerHybrid::Decompose | ( | bitLenInt | start, |
QStabilizerHybridPtr | dest | ||
) |
|
inlinevirtual |
Add a classical integer to the register, with sign and without carry.
Subtract an integer from the register, with sign and without carry.
Because the register length is an arbitrary number of bits, the sign bit position on the integer to add is variable. Hence, the integer to add is specified as cast to an unsigned format, with the sign bit assumed to be set at the appropriate position before the cast.
Implements Qrack::QAlu.
Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separable bits from index "start" for "length.".
Minimally decompose a set of contigious bits from the separably composed unit. The length of this separable unit is reduced by the length of bits decomposed, and the bits removed are output in the destination QInterface pointer. The destination object must be initialized to the correct number of bits, in 0 permutation state. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."
Like how "Compose" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Decompose" is like "just moving a few qubits away from the rest." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state. (This is equivalent to a "Schmidt decomposition.")
If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:
\( P(|1000>|xy>) = P(|1000 00>) + P(|1000 10>) + P(|1000 01>) + P(|1000 11>). \)
If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.
Implements Qrack::QInterface.
|
virtual |
Dispose a a contiguous set of qubits that are already in a permutation eigenstate.
Implements Qrack::QInterface.
|
inlinevirtual |
Divide by integer.
Implements Qrack::QAlu.
|
inlinevirtual |
If asynchronous work is still running, let the simulator know that it can be aborted.
Note that this method is typically used internally where appropriate, such that user code typically does not call Dump().
Reimplemented from Qrack::QInterface.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinevirtual |
Get permutation expectation value of bits.
The permutation expectation value of all included bits is returned, with bits valued from low to high as the order of the "bits" array parameter argument.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadgets.
The permutation expectation value of all included bits is returned, with bits valued from low to high as the order of the "bits" array parameter argument.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Get expectation value of bits, given an array of qubit weights.
The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Get (reduced density matrix) expectation value of bits, given an array of qubit weights.
The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry. If there are stabilizer ancillae, they are traced out of the reduced density matrix, giving an approximate result.
Reimplemented from Qrack::QInterface.
|
inlineprotected |
|
inlinevirtual |
Get expectation value of bits, given a (floating-point) array of qubit weights.
The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "weights" entry.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weights.
The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "weights" entry. If there are stabilizer ancillae, they are traced out of the reduced density matrix, giving an approximate result.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
If asynchronous work is still running, block until it finishes.
Note that this is never necessary to get correct, timely return values. QEngines and other layers will always internally "Finish" when necessary for correct return values. This is primarily for debugging and benchmarking.
Reimplemented from Qrack::QInterface.
|
protected |
|
inlineprotected |
|
protected |
|
protected |
|
virtual |
Act as if is a measurement was applied, except force the (usually random) result.
Implements Qrack::QInterface.
|
virtual |
Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result.
Implements Qrack::QParity.
|
inlineprotected |
|
inlinevirtual |
The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics)
Implements Qrack::QInterface.
|
inlineprotected |
Get the representational amplitude of a full permutation.
Implements Qrack::QInterface.
|
protected |
|
inline |
|
inline |
|
virtual |
|
virtual |
|
inlineprotected |
|
inlinevirtual |
Get the option to use T-injection gadgets.
If T-injection gadgets are available, as in Qrack::QStabilizerHybrid, then turning this option on attempts to simulate Clifford+T with polynomial resource gadgets. It can either hurt or help performance, though it commonly helps.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Transform a length of qubit register via lookup through a hash table.
The hash table must be a one-to-one function, otherwise the behavior of this method is undefined. The value array definition convention is the same as IndexedLDA(). Essentially, this is an IndexedLDA() operation that replaces the index register with the value register, but the lookup table must therefore be one-to-one, for this operation to be unitary, as required.
Implements Qrack::QAlu.
|
inlinevirtual |
Inverse ISwap - Swap values of two bits in register, and apply phase factor of -i if bits are different.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Inverse of multiplication modulo N by integer, (out of place)
Implements Qrack::QAlu.
|
inlinevirtual |
Add integer (without sign)
Implements Qrack::QAlu.
|
inlinevirtual |
Add classical BCD integer (without sign)
Implements Qrack::QAlu.
|
inlinevirtual |
Common driver method behind INCSC and DECSC (without overflow flag)
Implements Qrack::QAlu.
|
inlinevirtual |
Common driver method behind INCC and DECC (without sign, with carry)
Implements Qrack::QAlu.
|
inlinevirtual |
Common driver method behind INCSC and DECSC (without overflow flag)
Implements Qrack::QAlu.
|
inlinevirtual |
Common driver method behind INCSC and DECSC (with overflow flag)
Implements Qrack::QAlu.
|
inlinevirtual |
Add a classical integer to the register, with sign and without carry.
Implements Qrack::QAlu.
|
inlinevirtual |
Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory.
"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value + values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See IndexedLDA() for context.
FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().
Implements Qrack::QAlu.
|
inlinevirtual |
Set 8 bit register bits by a superposed index-offset-based read from classical memory.
"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits are first cleared, then the separable |input, 00000000> permutation state is mapped to |input, values[input]>, with "values[input]" placed in the "outputStart" register. FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM.
The physical motivation for this addressing mode can be explained as follows: say that we have a superconducting quantum interface device (SQUID) based chip. SQUIDs have already been demonstrated passing coherently superposed electrical currents. In a sufficiently quantum-mechanically isolated qubit chip with a classical cache, with both classical RAM and registers likely cryogenically isolated from the environment, SQUIDs could (hopefully) pass coherently superposed electrical currents into the classical RAM cache to load values into a qubit register. The state loaded would be a superposition of the values of all RAM to which coherently superposed electrical currents were passed.
In qubit system similar to the MOS 6502, say we have qubit-based "accumulator" and "X index" registers, and say that we start with a superposed X index register. In (classical) X addressing mode, the X index register value acts an offset into RAM from a specified starting address. The X addressing mode of a LoaD Accumulator (LDA) instruction, by the physical mechanism described above, should load the accumulator in quantum parallel with the values of every different address of RAM pointed to in superposition by the X index register. The superposed values in the accumulator are entangled with those in the X index register, by way of whatever values the classical RAM pointed to by X held at the time of the load. (If the RAM at index "36" held an unsigned char value of "27," then the value "36" in the X index register becomes entangled with the value "27" in the accumulator, and so on in quantum parallel for all superposed values of the X index register, at once.) If the X index register or accumulator are then measured, the two registers will both always collapse into a random but valid key-value pair of X index offset and value at that classical RAM address.
Note that a "superposed store operation in classical RAM" is not possible by analagous reasoning. Classical RAM would become entangled with both the accumulator and the X register. When the state of the registers was collapsed, we would find that only one "store" operation to a single memory address had actually been carried out, consistent with the address offset in the collapsed X register and the byte value in the collapsed accumulator. It would not be possible by this model to write in quantum parallel to more than one address of classical memory at a time.
Implements Qrack::QAlu.
|
inlinevirtual |
Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory.
"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value - values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See QInterface::IndexedLDA for context.
FOR BEST EFFICIENCY, the "values" array should be allocated aligned to a 64-byte boundary. (See the unit tests suite code for an example of how to align the allocation.)
While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().
Implements Qrack::QAlu.
|
protected |
|
inlinevirtual |
Returns "true" if current state representation is definitely a binary decision tree, "false" if it is definitely not, or "true" if it cannot be determined.
Reimplemented from Qrack::QInterface.
|
inlineprotected |
|
inlinevirtual |
Returns "true" if current state is identifiably within the Clifford set, or "false" if it is not or cannot be determined.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is not or cannot be determined.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done.
Reimplemented from Qrack::QInterface.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinevirtual |
Inverse square root of Swap gate.
Reimplemented from Qrack::QInterface.
Swap values of two bits in register, and apply phase factor of i if bits are different.
Reimplemented from Qrack::QInterface.
|
protected |
|
inlinevirtual |
Implements Qrack::QAlu.
|
inline |
Measurement gate.
Measures the qubit at "qubitIndex" and returns either "true" or "false." (This "gate" breaks unitarity.)
All physical evolution of a quantum state should be "unitary," except measurement. Measurement of a qubit "collapses" the quantum state into either only permutation states consistent with a |0> state for the bit, or else only permutation states consistent with a |1> state for the bit. Measurement also effectively multiplies the overall quantum state vector of the system by a random phase factor, equiprobable over all possible phase angles.
Effectively, when a bit measurement is emulated, Qrack calculates the norm of all permutation state components, to find their respective probabilities. The probabilities of all states in which the measured bit is "0" can be summed to give the probability of the bit being "0," and separately the probabilities of all states in which the measured bit is "1" can be summed to give the probability of the bit being "1." To simulate measurement, a random float between 0 and 1 is compared to the sum of the probability of all permutation states in which the bit is equal to "1". Depending on whether the random float is higher or lower than the probability, the qubit is determined to be either |0> or |1>, (up to phase). If the bit is determined to be |1>, then all permutation eigenstates in which the bit would be equal to |0> have their probability set to zero, and vice versa if the bit is determined to be |0>. Then, all remaining permutation states with nonzero probability are linearly rescaled so that the total probability of all permutation states is again "normalized" to exactly 100% or 1, (within double precision rounding error). Physically, the act of measurement should introduce an overall random phase factor on the state vector, which is emulated by generating another constantly distributed random float to select a phase angle between 0 and 2 * Pi.
Measurement breaks unitary evolution of state. All quantum gates except measurement should generally act as a unitary matrix on a permutation state vector. (Note that Boolean comparison convenience methods in Qrack such as "AND," "OR," and "XOR" employ the measurement operation in the act of first clearing output bits before filling them with the result of comparison, and these convenience methods therefore break unitary evolution of state, but in a physically realistic way. Comparable unitary operations would be performed with a combination of X and CCNOT gates, also called "Toffoli" gates, but the output bits would have to be assumed to be in a known fixed state, like all |0>, ahead of time to produce unitary logical comparison operations.)
|
inline |
Measure bits with indices in array, and return a mask of the results.
|
virtual |
Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits.
Reimplemented from Qrack::QInterface.
|
protected |
|
protected |
|
protected |
|
virtual |
Measure permutation state of all coherent bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply an arbitrary single bit unitary transformation, with arbitrary control bits.
Implements Qrack::QInterface.
|
virtual |
Apply a single bit transformation that only effects phase, with arbitrary control bits.
Reimplemented from Qrack::QInterface.
Apply an arbitrary single bit unitary transformation.
Implements Qrack::QInterface.
|
inlinevirtual |
Multiply by integer.
Implements Qrack::QAlu.
|
inlinevirtual |
Multiplication modulo N by integer, (out of place)
Implements Qrack::QAlu.
|
virtual |
Statistical measure of masked permutation probability.
"qPowers" contains powers of 2^n, each representing QInterface bit "n." The order of these values defines a mask for the result bitCapInt, of 2^0 ~ qPowers[0U] to 2^(qPowerCount - 1) ~ qPowers[qPowerCount - 1], in contiguous ascending order. "shots" specifies the number of samples to take as if totally re-preparing the pre-measurement state. This method returns a dictionary with keys, which are the (masked-order) measurement results, and values, which are the number of "shots" that produced that particular measurement result. This method does not "collapse" the state of this QInterface. (The idea is to efficiently simulate a potentially statistically random sample of multiple re-preparations of the state right before measurement, and to collect random measurement resutls, without forcing the user to re-prepare or "clone" the state.)
Reimplemented from Qrack::QInterface.
|
virtual |
Statistical measure of masked permutation probability (returned as array)
Same Qrack::MultiShotMeasureMask()
, except the shots are returned as an array.
Reimplemented from Qrack::QInterface.
|
virtual |
Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate.
(On an actual quantum computer, the state should never require manual normalization.)
Implements Qrack::QInterface.
|
inlinevirtual |
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
This is an expedient for an adaptive Grover's search for a function's global minimum.
Implements Qrack::QAlu.
|
inlinevirtual |
Raise a classical base to a quantum power, modulo N, (out of place)
Implements Qrack::QAlu.
Direct measure of bit probability to be in |1> state.
Implements Qrack::QInterface.
Direct measure of full permutation probability.
Reimplemented from Qrack::QInterface.
Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets.
Reimplemented from Qrack::QInterface.
Direct measure of masked permutation probability.
Returns probability of permutation of the mask.
"mask" masks the bits to check the probability of. "permutation" sets the 0 or 1 value for each bit in the mask. Bits which are set in the mask can be set to 0 or 1 in the permutation, while reset bits in the mask should be 0 in the permutation.
Reimplemented from Qrack::QInterface.
|
virtual |
Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T gate gadgets.
"mask" masks the bits to check the probability of. "permutation" sets the 0 or 1 value for each bit in the mask. Bits which are set in the mask can be set to 0 or 1 in the permutation, while reset bits in the mask should be 0 in the permutation.
Reimplemented from Qrack::QInterface.
Overall probability of any odd permutation of the masked set of bits.
Implements Qrack::QParity.
Direct measure of bit probability to be in |1> state, treating all ancillary qubits as post-selected T gate gadgets.
Reimplemented from Qrack::QInterface.
|
protected |
Flush non-Clifford phase gate gadgets with angle below a threshold.
|
inlineprotected |
Sets the representational amplitude of a full permutation.
Implements Qrack::QInterface.
|
inlinevirtual |
Set the number of threads in parallel for loops, per component QEngine.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Set the device index, if more than one device is available.
Implements Qrack::QInterface.
|
virtual |
Set to a specific permutation of all qubits.
Reimplemented from Qrack::QInterface.
|
virtual |
Set an arbitrary pure quantum state representation.
Implements Qrack::QInterface.
|
inlinevirtual |
Set the option to use T-injection gadgets (off by default)
If T-injection gadgets are available, as in Qrack::QStabilizerHybrid, then turning this option on attempts to simulate Clifford+T with polynomial resource gadgets. It can either hurt or help performance, though it commonly helps.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Square root of Swap gate.
Reimplemented from Qrack::QInterface.
|
inlinevirtual |
Implements Qrack::QInterface.
Swap values of two bits in register.
Reimplemented from Qrack::QInterface.
void Qrack::QStabilizerHybrid::SwitchToEngine | ( | ) |
Switches between CPU and GPU used modes.
(This will not incur a performance penalty, if the chosen mode matches the current mode.) Mode switching happens automatically when qubit counts change, but Compose() and Decompose() might leave their destination QInterface parameters in the opposite mode.
|
protected |
|
virtual |
Single-qubit TrySeparate()
Reimplemented from Qrack::QInterface.
Two-qubit TrySeparate()
Reimplemented from Qrack::QInterface.
|
virtual |
Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed.
This method is used to manually attempt internal separation of a QUnit subsytem. We attempt a Decompose() operation, on a state which might not be separable. If the state is not separable, we abort and return false. Otherwise, we complete the operation, add the separated subsystem back in place into the QUnit "shards," and return true.
This should never change the logical/physical state of the QInterface, only possibly its internal representation, for simulation optimization purposes. This is not a truly quantum computational operation, but it also does not lead to nonphysical effects.
Reimplemented from Qrack::QInterface.
|
inline |
Apply a "uniformly controlled" arbitrary single bit unitary transformation.
(See https://arxiv.org/abs/quant-ph/0312218)
A different unitary 2x2 complex matrix is associated with each permutation of the control bits. The first control bit index in the "controls" array is the least significant bit of the permutation, proceeding to the most significant bit. "mtrxs" is a flat (1-dimensional) array where each subsequent set of 4 components is an arbitrary 2x2 single bit gate associated with the next permutation of the control bits, starting from 0. All combinations of control bits apply one of the 4 component (flat 2x2) matrices. For k control bits, there are therefore 4 * 2^k complex components in "mtrxs," representing 2^k complex matrices of 2x2 components. (The component ordering in each matrix is the same as all other gates with an arbitrary 2x2 applied to a single bit, such as Qrack::ApplySingleBit.)
|
virtual |
Apply a "uniformly controlled" arbitrary single bit unitary transformation.
(See https://arxiv.org/abs/quant-ph/0312218)
A different unitary 2x2 complex matrix is associated with each permutation of the control bits. The first control bit index in the "controls" array is the least significant bit of the permutation, proceeding to the most significant bit. "mtrxs" is a flat (1-dimensional) array where each subsequent set of 4 components is an arbitrary 2x2 single bit gate associated with the next permutation of the control bits, starting from 0. All combinations of control bits apply one of the 4 component (flat 2x2) matrices. For k control bits, there are therefore 4 * 2^k complex components in "mtrxs," representing 2^k complex matrices of 2x2 components. (The component ordering in each matrix is the same as all other gates with an arbitrary 2x2 applied to a single bit, such as Qrack::ApplySingleBit.)
Reimplemented from Qrack::QInterface.
void Qrack::QInterface::UniformlyControlledSingleBit |
|
inlinevirtual |
Force a calculation of the norm of the state vector, in order to make it unit length before the next probability or measurement operation.
(On an actual quantum computer, the state should never require manual normalization.)
Implements Qrack::QInterface.
|
inlinevirtual |
Implements Qrack::QAlu.
|
inline |
X gate.
Applies the Pauli "X" operator to the qubit at "qubitIndex." The Pauli "X" operator is equivalent to a logical "NOT."
|
inline |
Bitwise Pauli X (or logical "NOT") operator.
|
virtual |
Masked X gate.
Applies the Pauli "X" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)
0). The Pauli "X" operator is equivalent to a logical "NOT."
Reimplemented from Qrack::QInterface.
|
virtual |
Masked Y gate.
Applies the Pauli "Y" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)
0). The Pauli "Y" operator is similar to a logical "NOT" with permutation phase.
Reimplemented from Qrack::QInterface.
Reverse the phase of the state where the register equals zero.
Reimplemented from Qrack::QInterface.
|
virtual |
Masked Z gate.
Applies the Pauli "Z" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)
0). The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.
Reimplemented from Qrack::QInterface.
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |