Qrack  9.9
General classical-emulating-quantum development framework
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Qrack::QEngine Class Referenceabstract

Abstract QEngine implementation, for all "Schroedinger method" engines. More...

#include <qengine.hpp>

Inheritance diagram for Qrack::QEngine:
Inheritance graph
[legend]
Collaboration diagram for Qrack::QEngine:
Collaboration graph
[legend]

Public Member Functions

 QEngine (bitLenInt qBitCount, qrack_rand_gen_ptr rgp=nullptr, bool doNorm=false, bool randomGlobalPhase=true, bool useHostMem=false, bool useHardwareRNG=true, real1_f norm_thresh=REAL1_EPSILON)
 
 QEngine ()
 Default constructor, primarily for protected internal use. More...
 
virtual ~QEngine ()
 
virtual void SetQubitCount (bitLenInt qb)
 
virtual real1_f GetRunningNorm ()
 Get in-flight renormalization factor. More...
 
virtual void SwitchHostPtr (bool useHostMem)
 Switch to/from host/device state vector bufffer. More...
 
virtual void ResetHostPtr ()
 Reset host/device state vector bufffer usage to default. More...
 
virtual void SetDevice (int64_t dID)
 Set GPU device ID. More...
 
virtual int64_t GetDevice ()
 Get GPU device ID. More...
 
virtual void ZeroAmplitudes ()=0
 Set all amplitudes to 0, and optionally temporarily deallocate state vector RAM. More...
 
virtual void CopyStateVec (QEnginePtr src)=0
 Exactly copy the state vector of a different QEngine instance. More...
 
virtual bool IsZeroAmplitude ()=0
 Returns "true" only if amplitudes are all totally 0. More...
 
virtual void GetAmplitudePage (complex *pagePtr, bitCapIntOcl offset, bitCapIntOcl length)=0
 Copy a "page" of amplitudes from this QEngine's internal state, into pagePtr. More...
 
virtual void SetAmplitudePage (const complex *pagePtr, bitCapIntOcl offset, bitCapIntOcl length)=0
 Copy a "page" of amplitudes from pagePtr into this QEngine's internal state. More...
 
virtual void SetAmplitudePage (QEnginePtr pageEnginePtr, bitCapIntOcl srcOffset, bitCapIntOcl dstOffset, bitCapIntOcl length)=0
 Copy a "page" of amplitudes from another QEngine, pointed to by pageEnginePtr, into this QEngine's internal state. More...
 
virtual void ShuffleBuffers (QEnginePtr engine)=0
 Swap the high half of this engine with the low half of another. More...
 
virtual QEnginePtr CloneEmpty ()=0
 Clone this QEngine's settings, with a zeroed state vector. More...
 
virtual void QueueSetDoNormalize (bool doNorm)=0
 Add an operation to the (OpenCL) queue, to set the value of doNormalize, which controls whether to automatically normalize the state. More...
 
virtual void QueueSetRunningNorm (real1_f runningNrm)=0
 Add an operation to the (OpenCL) queue, to set the value of runningNorm, which is the normalization constant for the next normalization operation. More...
 
virtual void ZMask (const bitCapInt &mask)
 Masked Z gate. More...
 
virtual bool ForceM (bitLenInt qubitIndex, bool result, bool doForce=true, bool doApply=true)
 PSEUDO-QUANTUM - Acts like a measurement gate, except with a specified forced result. More...
 
virtual bitCapInt ForceM (const std::vector< bitLenInt > &bits, const std::vector< bool > &values, bool doApply=true)
 Measure permutation state of a register. More...
 
virtual bitCapInt ForceMReg (bitLenInt start, bitLenInt length, const bitCapInt &result, bool doForce=true, bool doApply=true)
 Measure permutation state of a register. More...
 
virtual void ApplyM (const bitCapInt &qPower, bool result, const complex &nrm)
 
virtual void ApplyM (const bitCapInt &regMask, const bitCapInt &result, const complex &nrm)=0
 
virtual void Mtrx (const complex *mtrx, bitLenInt qubit)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void MCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More...
 
virtual void MACMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More...
 
virtual void UCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, const bitCapInt &controlPerm)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits, with arbitary control permutation. More...
 
virtual void CSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary control bits. More...
 
virtual void AntiCSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary (anti) control bits. More...
 
virtual void CSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary control bits. More...
 
virtual void AntiCSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary (anti) control bits. More...
 
virtual void CISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary control bits. More...
 
virtual void AntiCISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary (anti) control bits. More...
 
virtual bool M (bitLenInt q)
 
virtual void X (bitLenInt q)
 
virtual void INC (const bitCapInt &toAdd, bitLenInt start, bitLenInt length)
 Add integer (without sign) More...
 
virtual void DEC (const bitCapInt &toSub, bitLenInt start, bitLenInt length)
 Add integer (without sign) More...
 
virtual void INCC (const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add integer (without sign, with carry) More...
 
virtual void DECC (const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract classical integer (without sign, with carry) More...
 
virtual void INCS (const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Add a classical integer to the register, with sign and without carry. More...
 
virtual void DECS (const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Add a classical integer to the register, with sign and without carry. More...
 
virtual void CINC (const bitCapInt &toAdd, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
 Add integer (without sign, with controls) More...
 
virtual void CDEC (const bitCapInt &toSub, bitLenInt inOutStart, bitLenInt length, const std::vector< bitLenInt > &controls)
 Subtract integer (without sign, with controls) More...
 
virtual void INCDECC (const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Common driver method behind INCC and DECC (without sign, with carry) More...
 
virtual void MULModNOut (const bitCapInt &toMul, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)
 Multiplication modulo N by integer, (out of place) More...
 
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) More...
 
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) More...
 
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) More...
 
virtual void Swap (bitLenInt qubit1, bitLenInt qubit2)
 Swap values of two bits in register. More...
 
virtual void ISwap (bitLenInt qubit1, bitLenInt qubit2)
 Swap values of two bits in register, and apply phase factor of i if bits are different. More...
 
virtual 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...
 
virtual void SqrtSwap (bitLenInt qubit1, bitLenInt qubit2)
 Square root of Swap gate. More...
 
virtual void ISqrtSwap (bitLenInt qubit1, bitLenInt qubit2)
 Inverse square root of Swap gate. More...
 
virtual void FSim (real1_f theta, real1_f phi, bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics) More...
 
virtual real1_f ProbAll (const bitCapInt &fullRegister)
 Direct measure of full permutation probability. More...
 
virtual real1_f CtrlOrAntiProb (bool controlState, bitLenInt control, bitLenInt target)
 
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, const bitCapInt &permutation)=0
 Direct measure of register permutation probability. More...
 
virtual void ProbRegAll (bitLenInt start, bitLenInt length, real1 *probsArray)
 
virtual real1_f ProbMask (const bitCapInt &mask, const bitCapInt &permutation)=0
 Direct measure of masked permutation probability. More...
 
virtual real1_f GetExpectation (bitLenInt valueStart, bitLenInt valueLength)=0
 
virtual void Apply2x2 (bitCapIntOcl offset1, bitCapIntOcl offset2, const complex *mtrx, bitLenInt bitCount, bitCapIntOcl const *qPowersSorted, bool doCalcNorm, real1_f norm_thresh=REAL1_DEFAULT_ARG)=0
 
virtual void ApplyControlled2x2 (const std::vector< bitLenInt > &controls, bitLenInt target, const complex *mtrx)
 
virtual void ApplyAntiControlled2x2 (const std::vector< bitLenInt > &controls, bitLenInt target, const complex *mtrx)
 
virtual QInterfacePtr Decompose (bitLenInt start, bitLenInt length)
 Schmidt decompose a length of qubits. More...
 
virtual std::map< bitCapInt, int > MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots)
 Statistical measure of masked permutation probability. More...
 
virtual void MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots, unsigned long long *shotsArray)
 Statistical measure of masked permutation probability (returned as array) More...
 
virtual bool M (bitLenInt qubit)
 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...
 
virtual void Swap (bitLenInt qubit1, bitLenInt qubit2)
 Swap values of two bits in register. More...
 
virtual void ISwap (bitLenInt qubit1, bitLenInt qubit2)
 Swap values of two bits in register, and apply phase factor of i if bits are different. More...
 
virtual 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...
 
virtual void SqrtSwap (bitLenInt qubit1, bitLenInt qubit2)
 Square root of Swap gate. More...
 
virtual void ISqrtSwap (bitLenInt qubit1, bitLenInt qubit2)
 Inverse square root of Swap gate. More...
 
virtual void FSim (real1_f theta, real1_f phi, bitLenInt qubit1, bitLenInt qubit2)=0
 The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics) More...
 
virtual void Decompose (bitLenInt start, QInterfacePtr dest)=0
 Minimally decompose a set of contiguous bits from the separably composed unit, into "destination". More...
 
virtual QInterfacePtr Decompose (bitLenInt start, bitLenInt length)=0
 Schmidt decompose a length of qubits. More...
 
- Public Member Functions inherited from Qrack::QAlu
virtual void PhaseFlipIfLess (const bitCapInt &greaterPerm, bitLenInt start, bitLenInt length)=0
 This is an expedient for an adaptive Grover's search for a function's global minimum. More...
 
virtual void CPhaseFlipIfLess (const bitCapInt &greaterPerm, bitLenInt start, bitLenInt length, bitLenInt flagIndex)=0
 The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation. More...
 
virtual void INCSC (const 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 (const 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 (const 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 (const bitCapInt &toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract a classical integer from the register, with sign and with carry. More...
 
virtual void INCDECSC (const bitCapInt &toMod, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Common driver method behind INCSC and DECSC (without overflow flag) More...
 
virtual void INCDECSC (const bitCapInt &toMod, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)=0
 Common driver method behind INCSC and DECSC (with overflow flag) More...
 
virtual void MUL (const bitCapInt &toMul, bitLenInt start, bitLenInt carryStart, bitLenInt length)=0
 Multiply by integer. More...
 
virtual void DIV (const bitCapInt &toDiv, bitLenInt start, bitLenInt carryStart, bitLenInt length)=0
 Divide by integer. More...
 
virtual void POWModNOut (const bitCapInt &base, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)=0
 Raise a classical base to a quantum power, modulo N, (out of place) More...
 
virtual void CMUL (const bitCapInt &toMul, bitLenInt start, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)=0
 Controlled multiplication by integer. More...
 
virtual void CDIV (const bitCapInt &toDiv, bitLenInt start, bitLenInt carryStart, bitLenInt length, const std::vector< bitLenInt > &controls)=0
 Controlled division by power of integer. More...
 
virtual void CPOWModNOut (const bitCapInt &base, const bitCapInt &modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, const std::vector< bitLenInt > &controls)=0
 Controlled, raise a classical base to a quantum power, modulo N, (out of place) More...
 
virtual void INCBCD (const bitCapInt &toAdd, bitLenInt start, bitLenInt length)=0
 Add classical BCD integer (without sign) More...
 
virtual void DECBCD (const bitCapInt &toSub, bitLenInt start, bitLenInt length)
 Subtract classical BCD integer (without sign) More...
 
virtual void INCDECBCDC (const bitCapInt &toMod, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Common driver method behind INCSC and DECSC (without overflow flag) More...
 
virtual bitCapInt IndexedLDA (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, const unsigned char *values, bool resetValue=true)=0
 Set 8 bit register bits by a superposed index-offset-based read from classical memory. More...
 
virtual bitCapInt IndexedADC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, const unsigned char *values)=0
 Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory. More...
 
virtual bitCapInt IndexedSBC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, const unsigned char *values)=0
 Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory. More...
 
virtual void Hash (bitLenInt start, bitLenInt length, const unsigned char *values)=0
 Transform a length of qubit register via lookup through a hash table. More...
 
virtual void INCBCDC (const bitCapInt &toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add classical BCD integer (without sign, with carry) More...
 
virtual void DECBCDC (const 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 (const bitCapInt &mask)
 Measure (and collapse) parity of the masked set of qubits. More...
 
virtual void UniformParityRZ (const bitCapInt &mask, real1_f angle)
 If the target qubit set parity is odd, this applies a phase factor of \(e^{i angle}\). More...
 
virtual real1_f ProbParity (const bitCapInt &mask)=0
 Overall probability of any odd permutation of the masked set of bits. More...
 
virtual bool ForceMParity (const bitCapInt &mask, bool result, bool doForce=true)=0
 Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result. More...
 
virtual void CUniformParityRZ (const std::vector< bitLenInt > &controls, const bitCapInt &mask, real1_f angle)=0
 If the controls are set and 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 void SetConcurrency (uint32_t threadsPerEngine)
 Set the number of threads in parallel for loops, per component QEngine. More...
 
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 void SetQuantumState (const complex *inputState)=0
 Set an arbitrary pure quantum state representation. More...
 
virtual void GetQuantumState (complex *outputState)=0
 Get the pure quantum state representation. More...
 
virtual void GetProbs (real1 *outputProbs)=0
 Get the pure quantum state representation. More...
 
virtual complex GetAmplitude (const bitCapInt &perm)=0
 Get the representational amplitude of a full permutation. More...
 
virtual void SetAmplitude (const bitCapInt &perm, const complex &amp)=0
 Sets the representational amplitude of a full permutation. More...
 
virtual void SetPermutation (const bitCapInt &perm, const complex &phaseFac=CMPLX_DEFAULT_ARG)
 Set to a specific permutation of all qubits. More...
 
virtual bitLenInt Compose (QInterfacePtr toCopy)
 Combine another QInterface with this one, after the last bit index of this one. More...
 
virtual bitLenInt ComposeNoClone (QInterfacePtr toCopy)
 This is a variant of Compose() for a toCopy argument that will definitely not be reused once "Composed," hence more aggressive optimization can be done. More...
 
virtual std::map< QInterfacePtr, bitLenIntCompose (std::vector< QInterfacePtr > toCopy)
 Compose() a vector of peer QInterface targets, in sequence. More...
 
virtual bitLenInt Compose (QInterfacePtr toCopy, bitLenInt start)
 Compose() a QInterface peer, inserting its qubit into index order at start index. More...
 
virtual void Decompose (bitLenInt start, QInterfacePtr dest)=0
 Minimally decompose a set of contiguous bits from the separably composed unit, into "destination". More...
 
virtual void Dispose (bitLenInt start, bitLenInt length)=0
 Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separable bits from index "start" for "length.". More...
 
virtual void Dispose (bitLenInt start, bitLenInt length, const bitCapInt &disposedPerm)=0
 Dispose a a contiguous set of qubits that are already in a permutation eigenstate. More...
 
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 Phase (const complex &topLeft, const complex &bottomRight, bitLenInt qubit)
 Apply a single bit transformation that only effects phase. More...
 
virtual void Invert (const complex &topRight, const complex &bottomLeft, bitLenInt qubit)
 Apply a single bit transformation that reverses bit probability and might effect phase. More...
 
virtual 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. More...
 
virtual 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, with arbitrary control bits. More...
 
virtual 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. More...
 
virtual 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, with arbitrary (anti-)control bits. More...
 
virtual void UCPhase (const std::vector< bitLenInt > &controls, const complex &topLeft, const complex &bottomRight, bitLenInt target, const 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, const complex &topRight, const complex &bottomLeft, bitLenInt target, const 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 qubit, const complex *mtrxs)
 Apply a "uniformly controlled" arbitrary single bit unitary transformation. More...
 
virtual void UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubit, const complex *mtrxs, const std::vector< bitCapInt > &mtrxSkipPowers, const 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 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 PhaseRootNMask (bitLenInt n, const bitCapInt &mask)
 Masked PhaseRootN gate. More...
 
virtual void PhaseParity (real1_f radians, const bitCapInt &mask)
 Parity phase gate. More...
 
virtual void XMask (const bitCapInt &mask)
 Masked X gate. More...
 
virtual void Y (bitLenInt qubit)
 Y gate. More...
 
virtual void YMask (const bitCapInt &mask)
 Masked 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 qubit, 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 qubit, real1 const *angles)
 Apply a "uniformly controlled" rotation of a bit around the Pauli Z axis. More...
 
virtual void RT (real1_f radians, bitLenInt qubit)
 Phase shift gate. More...
 
virtual void RX (real1_f radians, bitLenInt qubit)
 X axis rotation gate. More...
 
virtual void RY (real1_f radians, bitLenInt qubit)
 Y axis rotation gate. More...
 
virtual void RZ (real1_f radians, bitLenInt qubit)
 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 qubit)
 Dyadic fraction phase shift gate. More...
 
virtual void RXDyad (int numerator, int denomPower, bitLenInt qubit)
 Dyadic fraction X axis rotation gate. More...
 
virtual void Exp (real1_f radians, bitLenInt qubit)
 (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 qubit)
 Dyadic fraction (identity) exponentiation gate. More...
 
virtual void ExpX (real1_f radians, bitLenInt qubit)
 Pauli X exponentiation gate. More...
 
virtual void ExpXDyad (int numerator, int denomPower, bitLenInt qubit)
 Dyadic fraction Pauli X exponentiation gate. More...
 
virtual void ExpY (real1_f radians, bitLenInt qubit)
 Pauli Y exponentiation gate. More...
 
virtual void ExpYDyad (int numerator, int denomPower, bitLenInt qubit)
 Dyadic fraction Pauli Y exponentiation gate. More...
 
virtual void ExpZ (real1_f radians, bitLenInt qubit)
 Pauli Z exponentiation gate. More...
 
virtual void ExpZDyad (int numerator, int denomPower, bitLenInt qubit)
 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 qubit)
 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 qubit)
 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 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 ZeroPhaseFlip (bitLenInt start, bitLenInt length)
 Reverse the phase of the state where the register equals zero. More...
 
virtual void PhaseFlip ()
 Phase flip always - equivalent to Z X Z X on any bit in the QInterface. More...
 
virtual void SetReg (bitLenInt start, bitLenInt length, const 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 MAll ()
 Measure permutation state of all coherent bits. 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 Reverse (bitLenInt first, bitLenInt last)
 Reverse all of the bits in a sequence. More...
 
virtual real1_f Prob (bitLenInt qubit)=0
 Direct measure of bit probability to be in |1> state. More...
 
virtual void ProbMaskAll (const 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 real1_f VarianceBitsAll (const std::vector< bitLenInt > &bits, const bitCapInt &offset=ZERO_BCI)
 Direct measure of variance of listed permutation probability. More...
 
virtual real1_f VarianceBitsAllRdm (bool roundRz, const std::vector< bitLenInt > &bits, const bitCapInt &offset=ZERO_BCI)
 Direct measure of (reduced density matrix) variance of listed permutation probability. More...
 
virtual real1_f VariancePauliAll (std::vector< bitLenInt > bits, std::vector< Pauli > paulis)
 Direct measure of variance of listed Pauli tensor product probability. More...
 
virtual real1_f VarianceUnitaryAll (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &basisOps, std::vector< real1_f > eigenVals={})
 Direct measure of variance of listed (3-parameter) single-qubit tensor product probability. More...
 
virtual real1_f VarianceUnitaryAll (const std::vector< bitLenInt > &bits, const std::vector< std::shared_ptr< complex >> &basisOps, std::vector< real1_f > eigenVals={})
 Direct measure of variance of listed (2x2 operator) single-qubit tensor product probability. More...
 
virtual real1_f VarianceFloatsFactorized (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Direct measure of variance of listed bit string probability. More...
 
virtual real1_f VarianceFloatsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Direct measure of (reduced density matrix) variance of bits, given an array of qubit weights. More...
 
virtual real1_f VarianceBitsFactorized (const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, const bitCapInt &offset=ZERO_BCI)
 Get expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f VarianceBitsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, const bitCapInt &offset=ZERO_BCI)
 Get (reduced density matrix) expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f ExpectationBitsAll (const std::vector< bitLenInt > &bits, const bitCapInt &offset=ZERO_BCI)
 Get permutation expectation value of bits. More...
 
virtual real1_f ExpectationPauliAll (std::vector< bitLenInt > bits, std::vector< Pauli > paulis)
 Get Pauli tensor product observable. More...
 
virtual real1_f ExpectationUnitaryAll (const std::vector< bitLenInt > &bits, const std::vector< std::shared_ptr< complex >> &basisOps, std::vector< real1_f > eigenVals={})
 Get single-qubit tensor product (arbitrary real) observable. More...
 
virtual real1_f ExpectationUnitaryAll (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &basisOps, std::vector< real1_f > eigenVals={})
 Get single-qubit (3-parameter) tensor product (arbitrary real) observable. More...
 
virtual real1_f ExpectationBitsFactorized (const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, const bitCapInt &offset=ZERO_BCI)
 Get expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f ExpectationBitsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, const bitCapInt &offset=ZERO_BCI)
 Get (reduced density matrix) expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f ExpectationFloatsFactorized (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Get expectation value of bits, given a (floating-point) array of qubit weights. More...
 
virtual real1_f ExpectationFloatsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weights. More...
 
virtual 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...
 
virtual real1_f ProbAllRdm (bool roundRz, const bitCapInt &fullRegister)
 Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f ProbMaskRdm (bool roundRz, const bitCapInt &mask, const bitCapInt &permutation)
 Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f ExpectationBitsAllRdm (bool roundRz, const std::vector< bitLenInt > &bits, const bitCapInt &offset=ZERO_BCI)
 Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual void SetBit (bitLenInt qubit, bool value)
 Set individual bit to pure |0> (false) or |1> (true) state. More...
 
virtual bool ApproxCompare (QInterfacePtr toCompare, real1_f error_tol=TRYDECOMPOSE_EPSILON)
 Compare state vectors approximately, to determine whether this state vector is the same as the target. More...
 
virtual real1_f SumSqrDiff (QInterfacePtr toCompare)=0
 Calculates (1 - <\psi_e|\psi_c>) between states |\psi_c> and |\psi_e>. More...
 
virtual bool TryDecompose (bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
 Attempt to Decompose() a bit range. More...
 
virtual void UpdateRunningNorm (real1_f norm_thresh=REAL1_DEFAULT_ARG)=0
 Force a calculation of the norm of the state vector, in order to make it unit length before the next probability or measurement operation. More...
 
virtual void NormalizeState (real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)=0
 Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate. More...
 
virtual void Finish ()
 If asynchronous work is still running, block until it finishes. More...
 
virtual bool isFinished ()
 Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done. More...
 
virtual void Dump ()
 If asynchronous work is still running, let the simulator know that it can be aborted. More...
 
virtual 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...
 
virtual bool isClifford ()
 Returns "true" if current state is identifiably within the Clifford set, or "false" if it is not or cannot be determined. More...
 
virtual 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...
 
virtual bool isOpenCL ()
 Returns "true" if current simulation is OpenCL-based. More...
 
virtual bool TrySeparate (const std::vector< bitLenInt > &qubits, real1_f error_tol)
 Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed. More...
 
virtual bool TrySeparate (bitLenInt qubit)
 Single-qubit TrySeparate() More...
 
virtual bool TrySeparate (bitLenInt qubit1, bitLenInt qubit2)
 Two-qubit TrySeparate() 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 SetNcrp (real1_f ncrp)
 Set the "Near-clifford 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 void SetTInjection (bool useGadget)
 Set the option to use T-injection gadgets (off by default) More...
 
virtual bool GetTInjection ()
 Get the option to use T-injection gadgets. More...
 
virtual void SetNoiseParameter (real1_f lambda)
 Set the noise level option (only for a noisy interface) More...
 
virtual real1_f GetNoiseParameter ()
 Get the noise level option (only for a noisy interface) More...
 
virtual QInterfacePtr Clone ()=0
 Clone this QInterface. 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

bool IsPhase (const complex *mtrx)
 
bool IsInvert (const complex *mtrx)
 
bool IsIdentity (const complex *mtrx, bool isControlled)
 
void EitherMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, bool isAnti)
 
- Protected Member Functions inherited from Qrack::QInterface
complex GetNonunitaryPhase ()
 
template<typename Fn >
void MACWrapper (const std::vector< bitLenInt > &controls, Fn fn)
 
virtual bitCapInt SampleClone (const std::vector< bitCapInt > &qPowers)
 
virtual real1_f ExpVarUnitaryAll (bool isExp, const std::vector< bitLenInt > &bits, const std::vector< std::shared_ptr< complex >> &basisOps, std::vector< real1_f > eigenVals={})
 
virtual real1_f ExpVarUnitaryAll (bool isExp, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &basisOps, std::vector< real1_f > eigenVals={})
 
virtual real1_f ExpVarBitsAll (bool isExp, const std::vector< bitLenInt > &bits, const bitCapInt &offset=ZERO_BCI)
 

Protected Attributes

bool useHostRam
 
real1 runningNorm
 The value stored in runningNorm should always be the total probability implied by the norm of all amplitudes, summed, at each update. More...
 
bitCapIntOcl maxQPowerOcl
 
- 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_srand_distribution
 
std::shared_ptr< RdRandomhardware_rand_generator
 

Additional Inherited Members

- Static Protected Member Functions inherited from Qrack::QInterface
static real1_f normHelper (const complex &c)
 
static real1_f clampProb (real1_f toClamp)
 

Detailed Description

Abstract QEngine implementation, for all "Schroedinger method" engines.

Constructor & Destructor Documentation

◆ QEngine() [1/2]

Qrack::QEngine::QEngine ( bitLenInt  qBitCount,
qrack_rand_gen_ptr  rgp = nullptr,
bool  doNorm = false,
bool  randomGlobalPhase = true,
bool  useHostMem = false,
bool  useHardwareRNG = true,
real1_f  norm_thresh = REAL1_EPSILON 
)
inline

◆ QEngine() [2/2]

Qrack::QEngine::QEngine ( )
inline

Default constructor, primarily for protected internal use.

◆ ~QEngine()

virtual Qrack::QEngine::~QEngine ( )
inlinevirtual

Member Function Documentation

◆ ACProb()

virtual real1_f Qrack::QEngine::ACProb ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Direct measure of bit probability to be in |1> state, if control bit is |0>.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ AntiCISqrtSwap()

void Qrack::QEngine::AntiCISqrtSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply an inverse square root of swap with arbitrary (anti) control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ AntiCSqrtSwap()

void Qrack::QEngine::AntiCSqrtSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply a square root of swap with arbitrary (anti) control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ AntiCSwap()

void Qrack::QEngine::AntiCSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply a swap with arbitrary (anti) control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ Apply2x2()

virtual void Qrack::QEngine::Apply2x2 ( bitCapIntOcl  offset1,
bitCapIntOcl  offset2,
const complex mtrx,
bitLenInt  bitCount,
bitCapIntOcl const *  qPowersSorted,
bool  doCalcNorm,
real1_f  norm_thresh = REAL1_DEFAULT_ARG 
)
pure virtual

◆ ApplyAntiControlled2x2()

void Qrack::QEngine::ApplyAntiControlled2x2 ( const std::vector< bitLenInt > &  controls,
bitLenInt  target,
const complex mtrx 
)
virtual

Reimplemented in Qrack::QHybrid.

◆ ApplyControlled2x2()

void Qrack::QEngine::ApplyControlled2x2 ( const std::vector< bitLenInt > &  controls,
bitLenInt  target,
const complex mtrx 
)
virtual

Reimplemented in Qrack::QHybrid.

◆ ApplyM() [1/2]

virtual void Qrack::QEngine::ApplyM ( const bitCapInt qPower,
bool  result,
const complex nrm 
)
inlinevirtual

Reimplemented in Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ ApplyM() [2/2]

virtual void Qrack::QEngine::ApplyM ( const bitCapInt regMask,
const bitCapInt result,
const complex nrm 
)
pure virtual

◆ CDEC()

virtual void Qrack::QEngine::CDEC ( const bitCapInt toSub,
bitLenInt  start,
bitLenInt  length,
const std::vector< bitLenInt > &  controls 
)
inlinevirtual

Subtract integer (without sign, with controls)

Reimplemented from Qrack::QAlu.

◆ CIMULModNOut()

virtual void Qrack::QEngine::CIMULModNOut ( const bitCapInt toMul,
const bitCapInt modN,
bitLenInt  inStart,
bitLenInt  outStart,
bitLenInt  length,
const std::vector< bitLenInt > &  controls 
)
inlinevirtual

Inverse of controlled multiplication modulo N by integer, (out of place)

Implements Qrack::QAlu.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ CINC()

virtual void Qrack::QEngine::CINC ( const bitCapInt toAdd,
bitLenInt  start,
bitLenInt  length,
const std::vector< bitLenInt > &  controls 
)
inlinevirtual

Add integer (without sign, with controls)

Implements Qrack::QAlu.

Reimplemented in Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ CISqrtSwap()

void Qrack::QEngine::CISqrtSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply an inverse square root of swap with arbitrary control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ CloneEmpty()

virtual QEnginePtr Qrack::QEngine::CloneEmpty ( )
pure virtual

Clone this QEngine's settings, with a zeroed state vector.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ CMULModNOut()

virtual void Qrack::QEngine::CMULModNOut ( const bitCapInt toMul,
const bitCapInt modN,
bitLenInt  inStart,
bitLenInt  outStart,
bitLenInt  length,
const std::vector< bitLenInt > &  controls 
)
inlinevirtual

Controlled multiplication modulo N by integer, (out of place)

Implements Qrack::QAlu.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ CopyStateVec()

virtual void Qrack::QEngine::CopyStateVec ( QEnginePtr  src)
pure virtual

Exactly copy the state vector of a different QEngine instance.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ CProb()

virtual real1_f Qrack::QEngine::CProb ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Direct measure of bit probability to be in |1> state, if control bit is |1>.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ CSqrtSwap()

void Qrack::QEngine::CSqrtSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply a square root of swap with arbitrary control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ CSwap()

void Qrack::QEngine::CSwap ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Apply a swap with arbitrary control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ CtrlOrAntiProb()

real1_f Qrack::QEngine::CtrlOrAntiProb ( bool  controlState,
bitLenInt  control,
bitLenInt  target 
)
virtual

◆ DEC()

virtual void Qrack::QEngine::DEC ( const bitCapInt toSub,
bitLenInt  start,
bitLenInt  length 
)
inlinevirtual

Add integer (without sign)

Subtract integer (without sign)

Implements Qrack::QAlu.

◆ DECC()

virtual void Qrack::QEngine::DECC ( const bitCapInt toSub,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
inlinevirtual

Subtract classical integer (without sign, with carry)

Subtract integer (without sign, with carry)

Reimplemented from Qrack::QAlu.

Reimplemented in Qrack::QHybrid.

◆ Decompose() [1/3]

virtual QInterfacePtr Qrack::QEngine::Decompose ( bitLenInt  start,
bitLenInt  length 
)
inlinevirtual

Schmidt decompose a length of qubits.

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager.

◆ Decompose() [2/3]

virtual QInterfacePtr Qrack::QInterface::Decompose

Schmidt decompose a length of qubits.

◆ Decompose() [3/3]

virtual void Qrack::QInterface::Decompose

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.

◆ DECS()

virtual void Qrack::QEngine::DECS ( const bitCapInt toSub,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex 
)
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.

◆ EitherMtrx()

void Qrack::QEngine::EitherMtrx ( const std::vector< bitLenInt > &  controls,
const complex mtrx,
bitLenInt  target,
bool  isAnti 
)
protected

◆ ForceM() [1/2]

bool Qrack::QEngine::ForceM ( bitLenInt  qubitIndex,
bool  result,
bool  doForce = true,
bool  doApply = true 
)
virtual

PSEUDO-QUANTUM - Acts like a measurement gate, except with a specified forced result.

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ ForceM() [2/2]

bitCapInt Qrack::QEngine::ForceM ( const std::vector< bitLenInt > &  bits,
const std::vector< bool > &  values,
bool  doApply = true 
)
virtual

Measure permutation state of a register.

Reimplemented from Qrack::QInterface.

◆ ForceMReg()

bitCapInt Qrack::QEngine::ForceMReg ( bitLenInt  start,
bitLenInt  length,
const bitCapInt result,
bool  doForce = true,
bool  doApply = true 
)
virtual

Measure permutation state of a register.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager.

◆ FSim() [1/2]

virtual void Qrack::QInterface::FSim

The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics)

◆ FSim() [2/2]

void Qrack::QEngine::FSim ( real1_f  theta,
real1_f  phi,
bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics)

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ GetAmplitudePage()

virtual void Qrack::QEngine::GetAmplitudePage ( complex pagePtr,
bitCapIntOcl  offset,
bitCapIntOcl  length 
)
pure virtual

Copy a "page" of amplitudes from this QEngine's internal state, into pagePtr.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ GetDevice()

virtual int64_t Qrack::QEngine::GetDevice ( )
inlinevirtual

Get GPU device ID.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ GetExpectation()

virtual real1_f Qrack::QEngine::GetExpectation ( bitLenInt  valueStart,
bitLenInt  valueLength 
)
pure virtual

◆ GetRunningNorm()

virtual real1_f Qrack::QEngine::GetRunningNorm ( )
inlinevirtual

Get in-flight renormalization factor.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ IISwap() [1/2]

void Qrack::QInterface::IISwap

Inverse ISwap - Swap values of two bits in register, and apply phase factor of -i if bits are different.

◆ IISwap() [2/2]

void Qrack::QEngine::IISwap ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Inverse ISwap - Swap values of two bits in register, and apply phase factor of -i if bits are different.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid, and Qrack::QPager.

◆ IMULModNOut()

virtual void Qrack::QEngine::IMULModNOut ( const bitCapInt toMul,
const bitCapInt modN,
bitLenInt  inStart,
bitLenInt  outStart,
bitLenInt  length 
)
inlinevirtual

Inverse of multiplication modulo N by integer, (out of place)

Implements Qrack::QAlu.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ INC()

virtual void Qrack::QEngine::INC ( const bitCapInt toAdd,
bitLenInt  start,
bitLenInt  length 
)
inlinevirtual

Add integer (without sign)

Implements Qrack::QAlu.

Reimplemented in Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ INCC()

virtual void Qrack::QEngine::INCC ( const bitCapInt toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
inlinevirtual

Add integer (without sign, with carry)

Reimplemented from Qrack::QAlu.

Reimplemented in Qrack::QHybrid.

◆ INCDECC()

virtual void Qrack::QEngine::INCDECC ( const bitCapInt toMod,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
inlinevirtual

Common driver method behind INCC and DECC (without sign, with carry)

Implements Qrack::QAlu.

Reimplemented in Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ INCS()

virtual void Qrack::QEngine::INCS ( const bitCapInt toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex 
)
inlinevirtual

Add a classical integer to the register, with sign and without carry.

Implements Qrack::QAlu.

Reimplemented in Qrack::QHybrid, Qrack::QEngineCPU, Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ IsIdentity()

bool Qrack::QEngine::IsIdentity ( const complex mtrx,
bool  isControlled 
)
inlineprotected

◆ IsInvert()

bool Qrack::QEngine::IsInvert ( const complex mtrx)
inlineprotected

◆ IsPhase()

bool Qrack::QEngine::IsPhase ( const complex mtrx)
inlineprotected

◆ ISqrtSwap() [1/2]

void Qrack::QInterface::ISqrtSwap

Inverse square root of Swap gate.

◆ ISqrtSwap() [2/2]

void Qrack::QEngine::ISqrtSwap ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Inverse square root of Swap gate.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ ISwap() [1/2]

void Qrack::QInterface::ISwap

Swap values of two bits in register, and apply phase factor of i if bits are different.

◆ ISwap() [2/2]

void Qrack::QEngine::ISwap ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Swap values of two bits in register, and apply phase factor of i if bits are different.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid, and Qrack::QPager.

◆ IsZeroAmplitude()

virtual bool Qrack::QEngine::IsZeroAmplitude ( )
pure virtual

Returns "true" only if amplitudes are all totally 0.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ M() [1/3]

virtual bool Qrack::QEngine::M ( bitLenInt  q)
inlinevirtual

Implements Qrack::QAlu.

◆ M() [2/3]

virtual bool Qrack::QInterface::M
inline

Measurement gate.

Measures the qubit at "qubit" 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.)

◆ M() [3/3]

virtual bitCapInt Qrack::QInterface::M
inline

Measure bits with indices in array, and return a mask of the results.

◆ MACMtrx()

virtual void Qrack::QEngine::MACMtrx ( const std::vector< bitLenInt > &  controls,
const complex mtrx,
bitLenInt  target 
)
inlinevirtual

Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ MCMtrx()

virtual void Qrack::QEngine::MCMtrx ( const std::vector< bitLenInt > &  controls,
const complex mtrx,
bitLenInt  target 
)
inlinevirtual

Apply an arbitrary single bit unitary transformation, with arbitrary control bits.

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ Mtrx()

void Qrack::QEngine::Mtrx ( const complex mtrx,
bitLenInt  qubit 
)
virtual

Apply an arbitrary single bit unitary transformation.

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ MULModNOut()

virtual void Qrack::QEngine::MULModNOut ( const bitCapInt toMul,
const bitCapInt modN,
bitLenInt  inStart,
bitLenInt  outStart,
bitLenInt  length 
)
inlinevirtual

Multiplication modulo N by integer, (out of place)

Implements Qrack::QAlu.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ MultiShotMeasureMask() [1/2]

std::map< bitCapInt, int > Qrack::QEngine::MultiShotMeasureMask ( const std::vector< bitCapInt > &  qPowers,
unsigned  shots 
)
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.)

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ MultiShotMeasureMask() [2/2]

void Qrack::QEngine::MultiShotMeasureMask ( const std::vector< bitCapInt > &  qPowers,
unsigned  shots,
unsigned long long *  shotsArray 
)
virtual

Statistical measure of masked permutation probability (returned as array)

Same Qrack::MultiShotMeasureMask(), except the shots are returned as an array.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ProbAll()

virtual real1_f Qrack::QEngine::ProbAll ( const bitCapInt fullRegister)
inlinevirtual

Direct measure of full permutation probability.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ ProbMask()

virtual real1_f Qrack::QEngine::ProbMask ( const bitCapInt mask,
const bitCapInt permutation 
)
pure virtual

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.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ ProbReg()

virtual real1_f Qrack::QEngine::ProbReg ( bitLenInt  start,
bitLenInt  length,
const bitCapInt permutation 
)
pure virtual

Direct measure of register permutation probability.

Returns probability of permutation of the register.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ ProbRegAll()

void Qrack::QEngine::ProbRegAll ( bitLenInt  start,
bitLenInt  length,
real1 probsArray 
)
virtual

Reimplemented in Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ QueueSetDoNormalize()

virtual void Qrack::QEngine::QueueSetDoNormalize ( bool  doNorm)
pure virtual

Add an operation to the (OpenCL) queue, to set the value of doNormalize, which controls whether to automatically normalize the state.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ QueueSetRunningNorm()

virtual void Qrack::QEngine::QueueSetRunningNorm ( real1_f  runningNrm)
pure virtual

Add an operation to the (OpenCL) queue, to set the value of runningNorm, which is the normalization constant for the next normalization operation.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ ResetHostPtr()

virtual void Qrack::QEngine::ResetHostPtr ( )
inlinevirtual

Reset host/device state vector bufffer usage to default.

◆ SetAmplitudePage() [1/2]

virtual void Qrack::QEngine::SetAmplitudePage ( const complex pagePtr,
bitCapIntOcl  offset,
bitCapIntOcl  length 
)
pure virtual

Copy a "page" of amplitudes from pagePtr into this QEngine's internal state.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ SetAmplitudePage() [2/2]

virtual void Qrack::QEngine::SetAmplitudePage ( QEnginePtr  pageEnginePtr,
bitCapIntOcl  srcOffset,
bitCapIntOcl  dstOffset,
bitCapIntOcl  length 
)
pure virtual

Copy a "page" of amplitudes from another QEngine, pointed to by pageEnginePtr, into this QEngine's internal state.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ SetDevice()

virtual void Qrack::QEngine::SetDevice ( int64_t  dID)
inlinevirtual

Set GPU device ID.

Implements Qrack::QInterface.

Reimplemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ SetQubitCount()

virtual void Qrack::QEngine::SetQubitCount ( bitLenInt  qb)
inlinevirtual

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ ShuffleBuffers()

virtual void Qrack::QEngine::ShuffleBuffers ( QEnginePtr  engine)
pure virtual

Swap the high half of this engine with the low half of another.

This is necessary for gates which cross sub-engine boundaries.

Implemented in Qrack::QHybrid, Qrack::QPager, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ SqrtSwap() [1/2]

void Qrack::QInterface::SqrtSwap

Square root of Swap gate.

◆ SqrtSwap() [2/2]

void Qrack::QEngine::SqrtSwap ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Square root of Swap gate.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QHybrid.

◆ Swap() [1/2]

void Qrack::QInterface::Swap

Swap values of two bits in register.

◆ Swap() [2/2]

void Qrack::QEngine::Swap ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Swap values of two bits in register.

Reimplemented from Qrack::QInterface.

Reimplemented in Qrack::QPager, and Qrack::QHybrid.

◆ SwitchHostPtr()

virtual void Qrack::QEngine::SwitchHostPtr ( bool  useHostMem)
inlinevirtual

Switch to/from host/device state vector bufffer.

Reimplemented in Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ UCMtrx()

void Qrack::QEngine::UCMtrx ( const std::vector< bitLenInt > &  controls,
const complex mtrx,
bitLenInt  target,
const bitCapInt controlPerm 
)
virtual

Apply an arbitrary single bit unitary transformation, with arbitrary control bits, with arbitary control permutation.

Reimplemented from Qrack::QInterface.

◆ X() [1/3]

virtual void Qrack::QEngine::X ( bitLenInt  q)
inlinevirtual

Implements Qrack::QAlu.

Reimplemented in Qrack::QEngineOCL, and Qrack::QEngineCUDA.

◆ X() [2/3]

virtual void Qrack::QInterface::X
inline

X gate.

Applies the Pauli "X" operator to the qubit at "qubit." The Pauli "X" operator is equivalent to a logical "NOT."

◆ X() [3/3]

virtual void Qrack::QInterface::X
inline

Bitwise Pauli X (or logical "NOT") operator.

◆ ZeroAmplitudes()

virtual void Qrack::QEngine::ZeroAmplitudes ( )
pure virtual

Set all amplitudes to 0, and optionally temporarily deallocate state vector RAM.

Implemented in Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QEngineCPU.

◆ ZMask()

virtual void Qrack::QEngine::ZMask ( const bitCapInt mask)
inlinevirtual

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.

Reimplemented in Qrack::QPager.

Member Data Documentation

◆ maxQPowerOcl

bitCapIntOcl Qrack::QEngine::maxQPowerOcl
protected

◆ runningNorm

real1 Qrack::QEngine::runningNorm
protected

The value stored in runningNorm should always be the total probability implied by the norm of all amplitudes, summed, at each update.

To normalize, we should always multiply by 1/sqrt(runningNorm).

◆ useHostRam

bool Qrack::QEngine::useHostRam
protected

The documentation for this class was generated from the following files: