Qrack  7.0
General classical-emulating-quantum development framework
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Qrack::QStabilizer Class Reference

#include <qstabilizer.hpp>

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

Public Member Functions

 QStabilizer (bitLenInt n, bitCapInt perm=0, qrack_rand_gen_ptr rgp=nullptr, complex ignored=CMPLX_DEFAULT_ARG, bool doNorm=false, bool randomGlobalPhase=true, bool ignored2=false, int ignored3=-1, bool useHardwareRNG=true, bool ignored4=false, real1_f ignored5=REAL1_EPSILON, std::vector< int > ignored6={}, bitLenInt ignored7=0, real1_f ignored8=FP_NORM_EPSILON)
 
QInterfacePtr Clone ()
 Clone this QInterface. More...
 
virtual ~QStabilizer ()
 
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...
 
void Finish ()
 If asynchronous work is still running, block until it finishes. More...
 
bool isFinished ()
 Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done. More...
 
void Dump ()
 If asynchronous work is still running, let the simulator know that it can be aborted. More...
 
bitLenInt GetQubitCount ()
 Get the count of bits in this register. More...
 
bitCapInt GetMaxQPower ()
 Get the maximum number of basis states, namely \( 2^n \) for \( n \) qubits. More...
 
void SetPermutation (const bitCapInt &perm)
 
void SetRandomSeed (uint32_t seed)
 
bool Rand ()
 
void SetQuantumState (const complex *inputState)
 Set an arbitrary pure quantum state representation. More...
 
void SetAmplitude (bitCapInt perm, complex amp)
 Sets the representational amplitude of a full permutation. More...
 
virtual bool ApproxCompare (QInterfacePtr toCompare, real1_f ignored=TRYDECOMPOSE_EPSILON)
 Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target. More...
 
virtual bool isEqual (QStabilizerPtr toCompare)
 
real1_f SumSqrDiff (QInterfacePtr toCompare)
 
virtual void CNOT (bitLenInt control, bitLenInt target)
 Apply a CNOT gate with control and target. More...
 
virtual void CY (bitLenInt control, bitLenInt target)
 Apply a CY gate with control and target. More...
 
virtual void CZ (bitLenInt control, bitLenInt target)
 Apply a CZ gate with control and target. More...
 
virtual void H (bitLenInt qubitIndex)
 Apply a Hadamard gate to target. More...
 
virtual void S (bitLenInt qubitIndex)
 Apply a phase gate (|0>->|0>, |1>->i|1>, or "S") to qubit b. More...
 
virtual void IS (bitLenInt qubitIndex)
 Apply an inverse phase gate (|0>->|0>, |1>->-i|1>, or "S adjoint") to qubit b. More...
 
virtual void Z (bitLenInt qubitIndex)
 Apply a phase gate (|0>->|0>, |1>->-|1>, or "Z") to qubit b. More...
 
virtual void X (bitLenInt qubitIndex)
 Apply an X (or NOT) gate to target. More...
 
virtual void Y (bitLenInt qubitIndex)
 Apply a Pauli Y gate to target. More...
 
void StabilizerSqrtX (const bitLenInt &target)
 Apply square root of X gate. More...
 
void StabilizerISqrtX (const bitLenInt &target)
 Apply inverse square root of X gate. More...
 
void StabilizerSqrtY (const bitLenInt &target)
 Apply square root of Y gate. More...
 
void StabilizerISqrtY (const bitLenInt &target)
 Apply inverse square root of Y gate. More...
 
virtual void Swap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 Swap values of two bits in register. More...
 
virtual bool ForceM (bitLenInt t, bool result, bool doForce=true, bool doApply=true)
 Measure qubit b. More...
 
virtual real1_f FirstNonzeroPhase ()
 Get phase of lowest permutation nonzero amplitude. More...
 
virtual void GetQuantumState (complex *stateVec)
 Convert the state to ket notation. More...
 
virtual void GetQuantumState (QInterfacePtr eng)
 Convert the state to ket notation, directly into another QInterface. More...
 
virtual void GetProbs (real1 *outputProbs)
 Get all probabilities corresponding to ket notation. More...
 
virtual complex GetAmplitude (bitCapInt perm)
 Get a single basis state amplitude. More...
 
bool IsSeparableZ (const bitLenInt &target)
 Returns "true" if target qubit is a Z basis eigenstate. More...
 
bool IsSeparableX (const bitLenInt &target)
 Returns "true" if target qubit is an X basis eigenstate. More...
 
bool IsSeparableY (const bitLenInt &target)
 Returns "true" if target qubit is a Y basis eigenstate. More...
 
uint8_t IsSeparable (const bitLenInt &target)
 Returns: 0 if target qubit is not separable 1 if target qubit is a Z basis eigenstate 2 if target qubit is an X basis eigenstate 3 if target qubit is a Y basis eigenstate. More...
 
virtual bitLenInt Compose (QStabilizerPtr toCopy)
 
virtual bitLenInt Compose (QStabilizerPtr toCopy, bitLenInt start)
 
virtual void Decompose (bitLenInt start, QInterfacePtr dest)
 Minimally decompose a set of contiguous bits from the separably composed unit, into "destination". More...
 
virtual QInterfacePtr Decompose (bitLenInt start, bitLenInt length)
 Schmidt decompose a length of qubits. More...
 
virtual void Dispose (bitLenInt start, bitLenInt length)
 Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separable bits from index "start" for "length.". More...
 
virtual void Dispose (bitLenInt start, bitLenInt length, bitCapInt ignored)
 Dispose a a contiguous set of qubits that are already in a permutation eigenstate. More...
 
bool CanDecomposeDispose (const bitLenInt start, const bitLenInt length)
 
virtual bool ApproxCompare (QStabilizerPtr o)
 
virtual void NormalizeState (real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1)
 Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate. More...
 
virtual void UpdateRunningNorm (real1_f norm_thresh=REAL1_DEFAULT_ARG)
 Force a calculation of the norm of the state vector, in order to make it unit length before the next probability or measurement operation. More...
 
virtual real1_f Prob (bitLenInt qubit)
 Direct measure of bit probability to be in |1> state. More...
 
virtual void Mtrx (const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Phase (complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase. More...
 
virtual void Invert (complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase. More...
 
virtual void MCMtrx (const bitLenInt *controls, bitLenInt controlLen, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More...
 
virtual void MCPhase (const bitLenInt *controls, bitLenInt controlLen, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary control bits. More...
 
virtual void MCInvert (const bitLenInt *controls, bitLenInt controlLen, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits. More...
 
virtual void FSim (real1_f theta, real1_f phi, bitLenInt qubit1, bitLenInt qubit2)
 The 2-qubit "fSim" gate, (useful in the simulation of particles with fermionic statistics) More...
 
- 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 bool GetIsArbitraryGlobalPhase ()
 
real1_f Rand ()
 Generate a random real number between 0 and 1. More...
 
virtual void SetPermutation (bitCapInt perm, 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 std::map< QInterfacePtr, bitLenIntCompose (std::vector< QInterfacePtr > toCopy)
 
virtual bitLenInt Compose (QInterfacePtr toCopy, bitLenInt start)
 
virtual void MACMtrx (const bitLenInt *controls, bitLenInt controlLen, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More...
 
virtual void MACPhase (const bitLenInt *controls, bitLenInt controlLen, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits. More...
 
virtual void MACInvert (const bitLenInt *controls, bitLenInt controlLen, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits. More...
 
virtual void UniformlyControlledSingleBit (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubitIndex, const complex *mtrxs)
 Apply a "uniformly controlled" arbitrary single bit unitary transformation. More...
 
virtual void UniformlyControlledSingleBit (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubitIndex, const complex *mtrxs, const bitCapInt *mtrxSkipPowers, bitLenInt mtrxSkipLen, 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, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary control bits. More...
 
virtual void AntiCSwap (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary (anti) control bits. More...
 
virtual void CSqrtSwap (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary control bits. More...
 
virtual void AntiCSqrtSwap (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary (anti) control bits. More...
 
virtual void CISqrtSwap (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary control bits. More...
 
virtual void AntiCISqrtSwap (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit1, bitLenInt qubit2)
 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 AntiCNOT (bitLenInt control, bitLenInt target)
 Anti controlled NOT 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 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 CU (const bitLenInt *controls, bitLenInt controlLen, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 Controlled general unitary gate. More...
 
virtual void AntiCU (const bitLenInt *controls, bitLenInt controlLen, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 (Anti-)Controlled general unitary 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 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 PhaseParity (real1_f radians, bitCapInt mask)
 Parity phase gate. More...
 
virtual void XMask (bitCapInt mask)
 Masked X gate. More...
 
virtual void YMask (bitCapInt mask)
 Masked Y gate. More...
 
virtual void ZMask (bitCapInt mask)
 Masked 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 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 bitLenInt *controls, 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, bitLenInt controlLen, bitLenInt qubitIndex, const real1 *angles)
 Apply a "uniformly controlled" rotation of a bit around the Pauli Z axis. More...
 
virtual void RT (real1_f radians, bitLenInt qubitIndex)
 Phase shift gate. More...
 
virtual void RX (real1_f radians, bitLenInt qubitIndex)
 X axis rotation gate. More...
 
virtual void RY (real1_f radians, bitLenInt qubitIndex)
 Y axis rotation gate. More...
 
virtual void RZ (real1_f radians, bitLenInt qubitIndex)
 Z axis rotation gate. More...
 
virtual void CRZ (real1_f radians, bitLenInt control, bitLenInt target)
 Controlled Z axis rotation gate. More...
 
virtual void RTDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction phase shift gate. More...
 
virtual void RXDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction X axis rotation gate. More...
 
virtual void Exp (real1_f radians, bitLenInt qubitIndex)
 (Identity) Exponentiation gate More...
 
virtual void Exp (const bitLenInt *controls, bitLenInt controlLen, bitLenInt qubit, const complex *matrix2x2, bool antiCtrled=false)
 Imaginary exponentiation of arbitrary 2x2 gate. More...
 
virtual void ExpDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction (identity) exponentiation gate. More...
 
virtual void ExpX (real1_f radians, bitLenInt qubitIndex)
 Pauli X exponentiation gate. More...
 
virtual void ExpXDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli X exponentiation gate. More...
 
virtual void ExpY (real1_f radians, bitLenInt qubitIndex)
 Pauli Y exponentiation gate. More...
 
virtual void ExpYDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli Y exponentiation gate. More...
 
virtual void ExpZ (real1_f radians, bitLenInt qubitIndex)
 Pauli Z exponentiation gate. More...
 
virtual void ExpZDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli Z exponentiation gate. More...
 
virtual void CRX (real1_f radians, bitLenInt control, bitLenInt target)
 Controlled X axis rotation gate. More...
 
virtual void CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction X axis rotation gate. More...
 
virtual void RYDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Y axis rotation gate. More...
 
virtual void 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 RZDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Z axis rotation gate. More...
 
virtual void CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction Z axis rotation gate. More...
 
virtual void CRT (real1_f radians, bitLenInt control, bitLenInt target)
 Controlled "phase shift gate". More...
 
virtual void CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction "phase shift gate". More...
 
virtual void H (bitLenInt start, bitLenInt length)
 Bitwise Hadamard. More...
 
virtual void X (bitLenInt start, bitLenInt length)
 Bitwise Pauli X (or logical "NOT") operator. More...
 
virtual void ROL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Circular shift left - shift bits left, and carry last bits. More...
 
virtual void ROR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Circular shift right - shift bits right, and carry first bits. More...
 
virtual void ASL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Arithmetic shift left, with last 2 bits as sign and carry. More...
 
virtual void ASR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Arithmetic shift right, with last 2 bits as sign and carry. More...
 
virtual void LSL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Logical shift left, filling the extra bits with |0> More...
 
virtual void LSR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Logical shift right, filling the extra bits with |0> More...
 
virtual void INCDECC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Common driver method behind INCC and DECC. More...
 
virtual void INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add integer (without sign, with carry) More...
 
virtual void DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract classical integer (without sign, with carry) More...
 
virtual void INC (bitCapInt toAdd, bitLenInt start, bitLenInt length)
 Add integer (without sign) More...
 
virtual void CINC (bitCapInt toAdd, bitLenInt inOutStart, bitLenInt length, const bitLenInt *controls, bitLenInt controlLen)
 Add integer (without sign, with controls) More...
 
virtual void INCS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Add a classical integer to the register, with sign and without 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, const bitLenInt *controls, bitLenInt controlLen)
 Subtract classical integer (without sign, with controls) 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 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 bitLenInt *controls, bitLenInt controlLen, bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt carryInSumOut, bitLenInt carryOut)
 Controlled quantum analog of classical "Full Adder" gate. More...
 
virtual void CIFullAdd (const 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 (const 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 (const 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 QFTR (const bitLenInt *qubits, bitLenInt length, 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 bitLenInt *qubits, bitLenInt length, 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, 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, bitLenInt length)
 Measure bits with indices in array, and return a mask of the results. More...
 
virtual bitCapInt ForceM (const bitLenInt *bits, bitLenInt length, const bool *values, bool doApply=true)
 Measure bits with indices in array, and return a mask of the results. More...
 
virtual void ISwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 Swap values of two bits in register, and apply phase factor of i if bits are different. More...
 
virtual void SqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 Square root of Swap gate. More...
 
virtual void ISqrtSwap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 Inverse square root of Swap gate. More...
 
virtual void Reverse (bitLenInt first, bitLenInt last)
 Reverse all of the bits in a sequence. More...
 
virtual real1_f ProbAll (bitCapInt fullRegister)
 Direct measure of full permutation probability. More...
 
virtual real1_f ProbReg (bitLenInt start, bitLenInt length, bitCapInt permutation)
 Direct measure of register permutation probability. More...
 
virtual real1_f ProbMask (bitCapInt mask, bitCapInt permutation)
 Direct measure of masked permutation probability. More...
 
virtual void ProbMaskAll (bitCapInt mask, real1 *probsArray)
 Direct measure of masked permutation probability. More...
 
virtual void ProbBitsAll (const bitLenInt *bits, bitLenInt length, real1 *probsArray)
 Direct measure of listed permutation probability. More...
 
virtual real1_f ExpectationBitsAll (const bitLenInt *bits, bitLenInt length, bitCapInt offset=0)
 Get permutation expectation value of bits. More...
 
virtual std::map< bitCapInt, int > MultiShotMeasureMask (const bitCapInt *qPowers, bitLenInt qPowerCount, unsigned shots)
 Statistical measure of masked permutation probability. More...
 
virtual void MultiShotMeasureMask (const bitCapInt *qPowers, bitLenInt qPowerCount, unsigned shots, unsigned *shotsArray)
 Statistical measure of masked permutation probability (returned as array) More...
 
virtual void SetBit (bitLenInt qubitIndex1, bool value)
 Set individual bit to pure |0> (false) or |1> (true) state. More...
 
virtual bool TryDecompose (bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
 
virtual bool 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 TrySeparate (const bitLenInt *qubits, bitLenInt length, 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 void SetReactiveSeparate (bool isAggSep)
 Set reactive separation option (on by default if available) More...
 
virtual bool GetReactiveSeparate ()
 Get reactive separation option. More...
 
virtual void SetDevice (int dID, bool forceReInit=false)
 Set the device index, if more than one device is available. More...
 
virtual int64_t GetDevice ()
 Get the device index. More...
 
bitCapIntOcl GetMaxSize ()
 Get maximum number of amplitudes that can be allocated on current device. More...
 
- Public Member Functions inherited from Qrack::ParallelFor
 ParallelFor ()
 
virtual ~ParallelFor ()
 
void SetConcurrencyLevel (unsigned num)
 
unsigned GetConcurrencyLevel ()
 
bitCapIntOcl GetStride ()
 
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 bitCapIntOcl *maskArray, const bitLenInt maskLen, 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...
 
void par_for_qbdt (const bitCapInt begin, const bitCapInt end, BdtFunc fn)
 Iterate over a QBDT tree. More...
 
real1_f par_norm (const bitCapIntOcl maxQPower, const StateVectorPtr stateArray, real1_f norm_thresh=ZERO_R1)
 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 Types

typedef std::vector< bool > BoolVector
 
typedef std::function< void(const bitLenInt &)> StabilizerParallelFunc
 
typedef std::function< void(void)> DispatchFn
 

Protected Member Functions

void Dispatch (DispatchFn fn)
 
void ParFor (StabilizerParallelFunc fn)
 
bool TrimControls (const bitLenInt *lControls, bitLenInt lControlLen, std::vector< bitLenInt > &output)
 
void rowcopy (const bitLenInt &i, const bitLenInt &k)
 Sets row i equal to row k. More...
 
void rowswap (const bitLenInt &i, const bitLenInt &k)
 Swaps row i and row k. More...
 
void rowset (const bitLenInt &i, bitLenInt b)
 Sets row i equal to the bth observable (X_1,...X_n,Z_1,...,Z_n) More...
 
uint8_t clifford (const bitLenInt &i, const bitLenInt &k)
 Return the phase (0,1,2,3) when row i is LEFT-multiplied by row k. More...
 
void rowmult (const bitLenInt &i, const bitLenInt &k)
 Left-multiply row i by row k. More...
 
bitLenInt gaussian ()
 Do Gaussian elimination to put the stabilizer generators in the following form: At the top, a minimal set of generators containing X's and Y's, in "quasi-upper-triangular" form. More...
 
void seed (const bitLenInt &g)
 Finds a Pauli operator P such that the basis state P|0...0> occurs with nonzero amplitude in q, and writes P to the scratch space of q. More...
 
AmplitudeEntry getBasisAmp (const real1_f &nrm)
 Helper for setBasisState() and setBasisProb() More...
 
void setBasisState (const real1_f &nrm, complex *stateVec, QInterfacePtr eng)
 Returns the result of applying the Pauli operator in the "scratch space" of q to |0...0> More...
 
void setBasisProb (const real1_f &nrm, real1 *outputProbs)
 Returns the probability from applying the Pauli operator in the "scratch space" of q to |0...0> More...
 
void DecomposeDispose (const bitLenInt start, const bitLenInt length, QStabilizerPtr toCopy)
 
- Protected Member Functions inherited from Qrack::QInterface
virtual void SetQubitCount (bitLenInt qb)
 
template<typename GateFunc >
void ControlledLoopFixture (bitLenInt length, GateFunc gate)
 
void FreeAligned (void *toFree)
 
complex GetNonunitaryPhase ()
 
template<typename Fn >
void MACWrapper (const bitLenInt *controls, bitLenInt controlLen, Fn fn)
 

Protected Attributes

std::vector< BoolVectorx
 
std::vector< BoolVectorz
 
std::vector< uint8_t > r
 
unsigned rawRandBools
 
unsigned rawRandBoolsRemaining
 
- Protected Attributes inherited from Qrack::QInterface
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
 
bool useRDRAND
 
real1 amplitudeFloor
 

Additional Inherited Members

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

Member Typedef Documentation

◆ BoolVector

typedef std::vector<bool> Qrack::QStabilizer::BoolVector
protected

◆ DispatchFn

typedef std::function<void(void)> Qrack::QStabilizer::DispatchFn
protected

◆ StabilizerParallelFunc

typedef std::function<void(const bitLenInt&)> Qrack::QStabilizer::StabilizerParallelFunc
protected

Constructor & Destructor Documentation

◆ QStabilizer()

Qrack::QStabilizer::QStabilizer ( bitLenInt  n,
bitCapInt  perm = 0,
qrack_rand_gen_ptr  rgp = nullptr,
complex  ignored = CMPLX_DEFAULT_ARG,
bool  doNorm = false,
bool  randomGlobalPhase = true,
bool  ignored2 = false,
int  ignored3 = -1,
bool  useHardwareRNG = true,
bool  ignored4 = false,
real1_f  ignored5 = REAL1_EPSILON,
std::vector< int >  ignored6 = {},
bitLenInt  ignored7 = 0,
real1_f  ignored8 = FP_NORM_EPSILON 
)

◆ ~QStabilizer()

virtual Qrack::QStabilizer::~QStabilizer ( )
inlinevirtual

Member Function Documentation

◆ ApproxCompare() [1/2]

virtual bool Qrack::QStabilizer::ApproxCompare ( QInterfacePtr  toCompare,
real1_f  error_tol = TRYDECOMPOSE_EPSILON 
)
inlinevirtual

Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ApproxCompare() [2/2]

bool Qrack::QStabilizer::ApproxCompare ( QStabilizerPtr  o)
virtual

◆ CanDecomposeDispose()

bool Qrack::QStabilizer::CanDecomposeDispose ( const bitLenInt  start,
const bitLenInt  length 
)

◆ clifford()

uint8_t Qrack::QStabilizer::clifford ( const bitLenInt i,
const bitLenInt k 
)
protected

Return the phase (0,1,2,3) when row i is LEFT-multiplied by row k.

◆ Clone()

QInterfacePtr Qrack::QStabilizer::Clone ( )
inlinevirtual

Clone this QInterface.

Implements Qrack::QInterface.

◆ CNOT()

void Qrack::QStabilizer::CNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Apply a CNOT gate with control and target.

Reimplemented from Qrack::QInterface.

◆ Compose() [1/2]

virtual bitLenInt Qrack::QStabilizer::Compose ( QStabilizerPtr  toCopy)
inlinevirtual

◆ Compose() [2/2]

bitLenInt Qrack::QStabilizer::Compose ( QStabilizerPtr  toCopy,
bitLenInt  start 
)
virtual

◆ CY()

void Qrack::QStabilizer::CY ( bitLenInt  control,
bitLenInt  target 
)
virtual

Apply a CY gate with control and target.

Reimplemented from Qrack::QInterface.

◆ CZ()

void Qrack::QStabilizer::CZ ( bitLenInt  control,
bitLenInt  target 
)
virtual

Apply a CZ gate with control and target.

Reimplemented from Qrack::QInterface.

◆ Decompose() [1/2]

virtual void Qrack::QStabilizer::Decompose ( bitLenInt  start,
QInterfacePtr  dest 
)
inlinevirtual

Minimally decompose a set of contiguous bits from the separably composed unit, into "destination".

Minimally decompose a set of contigious bits from the separably composed unit. The length of this separable unit is reduced by the length of bits decomposed, and the bits removed are output in the destination QInterface pointer. The destination object must be initialized to the correct number of bits, in 0 permutation state. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."

Like how "Compose" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Decompose" is like "just moving a few qubits away from the rest." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state. (This is equivalent to a "Schmidt decomposition.")

If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:

\( P(|1000>|xy>) = P(|1000 00>) + P(|1000 10>) + P(|1000 01>) + P(|1000 11>). \)

If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.

Implements Qrack::QInterface.

◆ Decompose() [2/2]

QInterfacePtr Qrack::QStabilizer::Decompose ( bitLenInt  start,
bitLenInt  length 
)
virtual

Schmidt decompose a length of qubits.

Implements Qrack::QInterface.

◆ DecomposeDispose()

void Qrack::QStabilizer::DecomposeDispose ( const bitLenInt  start,
const bitLenInt  length,
QStabilizerPtr  toCopy 
)
protected

◆ Dispatch()

void Qrack::QStabilizer::Dispatch ( DispatchFn  fn)
inlineprotected

◆ Dispose() [1/2]

virtual void Qrack::QStabilizer::Dispose ( bitLenInt  start,
bitLenInt  length 
)
inlinevirtual

Minimally decompose a set of contiguous bits from the separably composed unit, and discard the separable bits from index "start" for "length.".

Minimally decompose a set of contigious bits from the separably composed unit. The length of this separable unit is reduced by the length of bits decomposed, and the bits removed are output in the destination QInterface pointer. The destination object must be initialized to the correct number of bits, in 0 permutation state. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."

Like how "Compose" is like "just setting another group of qubits down next to the first," if two sets of qubits are not entangled, then "Decompose" is like "just moving a few qubits away from the rest." Schroedinger's equation does not require bits to be explicitly interacted in order to describe their permutation basis, and the descriptions of state of separable subsystems, those which are not entangled with other subsystems, are just as easily removed from the description of state. (This is equivalent to a "Schmidt decomposition.")

If we have for example 5 qubits, and we wish to separate into "left" and "right" subsystems of 3 and 2 qubits, we sum probabilities of one permutation of the "left" three over ALL permutations of the "right" two, for all permutations, and vice versa, like so:

\( P(|1000>|xy>) = P(|1000 00>) + P(|1000 10>) + P(|1000 01>) + P(|1000 11>). \)

If the subsystems are not "separable," i.e. if they are entangled, this operation is not well-motivated, and its output is not necessarily defined. (The summing of probabilities over permutations of subsytems will be performed as described above, but this is not quantum mechanically meaningful.) To ensure that the subsystem is "separable," i.e. that it has no entanglements to other subsystems in the QInterface, it can be measured with M(), or else all qubits other than the subsystem can be measured.

Implements Qrack::QInterface.

◆ Dispose() [2/2]

virtual void Qrack::QStabilizer::Dispose ( bitLenInt  start,
bitLenInt  length,
bitCapInt  disposedPerm 
)
inlinevirtual

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

Implements Qrack::QInterface.

◆ Dump()

void Qrack::QStabilizer::Dump ( )
inlinevirtual

If asynchronous work is still running, let the simulator know that it can be aborted.

Note that this method is typically used internally where appropriate, such that user code typically does not call Dump().

Reimplemented from Qrack::QInterface.

◆ Finish()

void Qrack::QStabilizer::Finish ( )
inlinevirtual

If asynchronous work is still running, block until it finishes.

Note that this is never necessary to get correct, timely return values. QEngines and other layers will always internally "Finish" when necessary for correct return values. This is primarily for debugging and benchmarking.

Reimplemented from Qrack::QInterface.

◆ FirstNonzeroPhase()

real1_f Qrack::QStabilizer::FirstNonzeroPhase ( )
virtual

Get phase of lowest permutation nonzero amplitude.

Reimplemented from Qrack::QInterface.

◆ ForceM()

bool Qrack::QStabilizer::ForceM ( bitLenInt  t,
bool  result,
bool  doForce = true,
bool  doApply = true 
)
virtual

Measure qubit b.

Implements Qrack::QInterface.

◆ FSim()

void Qrack::QStabilizer::FSim ( real1_f  theta,
real1_f  phi,
bitLenInt  qubitIndex1,
bitLenInt  qubitIndex2 
)
virtual

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

Implements Qrack::QInterface.

◆ gaussian()

bitLenInt Qrack::QStabilizer::gaussian ( )
protected

Do Gaussian elimination to put the stabilizer generators in the following form: At the top, a minimal set of generators containing X's and Y's, in "quasi-upper-triangular" form.

(Return value = number of such generators = log_2 of number of nonzero basis states) At the bottom, generators containing Z's only in quasi-upper-triangular form.

◆ GetAmplitude()

complex Qrack::QStabilizer::GetAmplitude ( bitCapInt  perm)
virtual

Get a single basis state amplitude.

Convert the state to ket notation (warning: could be huge!)

Implements Qrack::QInterface.

◆ getBasisAmp()

AmplitudeEntry Qrack::QStabilizer::getBasisAmp ( const real1_f nrm)
protected

◆ GetMaxQPower()

bitCapInt Qrack::QStabilizer::GetMaxQPower ( )
inlinevirtual

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

Reimplemented from Qrack::QInterface.

◆ GetProbs()

void Qrack::QStabilizer::GetProbs ( real1 outputProbs)
virtual

Get all probabilities corresponding to ket notation.

Implements Qrack::QInterface.

◆ GetQuantumState() [1/2]

void Qrack::QStabilizer::GetQuantumState ( complex stateVec)
virtual

Convert the state to ket notation.

Convert the state to ket notation (warning: could be huge!)

Implements Qrack::QInterface.

◆ GetQuantumState() [2/2]

void Qrack::QStabilizer::GetQuantumState ( QInterfacePtr  eng)
virtual

Convert the state to ket notation, directly into another QInterface.

Convert the state to ket notation (warning: could be huge!)

◆ GetQubitCount()

bitLenInt Qrack::QStabilizer::GetQubitCount ( )
inlinevirtual

Get the count of bits in this register.

Reimplemented from Qrack::QInterface.

◆ H()

void Qrack::QStabilizer::H ( bitLenInt  qubitIndex)
virtual

Apply a Hadamard gate to target.

Reimplemented from Qrack::QInterface.

◆ Invert()

void Qrack::QStabilizer::Invert ( complex  topRight,
complex  bottomLeft,
bitLenInt  qubitIndex 
)
virtual

Apply a single bit transformation that reverses bit probability and might effect phase.

Reimplemented from Qrack::QInterface.

◆ IS()

void Qrack::QStabilizer::IS ( bitLenInt  qubitIndex)
virtual

Apply an inverse phase gate (|0>->|0>, |1>->-i|1>, or "S adjoint") to qubit b.

Apply a phase gate (|0>->|0>, |1>->i|1>, or "S") to qubit b.

Reimplemented from Qrack::QInterface.

◆ isClifford() [1/2]

virtual bool Qrack::QStabilizer::isClifford ( )
inlinevirtual

Returns "true" if current state is identifiably within the Clifford set, or "false" if it is not or cannot be determined.

Reimplemented from Qrack::QInterface.

◆ isClifford() [2/2]

virtual bool Qrack::QStabilizer::isClifford ( bitLenInt  qubit)
inlinevirtual

Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is not or cannot be determined.

Reimplemented from Qrack::QInterface.

◆ isEqual()

bool Qrack::QStabilizer::isEqual ( QStabilizerPtr  toCompare)
virtual

◆ isFinished()

bool Qrack::QStabilizer::isFinished ( )
inlinevirtual

Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done.

Reimplemented from Qrack::QInterface.

◆ IsSeparable()

uint8_t Qrack::QStabilizer::IsSeparable ( const bitLenInt target)

Returns: 0 if target qubit is not separable 1 if target qubit is a Z basis eigenstate 2 if target qubit is an X basis eigenstate 3 if target qubit is a Y basis eigenstate.

◆ IsSeparableX()

bool Qrack::QStabilizer::IsSeparableX ( const bitLenInt target)

Returns "true" if target qubit is an X basis eigenstate.

◆ IsSeparableY()

bool Qrack::QStabilizer::IsSeparableY ( const bitLenInt target)

Returns "true" if target qubit is a Y basis eigenstate.

◆ IsSeparableZ()

bool Qrack::QStabilizer::IsSeparableZ ( const bitLenInt target)

Returns "true" if target qubit is a Z basis eigenstate.

◆ MCInvert()

void Qrack::QStabilizer::MCInvert ( const bitLenInt controls,
bitLenInt  controlLen,
complex  topRight,
complex  bottomLeft,
bitLenInt  target 
)
virtual

Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits.

Reimplemented from Qrack::QInterface.

◆ MCMtrx()

void Qrack::QStabilizer::MCMtrx ( const bitLenInt controls,
bitLenInt  controlLen,
const complex mtrx,
bitLenInt  target 
)
virtual

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

Implements Qrack::QInterface.

◆ MCPhase()

void Qrack::QStabilizer::MCPhase ( const bitLenInt controls,
bitLenInt  controlLen,
complex  topLeft,
complex  bottomRight,
bitLenInt  target 
)
virtual

Apply a single bit transformation that only effects phase, with arbitrary control bits.

Reimplemented from Qrack::QInterface.

◆ Mtrx()

void Qrack::QStabilizer::Mtrx ( const complex mtrx,
bitLenInt  qubitIndex 
)
virtual

Apply an arbitrary single bit unitary transformation.

Implements Qrack::QInterface.

◆ NormalizeState()

virtual void Qrack::QStabilizer::NormalizeState ( real1_f  nrm = REAL1_DEFAULT_ARG,
real1_f  norm_thresh = REAL1_DEFAULT_ARG,
real1_f  phaseArg = ZERO_R1 
)
inlinevirtual

Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate.

(On an actual quantum computer, the state should never require manual normalization.)

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ ParFor()

void Qrack::QStabilizer::ParFor ( StabilizerParallelFunc  fn)
inlineprotected

◆ Phase()

void Qrack::QStabilizer::Phase ( complex  topLeft,
complex  bottomRight,
bitLenInt  qubitIndex 
)
virtual

Apply a single bit transformation that only effects phase.

Reimplemented from Qrack::QInterface.

◆ Prob()

real1_f Qrack::QStabilizer::Prob ( bitLenInt  qubitIndex)
virtual

Direct measure of bit probability to be in |1> state.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ Rand()

bool Qrack::QStabilizer::Rand ( )
inline

◆ rowcopy()

void Qrack::QStabilizer::rowcopy ( const bitLenInt i,
const bitLenInt k 
)
protected

Sets row i equal to row k.

◆ rowmult()

void Qrack::QStabilizer::rowmult ( const bitLenInt i,
const bitLenInt k 
)
protected

Left-multiply row i by row k.

◆ rowset()

void Qrack::QStabilizer::rowset ( const bitLenInt i,
bitLenInt  b 
)
protected

Sets row i equal to the bth observable (X_1,...X_n,Z_1,...,Z_n)

◆ rowswap()

void Qrack::QStabilizer::rowswap ( const bitLenInt i,
const bitLenInt k 
)
protected

Swaps row i and row k.

◆ S()

void Qrack::QStabilizer::S ( bitLenInt  qubitIndex)
virtual

Apply a phase gate (|0>->|0>, |1>->i|1>, or "S") to qubit b.

Reimplemented from Qrack::QInterface.

◆ seed()

void Qrack::QStabilizer::seed ( const bitLenInt g)
protected

Finds a Pauli operator P such that the basis state P|0...0> occurs with nonzero amplitude in q, and writes P to the scratch space of q.

For this to work, Gaussian elimination must already have been performed on q. g is the return value from gaussian(q).

◆ SetAmplitude()

void Qrack::QStabilizer::SetAmplitude ( bitCapInt  perm,
complex  amp 
)
inlinevirtual

Sets the representational amplitude of a full permutation.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ setBasisProb()

void Qrack::QStabilizer::setBasisProb ( const real1_f nrm,
real1 outputProbs 
)
protected

Returns the probability from applying the Pauli operator in the "scratch space" of q to |0...0>

◆ setBasisState()

void Qrack::QStabilizer::setBasisState ( const real1_f nrm,
complex stateVec,
QInterfacePtr  eng 
)
protected

Returns the result of applying the Pauli operator in the "scratch space" of q to |0...0>

◆ SetPermutation()

void Qrack::QStabilizer::SetPermutation ( const bitCapInt perm)

◆ SetQuantumState()

void Qrack::QStabilizer::SetQuantumState ( const complex inputState)
inlinevirtual

Set an arbitrary pure quantum state representation.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ SetRandomSeed()

void Qrack::QStabilizer::SetRandomSeed ( uint32_t  seed)
inline

◆ StabilizerISqrtX()

void Qrack::QStabilizer::StabilizerISqrtX ( const bitLenInt target)

Apply inverse square root of X gate.

◆ StabilizerISqrtY()

void Qrack::QStabilizer::StabilizerISqrtY ( const bitLenInt target)

Apply inverse square root of Y gate.

◆ StabilizerSqrtX()

void Qrack::QStabilizer::StabilizerSqrtX ( const bitLenInt target)

Apply square root of X gate.

◆ StabilizerSqrtY()

void Qrack::QStabilizer::StabilizerSqrtY ( const bitLenInt target)

Apply square root of Y gate.

◆ SumSqrDiff()

real1_f Qrack::QStabilizer::SumSqrDiff ( QInterfacePtr  toCompare)
inlinevirtual

Implements Qrack::QInterface.

◆ Swap()

void Qrack::QStabilizer::Swap ( bitLenInt  qubitIndex1,
bitLenInt  qubitIndex2 
)
virtual

Swap values of two bits in register.

Reimplemented from Qrack::QInterface.

◆ TrimControls()

bool Qrack::QStabilizer::TrimControls ( const bitLenInt lControls,
bitLenInt  lControlLen,
std::vector< bitLenInt > &  output 
)
inlineprotected

◆ UpdateRunningNorm()

virtual void Qrack::QStabilizer::UpdateRunningNorm ( real1_f  norm_thresh = REAL1_DEFAULT_ARG)
inlinevirtual

Force a calculation of the norm of the state vector, in order to make it unit length before the next probability or measurement operation.

(On an actual quantum computer, the state should never require manual normalization.)

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ X()

void Qrack::QStabilizer::X ( bitLenInt  qubitIndex)
virtual

Apply an X (or NOT) gate to target.

Reimplemented from Qrack::QInterface.

◆ Y()

void Qrack::QStabilizer::Y ( bitLenInt  qubitIndex)
virtual

Apply a Pauli Y gate to target.

Reimplemented from Qrack::QInterface.

◆ Z()

void Qrack::QStabilizer::Z ( bitLenInt  qubitIndex)
virtual

Apply a phase gate (|0>->|0>, |1>->-|1>, or "Z") to qubit b.

Apply a phase gate (|0>->|0>, |1>->i|1>, or "S") to qubit b.

Reimplemented from Qrack::QInterface.

Member Data Documentation

◆ r

std::vector<uint8_t> Qrack::QStabilizer::r
protected

◆ rawRandBools

unsigned Qrack::QStabilizer::rawRandBools
protected

◆ rawRandBoolsRemaining

unsigned Qrack::QStabilizer::rawRandBoolsRemaining
protected

◆ x

std::vector<BoolVector> Qrack::QStabilizer::x
protected

◆ z

std::vector<BoolVector> Qrack::QStabilizer::z
protected

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