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

A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods to operate on it as by gates and register-like instructions. More...

#include <qinterface.hpp>

Inheritance diagram for Qrack::QInterface:
Inheritance graph
[legend]

Public Member Functions

 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 ()
 
virtual ~QInterface ()
 
virtual void SetRandomSeed (uint32_t seed)
 
virtual void SetConcurrency (uint32_t threadsPerEngine)
 Set the number of threads in parallel for loops, per component QEngine. More...
 
bitLenInt GetQubitCount ()
 Get the count of bits in this register. More...
 
bitCapInt GetMaxQPower ()
 Get the maximum number of basis states, namely \( n^2 \) for \( n \) qubits. More...
 
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 (bitCapInt perm)=0
 Get the representational amplitude of a full permutation. More...
 
virtual void SetAmplitude (bitCapInt perm, complex amp)=0
 Sets the representational amplitude of a full permutation. More...
 
virtual void SetPermutation (bitCapInt perm, complex phaseFac=CMPLX_DEFAULT_ARG)=0
 Set to a specific permutation. More...
 
virtual bitLenInt Compose (QInterfacePtr toCopy)
 Combine another QInterface with this one, after the last bit index of this one. More...
 
virtual std::map< QInterfacePtr, bitLenIntCompose (std::vector< QInterfacePtr > toCopy)
 
virtual bitLenInt Compose (QInterfacePtr toCopy, bitLenInt start)=0
 
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, bitCapInt disposedPerm)=0
 Dispose a a contiguous set of qubits that are already in a permutation eigenstate. More...
 
virtual void ApplySingleBit (const complex *mtrx, bitLenInt qubitIndex)=0
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void ApplyControlledSingleBit (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex *mtrx)=0
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More...
 
virtual void ApplyAntiControlledSingleBit (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex *mtrx)=0
 Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More...
 
virtual void ApplySinglePhase (const complex topLeft, const complex bottomRight, bitLenInt qubitIndex)
 Apply a single bit transformation that only effects phase. More...
 
virtual void ApplySingleInvert (const complex topRight, const complex bottomLeft, bitLenInt qubitIndex)
 Apply a single bit transformation that reverses bit probability and might effect phase. More...
 
virtual void ApplyControlledSinglePhase (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex topLeft, const complex bottomRight)
 Apply a single bit transformation that only effects phase, with arbitrary control bits. More...
 
virtual void ApplyControlledSingleInvert (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex topRight, const complex bottomLeft)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits. More...
 
virtual void ApplyAntiControlledSinglePhase (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex topLeft, const complex bottomRight)
 Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits. More...
 
virtual void ApplyAntiControlledSingleInvert (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &target, const complex topRight, const complex bottomLeft)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits. More...
 
virtual void UniformlyControlledSingleBit (const bitLenInt *controls, const bitLenInt &controlLen, bitLenInt qubitIndex, const complex *mtrxs)
 Apply a "uniformly controlled" arbitrary single bit unitary transformation. More...
 
virtual void UniformlyControlledSingleBit (const bitLenInt *controls, const bitLenInt &controlLen, bitLenInt qubitIndex, const complex *mtrxs, const bitCapInt *mtrxSkipPowers, const bitLenInt mtrxSkipLen, 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 CSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply a swap with arbitrary control bits. More...
 
virtual void AntiCSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply a swap with arbitrary (anti) control bits. More...
 
virtual void CSqrtSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply a square root of swap with arbitrary control bits. More...
 
virtual void AntiCSqrtSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply a square root of swap with arbitrary (anti) control bits. More...
 
virtual void CISqrtSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply an inverse square root of swap with arbitrary control bits. More...
 
virtual void AntiCISqrtSwap (const bitLenInt *controls, const bitLenInt &controlLen, const bitLenInt &qubit1, const bitLenInt &qubit2)=0
 Apply an inverse square root of 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 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 CU (bitLenInt *controls, bitLenInt controlLen, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 Controlled general unitary gate. More...
 
virtual void H (bitLenInt qubitIndex)
 Hadamard gate. More...
 
virtual void SqrtH (bitLenInt qubitIndex)
 Square root of Hadamard gate. More...
 
virtual void SH (bitLenInt qubitIndex)
 Y-basis transformation gate. More...
 
virtual void HIS (bitLenInt qubitIndex)
 Y-basis (inverse) transformation gate. More...
 
virtual bool M (bitLenInt qubitIndex)
 Measurement gate. More...
 
virtual bool ForceM (bitLenInt qubit, bool result, bool doForce=true, bool doApply=true)=0
 Act as if is a measurement was applied, except force the (usually random) result. 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 bool MParity (const bitCapInt &mask)
 Measure (and collapse) parity of the masked set of qubits. More...
 
virtual void S (bitLenInt qubitIndex)
 S gate. More...
 
virtual void IS (bitLenInt qubitIndex)
 Inverse S gate. More...
 
virtual void T (bitLenInt qubitIndex)
 T gate. More...
 
virtual void IT (bitLenInt qubitIndex)
 Inverse T gate. More...
 
virtual void PhaseRootN (bitLenInt n, bitLenInt qubitIndex)
 "PhaseRootN" gate More...
 
virtual void IPhaseRootN (bitLenInt n, bitLenInt qubitIndex)
 Inverse "PhaseRootN" gate. More...
 
virtual void X (bitLenInt qubitIndex)
 X gate. More...
 
virtual void Y (bitLenInt qubitIndex)
 Y gate. More...
 
virtual void Z (bitLenInt qubitIndex)
 Z gate. More...
 
virtual void SqrtX (bitLenInt qubitIndex)
 Square root of X gate. More...
 
virtual void ISqrtX (bitLenInt qubitIndex)
 Inverse square root of X gate. More...
 
virtual void SqrtXConjT (bitLenInt qubitIndex)
 Phased square root of X gate. More...
 
virtual void ISqrtXConjT (bitLenInt qubitIndex)
 Inverse phased square root of X gate. More...
 
virtual void SqrtY (bitLenInt qubitIndex)
 Square root of Y gate. More...
 
virtual void ISqrtY (bitLenInt qubitIndex)
 Square root of Y gate. More...
 
virtual void CY (bitLenInt control, bitLenInt target)
 Controlled Y gate. More...
 
virtual void CZ (bitLenInt control, bitLenInt target)
 Controlled Z gate. More...
 
virtual void CCZ (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-Controlled Z gate. More...
 
virtual void CH (bitLenInt control, bitLenInt target)
 Controlled H gate. More...
 
virtual void CS (bitLenInt control, bitLenInt target)
 Controlled S gate. More...
 
virtual void CIS (bitLenInt control, bitLenInt target)
 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 CIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target)
 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 RT (real1_f radians, bitLenInt qubitIndex)
 Phase shift gate. More...
 
virtual void RTDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction phase shift gate. More...
 
virtual void RX (real1_f radians, bitLenInt qubitIndex)
 X axis rotation 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 (bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit, 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 RY (real1_f radians, bitLenInt qubitIndex)
 Y axis rotation gate. More...
 
virtual void RYDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Y axis rotation gate. More...
 
virtual void CRY (real1_f radians, bitLenInt control, bitLenInt target)
 Controlled 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 UniformlyControlledRY (const bitLenInt *controls, const bitLenInt &controlLen, bitLenInt qubitIndex, const real1 *angles)
 Apply a "uniformly controlled" rotation of a bit around the Pauli Y axis. More...
 
virtual void UniformlyControlledRZ (const bitLenInt *controls, const bitLenInt &controlLen, bitLenInt qubitIndex, const real1 *angles)
 Apply a "uniformly controlled" rotation of a bit around the Pauli Z axis. More...
 
virtual void UniformParityRZ (const bitCapInt &mask, const real1_f &angle)
 If the target qubit set parity is odd, this applies a phase factor of e^{i angle}. More...
 
virtual void CUniformParityRZ (const bitLenInt *controls, const bitLenInt &controlLen, const bitCapInt &mask, const 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...
 
virtual void RZ (real1_f radians, bitLenInt qubitIndex)
 Z axis rotation gate. More...
 
virtual void RZDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Z axis rotation gate. More...
 
virtual void CRZ (real1_f radians, bitLenInt control, bitLenInt target)
 Controlled 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 U (bitLenInt start, bitLenInt length, real1_f theta, real1_f phi, real1_f lambda)
 Bitwise general unitary. More...
 
virtual void U2 (bitLenInt start, bitLenInt length, real1_f phi, real1_f lambda)
 Bitwise 2-parameter unitary. More...
 
virtual void H (bitLenInt start, bitLenInt length)
 Bitwise Hadamard. More...
 
virtual void SH (bitLenInt start, bitLenInt length)
 Bitwise Y-basis transformation gate. More...
 
virtual void HIS (bitLenInt start, bitLenInt length)
 Bitwise inverse Y-basis transformation gate. More...
 
virtual void SqrtH (bitLenInt start, bitLenInt length)
 Bitwise square root of Hadamard. More...
 
virtual void S (bitLenInt start, bitLenInt length)
 Bitwise S operator (1/4 phase rotation) More...
 
virtual void IS (bitLenInt start, bitLenInt length)
 Bitwise inverse S operator (1/4 phase rotation) More...
 
virtual void T (bitLenInt start, bitLenInt length)
 Bitwise T operator (1/8 phase rotation) More...
 
virtual void IT (bitLenInt start, bitLenInt length)
 Bitwise inverse T operator (1/8 phase rotation) More...
 
virtual void PhaseRootN (bitLenInt n, bitLenInt start, bitLenInt length)
 Bitwise "PhaseRootN" operator (1/(2^N) phase rotation) More...
 
virtual void IPhaseRootN (bitLenInt n, bitLenInt start, bitLenInt length)
 Bitwise inverse "PhaseRootN" operator (1/(2^N) phase rotation) More...
 
virtual void X (bitLenInt start, bitLenInt length)
 Bitwise Pauli X (or logical "NOT") operator. More...
 
virtual void Y (bitLenInt start, bitLenInt length)
 Bitwise Pauli Y operator. More...
 
virtual void SqrtX (bitLenInt start, bitLenInt length)
 Bitwise square root of Pauli X operator. More...
 
virtual void ISqrtX (bitLenInt start, bitLenInt length)
 Bitwise inverse square root of Pauli X operator. More...
 
virtual void SqrtXConjT (bitLenInt start, bitLenInt length)
 Bitwise phased square root of Pauli X operator. More...
 
virtual void ISqrtXConjT (bitLenInt start, bitLenInt length)
 Bitwise inverse phased square root of Pauli X operator. More...
 
virtual void SqrtY (bitLenInt start, bitLenInt length)
 Bitwise square root of Pauli Y operator. More...
 
virtual void ISqrtY (bitLenInt start, bitLenInt length)
 Bitwise inverse square root of Pauli Y operator. More...
 
virtual void Z (bitLenInt start, bitLenInt length)
 Bitwise Pauli Z operator. More...
 
virtual void CNOT (bitLenInt inputBits, bitLenInt targetBits, bitLenInt length)
 Bitwise controlled-not. More...
 
virtual void AntiCNOT (bitLenInt inputBits, bitLenInt targetBits, bitLenInt length)
 Bitwise "anti-"controlled-not. More...
 
virtual void CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length)
 Bitwise doubly controlled-not. More...
 
virtual void AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length)
 Bitwise doubly "anti-"controlled-not. More...
 
virtual void AND (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "AND". More...
 
virtual void CLAND (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "AND". More...
 
virtual void OR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "OR". More...
 
virtual void CLOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "OR". More...
 
virtual void XOR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "XOR". More...
 
virtual void CLXOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "XOR". More...
 
virtual void NAND (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "NAND". More...
 
virtual void CLNAND (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "NAND". More...
 
virtual void NOR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "NOR". More...
 
virtual void CLNOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "NOR". More...
 
virtual void XNOR (bitLenInt inputStart1, bitLenInt inputStart2, bitLenInt outputStart, bitLenInt length)
 Bitwise "XNOR". More...
 
virtual void CLXNOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "XNOR". More...
 
virtual void RT (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise phase shift gate. More...
 
virtual void RTDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction phase shift gate. More...
 
virtual void RX (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise X axis rotation gate. More...
 
virtual void RXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction X axis rotation gate. More...
 
virtual void CRX (real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled X axis rotation gate. More...
 
virtual void CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction X axis rotation gate. More...
 
virtual void RY (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise Y axis rotation gate. More...
 
virtual void RYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction Y axis rotation gate. More...
 
virtual void CRY (real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Y axis rotation gate. More...
 
virtual void CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction y axis rotation gate. More...
 
virtual void RZ (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise Z axis rotation gate. More...
 
virtual void RZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction Z axis rotation gate. More...
 
virtual void CRZ (real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Z axis rotation gate. More...
 
virtual void CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction Z axis rotation gate. More...
 
virtual void CRT (real1_f radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled "phase shift gate". More...
 
virtual void CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction "phase shift gate". More...
 
virtual void Exp (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise (identity) exponentiation gate. More...
 
virtual void ExpDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction (identity) exponentiation gate. More...
 
virtual void ExpX (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli X exponentiation gate. More...
 
virtual void ExpXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli X exponentiation gate. More...
 
virtual void ExpY (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli Y exponentiation gate. More...
 
virtual void ExpYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli Y exponentiation gate. More...
 
virtual void ExpZ (real1_f radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli Z exponentiation gate. More...
 
virtual void ExpZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli Z exponentiation gate. More...
 
virtual void CY (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Y gate. More...
 
virtual void CZ (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Z gate. More...
 
virtual void CCZ (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length)
 Bitwise doubly-controlled Z gate. More...
 
virtual void CH (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled H gate. More...
 
virtual void CS (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled S gate. More...
 
virtual void CIS (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled inverse S gate. More...
 
virtual void CT (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled T gate. More...
 
virtual void CIT (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled inverse T gate. More...
 
virtual void CPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled "PhaseRootN" gate. More...
 
virtual void CIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled inverse "PhaseRootN" gate. 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 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 INC (bitCapInt toAdd, bitLenInt start, bitLenInt length)=0
 Add integer (without sign) More...
 
virtual void CINC (bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Add integer (without sign, with controls) More...
 
virtual void INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Add integer (without sign, with carry) More...
 
virtual void INCS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)=0
 Add a classical integer to the register, with sign and without carry. More...
 
virtual void INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)=0
 Add a classical integer to the register, with sign and with carry. More...
 
virtual void INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Add a classical integer to the register, with sign and with (phase-based) carry. More...
 
virtual void DEC (bitCapInt toSub, bitLenInt start, bitLenInt length)
 Subtract classical integer (without sign) More...
 
virtual void CDEC (bitCapInt toSub, bitLenInt inOutStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)
 Subtract classical integer (without sign, with controls) More...
 
virtual void DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Subtract classical integer (without sign, with carry) More...
 
virtual void DECS (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Subtract a classical integer from the register, with sign and without carry. More...
 
virtual void DECSC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)=0
 Subtract a classical integer from the register, with sign and with carry. More...
 
virtual void DECSC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)=0
 Subtract a classical integer from the register, with sign and with carry. More...
 
virtual void MUL (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)=0
 Multiply by integer. More...
 
virtual void DIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)=0
 Divide by integer. More...
 
virtual void MULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)=0
 Multiplication modulo N by integer, (out of place) More...
 
virtual void IMULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length)=0
 Inverse: multiplication modulo N by integer, (out of place) More...
 
virtual void POWModNOut (bitCapInt base, 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 (bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Controlled multiplication by integer. More...
 
virtual void CDIV (bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Controlled division by power of integer. More...
 
virtual void CMULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Controlled multiplication modulo N by integer, (out of place) More...
 
virtual void CIMULModNOut (bitCapInt toMul, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Inverse: controlled multiplication modulo N by integer, (out of place) More...
 
virtual void CPOWModNOut (bitCapInt base, bitCapInt modN, bitLenInt inStart, bitLenInt outStart, bitLenInt length, bitLenInt *controls, bitLenInt controlLen)=0
 Controlled, raise a classical base to a quantum power, modulo N, (out of place) 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 (bitLenInt *controls, bitLenInt controlLen, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
 Controlled quantum analog of classical "Full Adder" gate. More...
 
virtual void CIFullAdd (bitLenInt *controls, bitLenInt controlLen, 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 (bitLenInt *controls, bitLenInt controlLen, 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 (bitLenInt *controls, bitLenInt controlLen, 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 IQFT (bitLenInt start, bitLenInt length, bool trySeparate=false)
 Inverse Quantum Fourier Transform - 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 CPhaseFlipIfLess (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 PhaseFlipIfLess (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 PhaseFlip ()
 Phase flip always - equivalent to Z X Z X on any bit in the QInterface. 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 MAll ()
 Measure permutation state of all coherent bits. 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 bitLenInt *bits, const bitLenInt &length)
 Measure bits with indices in array, and return a mask of the results. More...
 
virtual bitCapInt ForceM (const bitLenInt *bits, const bitLenInt &length, const bool *values, bool doApply=true)
 Measure bits with indices in array, and return a mask of the results. More...
 
virtual bitCapInt IndexedLDA (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, 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, 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, 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, unsigned char *values)=0
 Transform a length of qubit register via lookup through a hash table. More...
 
virtual void Swap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
 Swap values of two bits in register. More...
 
virtual void Swap (bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise swap. More...
 
virtual void ISwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
 Swap values of two bits in register, and apply phase factor of i if bits are different. More...
 
virtual void ISwap (bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise swap. More...
 
virtual void SqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
 Square root of Swap gate. More...
 
virtual void SqrtSwap (bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise square root of swap. More...
 
virtual void ISqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
 Inverse square root of Swap gate. More...
 
virtual void ISqrtSwap (bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise inverse square root of swap. More...
 
virtual void FSim (real1_f theta, real1_f phi, bitLenInt qubitIndex1, bitLenInt qubitIndex2)=0
 The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics) More...
 
virtual void FSim (real1_f theta, real1_f phi, bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise "fSim". More...
 
virtual void Reverse (bitLenInt first, bitLenInt last)
 Reverse all of the bits in a sequence. More...
 
virtual real1_f Prob (bitLenInt qubitIndex)=0
 Direct measure of bit probability to be in |1> state. More...
 
virtual real1_f ProbAll (bitCapInt fullRegister)=0
 Direct measure of full permutation probability. More...
 
virtual real1_f ProbReg (const bitLenInt &start, const bitLenInt &length, const bitCapInt &permutation)
 Direct measure of register permutation probability. More...
 
virtual real1_f ProbMask (const bitCapInt &mask, const bitCapInt &permutation)
 Direct measure of masked permutation probability. More...
 
virtual void ProbMaskAll (const bitCapInt &mask, real1 *probsArray)
 Direct measure of masked permutation probability. More...
 
virtual real1_f ProbParity (const bitCapInt &mask)=0
 Overall probability of any odd permutation of the masked set of bits. More...
 
virtual std::map< bitCapInt, int > MultiShotMeasureMask (const bitCapInt *qPowers, const bitLenInt qPowerCount, const unsigned int shots)
 Statistical measure of masked permutation probability. More...
 
virtual void SetBit (bitLenInt qubitIndex1, bool value)
 Set individual bit to pure |0> (false) or |1> (true) state. More...
 
virtual bool ApproxCompare (QInterfacePtr toCompare, real1_f error_tol=REAL1_EPSILON)
 Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target. More...
 
virtual real1_f SumSqrDiff (QInterfacePtr toCompare)=0
 
virtual bool TryDecompose (bitLenInt start, QInterfacePtr dest, real1_f error_tol=REAL1_EPSILON)
 
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)=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 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 TrySeparate (bitLenInt start, bitLenInt length=1, real1_f error_tol=REAL1_EPSILON)
 Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed. More...
 
virtual QInterfacePtr Clone ()=0
 Clone this QInterface. More...
 
virtual void SetDevice (const int &dID, const bool &forceReInit=false)
 Set the device index, if more than one device is available. More...
 
virtual int GetDeviceID ()
 Get the device index. More...
 
bitCapIntOcl GetMaxSize ()
 Get maximum number of amplitudes that can be allocated on current device. More...
 

Protected Member Functions

virtual void SetQubitCount (bitLenInt qb)
 
template<typename GateFunc >
void ControlledLoopFixture (bitLenInt length, GateFunc gate)
 
void FreeAligned (void *toFree)
 
bool IsIdentity (const complex *mtrx, const bool isControlled)
 
complex GetNonunitaryPhase ()
 

Static Protected Member Functions

static real1_f normHelper (complex c)
 
static real1_f clampProb (real1_f toClamp)
 

Protected Attributes

bitLenInt qubitCount
 
bitCapInt maxQPower
 
uint32_t randomSeed
 
qrack_rand_gen_ptr rand_generator
 
std::uniform_real_distribution< real1_frand_distribution
 
std::shared_ptr< RdRandomhardware_rand_generator
 
bool doNormalize
 
bool randGlobalPhase
 
real1 amplitudeFloor
 

Detailed Description

A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods to operate on it as by gates and register-like instructions.

See README.md for an overview of the algorithms Qrack employs.

Constructor & Destructor Documentation

◆ QInterface() [1/2]

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 
)
inline

◆ QInterface() [2/2]

Qrack::QInterface::QInterface ( )
inline

◆ ~QInterface()

virtual Qrack::QInterface::~QInterface ( )
inlinevirtual

Member Function Documentation

◆ clampProb()

static real1_f Qrack::QInterface::clampProb ( real1_f  toClamp)
inlinestaticprotected

◆ Compose() [1/3]

virtual bitLenInt Qrack::QInterface::Compose ( QInterfacePtr  toCopy)
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 in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QPager, Qrack::QHybrid, and Qrack::QUnit.

◆ Compose() [2/3]

std::map< QInterfacePtr, bitLenInt > Qrack::QInterface::Compose ( std::vector< QInterfacePtr toCopy)
virtual

Reimplemented in Qrack::QEngineCPU.

◆ Compose() [3/3]

virtual bitLenInt Qrack::QInterface::Compose ( QInterfacePtr  toCopy,
bitLenInt  start 
)
pure virtual

◆ ControlledLoopFixture()

template<typename GateFunc >
void Qrack::QInterface::ControlledLoopFixture ( bitLenInt  length,
GateFunc  gate 
)
protected

◆ Decompose()

virtual void Qrack::QInterface::Decompose ( bitLenInt  start,
QInterfacePtr  dest 
)
pure virtual

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.

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QPager, Qrack::QHybrid, and Qrack::QUnit.

◆ Dispose() [1/2]

virtual void Qrack::QInterface::Dispose ( bitLenInt  start,
bitLenInt  length 
)
pure virtual

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.

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QPager, Qrack::QHybrid, and Qrack::QUnit.

◆ Dispose() [2/2]

virtual void Qrack::QInterface::Dispose ( bitLenInt  start,
bitLenInt  length,
bitCapInt  disposedPerm 
)
pure virtual

Dispose a a contiguous set of qubits that are already in a permutation eigenstate.

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, and Qrack::QUnit.

◆ FreeAligned()

void Qrack::QInterface::FreeAligned ( void *  toFree)
inlineprotected

◆ GetAmplitude()

virtual complex Qrack::QInterface::GetAmplitude ( bitCapInt  perm)
pure virtual

Get the representational amplitude of a full permutation.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, and Qrack::QUnit.

◆ GetMaxQPower()

bitCapInt Qrack::QInterface::GetMaxQPower ( )
inline

Get the maximum number of basis states, namely \( n^2 \) for \( n \) qubits.

◆ GetNonunitaryPhase()

complex Qrack::QInterface::GetNonunitaryPhase ( )
inlineprotected

◆ GetProbs()

virtual void Qrack::QInterface::GetProbs ( real1 outputProbs)
pure virtual

Get the pure quantum state representation.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, Qrack::QUnitMulti, and Qrack::QUnit.

◆ GetQuantumState()

virtual void Qrack::QInterface::GetQuantumState ( complex outputState)
pure virtual

Get the pure quantum state representation.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, Qrack::QUnitMulti, and Qrack::QUnit.

◆ GetQubitCount()

bitLenInt Qrack::QInterface::GetQubitCount ( )
inline

Get the count of bits in this register.

◆ IsIdentity()

bool Qrack::QInterface::IsIdentity ( const complex mtrx,
const bool  isControlled 
)
protected

◆ normHelper()

static real1_f Qrack::QInterface::normHelper ( complex  c)
inlinestaticprotected

◆ Rand()

real1_f Qrack::QInterface::Rand ( )
inline

Generate a random real number between 0 and 1.

◆ SetAmplitude()

virtual void Qrack::QInterface::SetAmplitude ( bitCapInt  perm,
complex  amp 
)
pure virtual

Sets the representational amplitude of a full permutation.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, and Qrack::QUnit.

◆ SetConcurrency()

virtual void Qrack::QInterface::SetConcurrency ( uint32_t  threadsPerEngine)
inlinevirtual

Set the number of threads in parallel for loops, per component QEngine.

Reimplemented in Qrack::QPager, Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QEngineCPU, and Qrack::QHybrid.

◆ SetPermutation()

virtual void Qrack::QInterface::SetPermutation ( bitCapInt  perm,
complex  phaseFac = CMPLX_DEFAULT_ARG 
)
pure virtual

◆ SetQuantumState()

virtual void Qrack::QInterface::SetQuantumState ( const complex inputState)
pure virtual

Set an arbitrary pure quantum state representation.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QEngineOCL, Qrack::QStabilizerHybrid, Qrack::QEngineCPU, Qrack::QHybrid, Qrack::QPager, and Qrack::QUnit.

◆ SetQubitCount()

virtual void Qrack::QInterface::SetQubitCount ( bitLenInt  qb)
inlineprotectedvirtual

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

◆ SetRandomSeed()

virtual void Qrack::QInterface::SetRandomSeed ( uint32_t  seed)
inlinevirtual

Member Data Documentation

◆ amplitudeFloor

real1 Qrack::QInterface::amplitudeFloor
protected

◆ doNormalize

bool Qrack::QInterface::doNormalize
protected

◆ hardware_rand_generator

std::shared_ptr<RdRandom> Qrack::QInterface::hardware_rand_generator
protected

◆ maxQPower

bitCapInt Qrack::QInterface::maxQPower
protected

◆ qubitCount

bitLenInt Qrack::QInterface::qubitCount
protected

◆ rand_distribution

std::uniform_real_distribution<real1_f> Qrack::QInterface::rand_distribution
protected

◆ rand_generator

qrack_rand_gen_ptr Qrack::QInterface::rand_generator
protected

◆ randGlobalPhase

bool Qrack::QInterface::randGlobalPhase
protected

◆ randomSeed

uint32_t Qrack::QInterface::randomSeed
protected

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