Qrack  9.0
General classical-emulating-quantum development framework
Functions
Basic quantum gate primitives

Functions

virtual void Qrack::QInterface::Mtrx (const complex *mtrx, bitLenInt qubitIndex)=0
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QInterface::MCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)=0
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More...
 
virtual void Qrack::QInterface::MACMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QInterface::UCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, bitCapInt controlPerm)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits, with arbitary control permutation. More...
 
virtual void Qrack::QInterface::Phase (const complex topLeft, const complex bottomRight, bitLenInt qubitIndex)
 Apply a single bit transformation that only effects phase. More...
 
virtual void Qrack::QInterface::Invert (const complex topRight, const complex bottomLeft, bitLenInt qubitIndex)
 Apply a single bit transformation that reverses bit probability and might effect phase. More...
 
virtual void Qrack::QInterface::MCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary control bits. More...
 
virtual void Qrack::QInterface::MCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits. More...
 
virtual void Qrack::QInterface::MACPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QInterface::MACInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QInterface::UCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target, bitCapInt perm)
 Apply a single bit transformation that only effects phase, with arbitrary control bits, with arbitrary control permutation. More...
 
virtual void Qrack::QInterface::UCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target, bitCapInt perm)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits, with arbitrary control permutation. More...
 
virtual void Qrack::QInterface::UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs)
 Apply a "uniformly controlled" arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QInterface::UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs, const std::vector< bitCapInt > &mtrxSkipPowers, bitCapInt mtrxSkipValueMask)
 
virtual void Qrack::QInterface::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 Qrack::QInterface::CSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary control bits. More...
 
virtual void Qrack::QInterface::AntiCSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary (anti) control bits. More...
 
virtual void Qrack::QInterface::CSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary control bits. More...
 
virtual void Qrack::QInterface::AntiCSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary (anti) control bits. More...
 
virtual void Qrack::QInterface::CISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary control bits. More...
 
virtual void Qrack::QInterface::AntiCISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary (anti) control bits. More...
 
virtual void Qrack::QInterface::CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-controlled NOT gate. More...
 
virtual void Qrack::QInterface::AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled NOT gate. More...
 
virtual void Qrack::QInterface::CNOT (bitLenInt control, bitLenInt target)
 Controlled NOT gate. More...
 
virtual void Qrack::QInterface::AntiCNOT (bitLenInt control, bitLenInt target)
 Anti controlled NOT gate. More...
 
virtual void Qrack::QInterface::CY (bitLenInt control, bitLenInt target)
 Controlled Y gate. More...
 
virtual void Qrack::QInterface::AntiCY (bitLenInt control, bitLenInt target)
 Anti controlled Y gate. More...
 
virtual void Qrack::QInterface::CCY (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-Controlled Y gate. More...
 
virtual void Qrack::QInterface::AntiCCY (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled Y gate. More...
 
virtual void Qrack::QInterface::CZ (bitLenInt control, bitLenInt target)
 Controlled Z gate. More...
 
virtual void Qrack::QInterface::AntiCZ (bitLenInt control, bitLenInt target)
 Anti controlled Z gate. More...
 
virtual void Qrack::QInterface::CCZ (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-Controlled Z gate. More...
 
virtual void Qrack::QInterface::AntiCCZ (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled Z gate. More...
 
virtual void Qrack::QInterface::U (bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 General unitary gate. More...
 
virtual void Qrack::QInterface::U2 (bitLenInt target, real1_f phi, real1_f lambda)
 2-parameter unitary gate More...
 
virtual void Qrack::QInterface::IU2 (bitLenInt target, real1_f phi, real1_f lambda)
 Inverse 2-parameter unitary gate. More...
 
virtual void Qrack::QInterface::AI (bitLenInt target, real1_f azimuth, real1_f inclination)
 "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::IAI (bitLenInt target, real1_f azimuth, real1_f inclination)
 Invert "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::CAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
 Controlled "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::AntiCAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
 (Anti-)Controlled "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::CIAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
 Controlled inverse "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::AntiCIAI (bitLenInt control, bitLenInt target, real1_f azimuth, real1_f inclination)
 (Anti-)Controlled inverse "Azimuth, Inclination" (RY-RZ) More...
 
virtual void Qrack::QInterface::CU (const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 Controlled general unitary gate. More...
 
virtual void Qrack::QInterface::AntiCU (const std::vector< bitLenInt > &controls, bitLenInt target, real1_f theta, real1_f phi, real1_f lambda)
 (Anti-)Controlled general unitary gate More...
 
virtual void Qrack::QInterface::H (bitLenInt qubit)
 Hadamard gate. More...
 
virtual void Qrack::QInterface::SqrtH (bitLenInt qubit)
 Square root of Hadamard gate. More...
 
virtual void Qrack::QInterface::SH (bitLenInt qubit)
 Y-basis transformation gate. More...
 
virtual void Qrack::QInterface::HIS (bitLenInt qubit)
 Y-basis (inverse) transformation gate. More...
 
virtual bool Qrack::QInterface::M (bitLenInt qubitIndex)
 Measurement gate. More...
 
virtual bool Qrack::QInterface::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 void Qrack::QInterface::S (bitLenInt qubit)
 S gate. More...
 
virtual void Qrack::QInterface::IS (bitLenInt qubit)
 Inverse S gate. More...
 
virtual void Qrack::QInterface::T (bitLenInt qubit)
 T gate. More...
 
virtual void Qrack::QInterface::IT (bitLenInt qubit)
 Inverse T gate. More...
 
virtual void Qrack::QInterface::PhaseRootN (bitLenInt n, bitLenInt qubit)
 "PhaseRootN" gate More...
 
virtual void Qrack::QInterface::IPhaseRootN (bitLenInt n, bitLenInt qubit)
 Inverse "PhaseRootN" gate. More...
 
virtual void Qrack::QInterface::PhaseParity (real1_f radians, bitCapInt mask)
 Parity phase gate. More...
 
virtual void Qrack::QInterface::X (bitLenInt qubit)
 X gate. More...
 
virtual void Qrack::QInterface::XMask (bitCapInt mask)
 Masked X gate. More...
 
virtual void Qrack::QInterface::Y (bitLenInt qubit)
 Y gate. More...
 
virtual void Qrack::QInterface::YMask (bitCapInt mask)
 Masked Y gate. More...
 
virtual void Qrack::QInterface::Z (bitLenInt qubit)
 Z gate. More...
 
virtual void Qrack::QInterface::ZMask (bitCapInt mask)
 Masked Z gate. More...
 
virtual void Qrack::QInterface::SqrtX (bitLenInt qubit)
 Square root of X gate. More...
 
virtual void Qrack::QInterface::ISqrtX (bitLenInt qubit)
 Inverse square root of X gate. More...
 
virtual void Qrack::QInterface::SqrtY (bitLenInt qubit)
 Square root of Y gate. More...
 
virtual void Qrack::QInterface::ISqrtY (bitLenInt qubit)
 Inverse square root of Y gate. More...
 
virtual void Qrack::QInterface::SqrtW (bitLenInt qubit)
 Square root of W gate. More...
 
virtual void Qrack::QInterface::ISqrtW (bitLenInt qubit)
 Inverse square root of W gate. More...
 
virtual void Qrack::QInterface::CH (bitLenInt control, bitLenInt target)
 Controlled H gate. More...
 
virtual void Qrack::QInterface::AntiCH (bitLenInt control, bitLenInt target)
 (Anti-)controlled H gate More...
 
virtual void Qrack::QInterface::CS (bitLenInt control, bitLenInt target)
 Controlled S gate. More...
 
virtual void Qrack::QInterface::AntiCS (bitLenInt control, bitLenInt target)
 (Anti-)controlled S gate More...
 
virtual void Qrack::QInterface::CIS (bitLenInt control, bitLenInt target)
 Controlled inverse S gate. More...
 
virtual void Qrack::QInterface::AntiCIS (bitLenInt control, bitLenInt target)
 (Anti-)controlled inverse S gate More...
 
virtual void Qrack::QInterface::CT (bitLenInt control, bitLenInt target)
 Controlled T gate. More...
 
virtual void Qrack::QInterface::CIT (bitLenInt control, bitLenInt target)
 Controlled inverse T gate. More...
 
virtual void Qrack::QInterface::CPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target)
 Controlled "PhaseRootN" gate. More...
 
virtual void Qrack::QInterface::AntiCPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target)
 (Anti-)controlled "PhaseRootN" gate More...
 
virtual void Qrack::QInterface::CIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target)
 Controlled inverse "PhaseRootN" gate. More...
 
virtual void Qrack::QInterface::AntiCIPhaseRootN (bitLenInt n, bitLenInt control, bitLenInt target)
 (Anti-)controlled inverse "PhaseRootN" gate More...
 
virtual void Qrack::QUnit::H (bitLenInt target)
 Hadamard gate. More...
 
virtual void Qrack::QUnit::S (bitLenInt target)
 S gate. More...
 
virtual void Qrack::QUnit::IS (bitLenInt target)
 Inverse S gate. More...
 
virtual void Qrack::QUnit::ZMask (bitCapInt mask)
 Masked Z gate. More...
 
virtual void Qrack::QUnit::PhaseParity (real1 radians, bitCapInt mask)
 
virtual void Qrack::QUnit::Phase (complex topLeft, complex bottomRight, bitLenInt qubitIndex)
 Apply a single bit transformation that only effects phase. More...
 
virtual void Qrack::QUnit::Invert (complex topRight, complex bottomLeft, bitLenInt qubitIndex)
 Apply a single bit transformation that reverses bit probability and might effect phase. More...
 
virtual void Qrack::QUnit::MCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary control bits. More...
 
virtual void Qrack::QUnit::MCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits. More...
 
virtual void Qrack::QUnit::MACPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target)
 Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QUnit::MACInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QUnit::UCPhase (const std::vector< bitLenInt > &controls, complex topLeft, complex bottomRight, bitLenInt target, bitCapInt controlPerm)
 Apply a single bit transformation that only effects phase, with arbitrary control bits, with arbitrary control permutation. More...
 
virtual void Qrack::QUnit::UCInvert (const std::vector< bitLenInt > &controls, complex topRight, complex bottomLeft, bitLenInt target, bitCapInt controlPerm)
 Apply a single bit transformation that reverses bit probability and might effect phase, with arbitrary control bits, with arbitrary control permutation. More...
 
virtual void Qrack::QUnit::Mtrx (const complex *mtrx, bitLenInt qubit)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void Qrack::QUnit::MCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits. More...
 
virtual void Qrack::QUnit::MACMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target)
 Apply an arbitrary single bit unitary transformation, with arbitrary (anti-)control bits. More...
 
virtual void Qrack::QUnit::UCMtrx (const std::vector< bitLenInt > &controls, const complex *mtrx, bitLenInt target, bitCapInt controlPerm)
 Apply an arbitrary single bit unitary transformation, with arbitrary control bits, with arbitary control permutation. More...
 
virtual void Qrack::QUnit::UniformlyControlledSingleBit (const std::vector< bitLenInt > &controls, bitLenInt qubitIndex, const complex *mtrxs, const std::vector< bitCapInt > &mtrxSkipPowers, bitCapInt mtrxSkipValueMask)
 
virtual void Qrack::QUnit::CUniformParityRZ (const std::vector< bitLenInt > &controls, bitCapInt mask, real1_f angle)
 If the controls are set and the target qubit set parity is odd, this applies a phase factor of \(e^{i angle}\). More...
 
virtual void Qrack::QUnit::CSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary control bits. More...
 
virtual void Qrack::QUnit::AntiCSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a swap with arbitrary (anti) control bits. More...
 
virtual void Qrack::QUnit::CSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary control bits. More...
 
virtual void Qrack::QUnit::AntiCSqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply a square root of swap with arbitrary (anti) control bits. More...
 
virtual void Qrack::QUnit::CISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary control bits. More...
 
virtual void Qrack::QUnit::AntiCISqrtSwap (const std::vector< bitLenInt > &controls, bitLenInt qubit1, bitLenInt qubit2)
 Apply an inverse square root of swap with arbitrary (anti) control bits. More...
 
virtual bool Qrack::QUnit::ForceM (bitLenInt qubitIndex, bool result, bool doForce=true, bool doApply=true)
 Act as if is a measurement was applied, except force the (usually random) result. More...
 
virtual bitCapInt Qrack::QUnit::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 Qrack::QUnit::MAll ()
 Measure permutation state of all coherent bits. More...
 
virtual std::map< bitCapInt, int > Qrack::QUnit::MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots)
 Statistical measure of masked permutation probability. More...
 
virtual void Qrack::QUnit::MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots, unsigned long long *shotsArray)
 Statistical measure of masked permutation probability (returned as array) More...
 

Detailed Description

Function Documentation

◆ AI()

void Qrack::QInterface::AI ( bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

"Azimuth, Inclination" (RY-RZ)

"Azimuth, Inclination"

Sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ AntiCAI()

void Qrack::QInterface::AntiCAI ( bitLenInt  control,
bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

(Anti-)Controlled "Azimuth, Inclination" (RY-RZ)

Controlled "Azimuth, Inclination".

If the control bit is reset, this gate sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ AntiCCNOT()

virtual void Qrack::QInterface::AntiCCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Anti doubly-controlled NOT gate.

If both controls are set to 0, the target bit is NOT-ed or X-ed.

◆ AntiCCY()

virtual void Qrack::QInterface::AntiCCY ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Anti doubly-controlled Y gate.

If both controls are set to 0, apply Pauli Y operation to target bit.

◆ AntiCCZ()

virtual void Qrack::QInterface::AntiCCZ ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Anti doubly-controlled Z gate.

If both controls are set to 0, apply Pauli Z operation to target bit.

◆ AntiCH()

virtual void Qrack::QInterface::AntiCH ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

(Anti-)controlled H gate

If the "control" bit is set to 1, then the "H" Walsh-Hadamard transform operator is applied to "target."

◆ AntiCIAI()

void Qrack::QInterface::AntiCIAI ( bitLenInt  control,
bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

(Anti-)Controlled inverse "Azimuth, Inclination" (RY-RZ)

Controlled inverse "Azimuth, Inclination".

(Inverse of...) If the control bit is reset, this gate sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ AntiCIPhaseRootN()

virtual void Qrack::QInterface::AntiCIPhaseRootN ( bitLenInt  n,
bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

(Anti-)controlled inverse "PhaseRootN" gate

If the "control" bit is set to 0, then the inverse "PhaseRootN" gate is applied to "target."

◆ AntiCIS()

virtual void Qrack::QInterface::AntiCIS ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

(Anti-)controlled inverse S gate

If the "control" bit is set to 1, then the inverse S gate is applied to "target."

◆ AntiCISqrtSwap() [1/2]

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

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

Reimplemented in Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, and Qrack::QBdtHybrid.

◆ AntiCISqrtSwap() [2/2]

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

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

Reimplemented from Qrack::QInterface.

◆ AntiCNOT()

virtual void Qrack::QInterface::AntiCNOT ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Anti controlled NOT gate.

If the control is set to 0, the target bit is NOT-ed or X-ed.

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ AntiCPhaseRootN()

virtual void Qrack::QInterface::AntiCPhaseRootN ( bitLenInt  n,
bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

(Anti-)controlled "PhaseRootN" gate

If the "control" bit is set to 0, then the "PhaseRootN" gate is applied to "target."

◆ AntiCS()

virtual void Qrack::QInterface::AntiCS ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

(Anti-)controlled S gate

If the "control" bit is set to 1, then the S gate is applied to "target."

◆ AntiCSqrtSwap() [1/2]

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

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

Reimplemented in Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, and Qrack::QBdtHybrid.

◆ AntiCSqrtSwap() [2/2]

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

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

Reimplemented from Qrack::QInterface.

◆ AntiCSwap() [1/2]

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

Apply a swap with arbitrary (anti) control bits.

Reimplemented in Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, and Qrack::QBdtHybrid.

◆ AntiCSwap() [2/2]

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

Apply a swap with arbitrary (anti) control bits.

Reimplemented from Qrack::QInterface.

◆ AntiCU()

void Qrack::QInterface::AntiCU ( const std::vector< bitLenInt > &  controls,
bitLenInt  target,
real1_f  theta,
real1_f  phi,
real1_f  lambda 
)
virtual

(Anti-)Controlled general unitary gate

Applies an (anti-)controlled gate guaranteed to be unitary, from three angles, as commonly defined, spanning all possible single bit unitary gates, (up to a global phase factor which has no effect on Hermitian operator expectation values).

◆ AntiCY()

virtual void Qrack::QInterface::AntiCY ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Anti controlled Y gate.

If the control is set to 0, then the Pauli "Y" operator is applied to the target.

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ AntiCZ()

virtual void Qrack::QInterface::AntiCZ ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Anti controlled Z gate.

If the control is set to 0, then the Pauli "Z" operator is applied to the target.

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ CAI()

void Qrack::QInterface::CAI ( bitLenInt  control,
bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

Controlled "Azimuth, Inclination" (RY-RZ)

Controlled "Azimuth, Inclination".

If the control bit is set, this gate sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ CCNOT()

virtual void Qrack::QInterface::CCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Doubly-controlled NOT gate.

If both controls are set to 1, the target bit is NOT-ed or X-ed.

◆ CCY()

virtual void Qrack::QInterface::CCY ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Doubly-Controlled Y gate.

If both "control" bits are set to 1, then the Pauli "Y" operator is applied to "target."

◆ CCZ()

virtual void Qrack::QInterface::CCZ ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target 
)
inlinevirtual

Doubly-Controlled Z gate.

If both "control" bits are set to 1, then the Pauli "Z" operator is applied to "target."

◆ CH()

virtual void Qrack::QInterface::CH ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled H gate.

If the "control" bit is set to 1, then the "H" Walsh-Hadamard transform operator is applied to "target."

◆ CIAI()

void Qrack::QInterface::CIAI ( bitLenInt  control,
bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

Controlled inverse "Azimuth, Inclination" (RY-RZ)

Controlled inverse "Azimuth, Inclination".

(Inverse of...) If the control bit is set, this gate sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ CIPhaseRootN()

virtual void Qrack::QInterface::CIPhaseRootN ( bitLenInt  n,
bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled inverse "PhaseRootN" gate.

If the "control" bit is set to 1, then the inverse "PhaseRootN" gate is applied to "target."

◆ CIS()

virtual void Qrack::QInterface::CIS ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled inverse S gate.

If the "control" bit is set to 1, then the inverse S gate is applied to "target."

◆ CISqrtSwap() [1/2]

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

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

Reimplemented in Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ CISqrtSwap() [2/2]

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

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

Reimplemented from Qrack::QInterface.

◆ CIT()

virtual void Qrack::QInterface::CIT ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled inverse T gate.

If the "control" bit is set to 1, then the inverse T gate is applied to "target."

◆ CNOT()

virtual void Qrack::QInterface::CNOT ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled NOT gate.

If the control is set to 1, the target bit is NOT-ed or X-ed.

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ CPhaseRootN()

virtual void Qrack::QInterface::CPhaseRootN ( bitLenInt  n,
bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled "PhaseRootN" gate.

If the "control" bit is set to 1, then the "PhaseRootN" gate is applied to "target."

◆ CS()

virtual void Qrack::QInterface::CS ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled S gate.

If the "control" bit is set to 1, then the S gate is applied to "target."

◆ CSqrtSwap() [1/2]

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

Apply a square root of swap with arbitrary control bits.

Reimplemented in Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ CSqrtSwap() [2/2]

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

Apply a square root of swap with arbitrary control bits.

Reimplemented from Qrack::QInterface.

◆ CSwap() [1/2]

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

Apply a swap with arbitrary control bits.

Reimplemented in Qrack::QStabilizerHybrid, Qrack::QUnit, Qrack::QHybrid, Qrack::QEngine, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ CSwap() [2/2]

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

Apply a swap with arbitrary control bits.

Reimplemented from Qrack::QInterface.

◆ CT()

virtual void Qrack::QInterface::CT ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled T gate.

If the "control" bit is set to 1, then the T gate is applied to "target."

◆ CU()

void Qrack::QInterface::CU ( const std::vector< bitLenInt > &  controls,
bitLenInt  target,
real1_f  theta,
real1_f  phi,
real1_f  lambda 
)
virtual

Controlled general unitary gate.

Applies a controlled gate guaranteed to be unitary, from three angles, as commonly defined, spanning all possible single bit unitary gates, (up to a global phase factor which has no effect on Hermitian operator expectation values).

◆ CUniformParityRZ()

void Qrack::QUnit::CUniformParityRZ ( const std::vector< bitLenInt > &  controls,
bitCapInt  mask,
real1_f  angle 
)
virtual

If the controls are set and the target qubit set parity is odd, this applies a phase factor of \(e^{i angle}\).

If the controls are set and the target qubit set parity is even, this applies the conjugate, \(e^{-i angle}\). Otherwise, do nothing if any control is not set.

Implements Qrack::QParity.

◆ CY()

virtual void Qrack::QInterface::CY ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled Y gate.

If the "control" bit is set to 1, then the Pauli "Y" operator is applied to "target."

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ CZ()

virtual void Qrack::QInterface::CZ ( bitLenInt  control,
bitLenInt  target 
)
inlinevirtual

Controlled Z gate.

If the "control" bit is set to 1, then the Pauli "Z" operator is applied to "target."

Reimplemented in Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ ForceM() [1/2]

virtual bool Qrack::QInterface::ForceM ( bitLenInt  qubit,
bool  result,
bool  doForce = true,
bool  doApply = true 
)
pure virtual

Act as if is a measurement was applied, except force the (usually random) result.

Warning
PSEUDO-QUANTUM

Implemented in Qrack::QUnitClifford, Qrack::QStabilizer, Qrack::QUnit, Qrack::QEngine, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QPager, Qrack::QHybrid, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ ForceM() [2/2]

bool Qrack::QUnit::ForceM ( bitLenInt  qubit,
bool  result,
bool  doForce = true,
bool  doApply = true 
)
virtual

Act as if is a measurement was applied, except force the (usually random) result.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ ForceMReg()

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

Act as if is a measurement was applied, except force the (usually random) result.

Bit-wise apply measurement gate to a register.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ H() [1/2]

virtual void Qrack::QInterface::H ( bitLenInt  qubit)
inlinevirtual

Hadamard gate.

Applies a Hadamard gate on qubit at "qubitIndex."

Reimplemented in Qrack::QUnit, Qrack::QUnitClifford, and Qrack::QStabilizer.

◆ H() [2/2]

void Qrack::QUnit::H ( bitLenInt  qubit)
virtual

Hadamard gate.

Applies a Hadamard gate on qubit at "qubitIndex."

Reimplemented from Qrack::QInterface.

◆ HIS()

virtual void Qrack::QInterface::HIS ( bitLenInt  qubit)
inlinevirtual

Y-basis (inverse) transformation gate.

Converts from Pauli Y basis to Z, (via IS then H gates).

◆ IAI()

void Qrack::QInterface::IAI ( bitLenInt  target,
real1_f  azimuth,
real1_f  inclination 
)
virtual

Invert "Azimuth, Inclination" (RY-RZ)

Inverse "Azimuth, Inclination".

(Inverse of) sets the azimuth and inclination from Z-X-Y basis probability measurements.

◆ Invert() [1/2]

void Qrack::QUnit::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.

◆ Invert() [2/2]

virtual void Qrack::QInterface::Invert ( const complex  topRight,
const complex  bottomLeft,
bitLenInt  qubitIndex 
)
inlinevirtual

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

Reimplemented in Qrack::QStabilizer, Qrack::QUnitClifford, Qrack::QUnit, Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QBdtHybrid.

◆ IPhaseRootN()

virtual void Qrack::QInterface::IPhaseRootN ( bitLenInt  n,
bitLenInt  qubit 
)
inlinevirtual

Inverse "PhaseRootN" gate.

Applies an inverse 1/(2^N) phase rotation to the qubit at "qubitIndex."

◆ IS() [1/2]

virtual void Qrack::QInterface::IS ( bitLenInt  qubit)
inlinevirtual

Inverse S gate.

Applies an inverse 1/4 phase rotation to the qubit at "qubitIndex."

Reimplemented in Qrack::QUnit, Qrack::QUnitClifford, and Qrack::QStabilizer.

◆ IS() [2/2]

void Qrack::QUnit::IS ( bitLenInt  qubit)
virtual

Inverse S gate.

Applies an inverse 1/4 phase rotation to the qubit at "qubitIndex."

Reimplemented from Qrack::QInterface.

◆ ISqrtW()

virtual void Qrack::QInterface::ISqrtW ( bitLenInt  qubit)
inlinevirtual

Inverse square root of W gate.

Per 2019 Arute, Google's "quantum supremacy" experiment

◆ ISqrtX()

virtual void Qrack::QInterface::ISqrtX ( bitLenInt  qubit)
inlinevirtual

Inverse square root of X gate.

Applies the (by convention) inverse square root of the Pauli "X" operator to the qubit at "qubitIndex." The Pauli "X" operator is equivalent to a logical "NOT."

◆ ISqrtY()

virtual void Qrack::QInterface::ISqrtY ( bitLenInt  qubit)
inlinevirtual

Inverse square root of Y gate.

Applies the (by convention) inverse square root of the Pauli "Y" operator to the qubit at "qubitIndex." The Pauli "Y" operator is similar to a logical "NOT" with permutation phase effects.

◆ IT()

virtual void Qrack::QInterface::IT ( bitLenInt  qubit)
inlinevirtual

Inverse T gate.

Applies an inverse 1/8 phase rotation to the qubit at "qubitIndex."

◆ IU2()

virtual void Qrack::QInterface::IU2 ( bitLenInt  target,
real1_f  phi,
real1_f  lambda 
)
inlinevirtual

Inverse 2-parameter unitary gate.

Applies the inverse of U2

◆ M()

virtual bool Qrack::QInterface::M ( bitLenInt  qubitIndex)
inlinevirtual

Measurement gate.

Measures the qubit at "qubitIndex" and returns either "true" or "false." (This "gate" breaks unitarity.)

All physical evolution of a quantum state should be "unitary," except measurement. Measurement of a qubit "collapses" the quantum state into either only permutation states consistent with a |0> state for the bit, or else only permutation states consistent with a |1> state for the bit. Measurement also effectively multiplies the overall quantum state vector of the system by a random phase factor, equiprobable over all possible phase angles.

Effectively, when a bit measurement is emulated, Qrack calculates the norm of all permutation state components, to find their respective probabilities. The probabilities of all states in which the measured bit is "0" can be summed to give the probability of the bit being "0," and separately the probabilities of all states in which the measured bit is "1" can be summed to give the probability of the bit being "1." To simulate measurement, a random float between 0 and 1 is compared to the sum of the probability of all permutation states in which the bit is equal to "1". Depending on whether the random float is higher or lower than the probability, the qubit is determined to be either |0> or |1>, (up to phase). If the bit is determined to be |1>, then all permutation eigenstates in which the bit would be equal to |0> have their probability set to zero, and vice versa if the bit is determined to be |0>. Then, all remaining permutation states with nonzero probability are linearly rescaled so that the total probability of all permutation states is again "normalized" to exactly 100% or 1, (within double precision rounding error). Physically, the act of measurement should introduce an overall random phase factor on the state vector, which is emulated by generating another constantly distributed random float to select a phase angle between 0 and 2 * Pi.

Measurement breaks unitary evolution of state. All quantum gates except measurement should generally act as a unitary matrix on a permutation state vector. (Note that Boolean comparison convenience methods in Qrack such as "AND," "OR," and "XOR" employ the measurement operation in the act of first clearing output bits before filling them with the result of comparison, and these convenience methods therefore break unitary evolution of state, but in a physically realistic way. Comparable unitary operations would be performed with a combination of X and CCNOT gates, also called "Toffoli" gates, but the output bits would have to be assumed to be in a known fixed state, like all |0>, ahead of time to produce unitary logical comparison operations.)

Reimplemented in Qrack::QUnit, Qrack::QStabilizerHybrid, Qrack::QEngine, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ MACInvert() [1/2]

virtual void Qrack::QInterface::MACInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ MACInvert() [2/2]

virtual void Qrack::QUnit::MACInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented from Qrack::QInterface.

◆ MACMtrx() [1/2]

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

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

Reimplemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, Qrack::QPager, Qrack::QHybrid, Qrack::QBdtHybrid, Qrack::QBdt, Qrack::QUnitClifford, and Qrack::QEngine.

◆ MACMtrx() [2/2]

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

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

Reimplemented from Qrack::QInterface.

◆ MACPhase() [1/2]

virtual void Qrack::QInterface::MACPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target 
)
inlinevirtual

Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits.

Reimplemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, and Qrack::QUnitClifford.

◆ MACPhase() [2/2]

virtual void Qrack::QUnit::MACPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target 
)
inlinevirtual

Apply a single bit transformation that only effects phase, with arbitrary (anti-)control bits.

Reimplemented from Qrack::QInterface.

◆ MAll()

bitCapInt Qrack::QUnit::MAll ( )
virtual

Measure permutation state of all coherent bits.

Reimplemented from Qrack::QInterface.

◆ MCInvert() [1/2]

virtual void Qrack::QInterface::MCInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, Qrack::QBdt, and Qrack::QUnitClifford.

◆ MCInvert() [2/2]

virtual void Qrack::QUnit::MCInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented from Qrack::QInterface.

◆ MCMtrx() [1/2]

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

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

Implements Qrack::QInterface.

◆ MCMtrx() [2/2]

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

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

Implemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, Qrack::QPager, Qrack::QHybrid, Qrack::QBdtHybrid, Qrack::QBdt, Qrack::QUnitClifford, and Qrack::QEngine.

◆ MCPhase() [1/2]

virtual void Qrack::QInterface::MCPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QStabilizer, Qrack::QBdt, and Qrack::QUnitClifford.

◆ MCPhase() [2/2]

virtual void Qrack::QUnit::MCPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target 
)
inlinevirtual

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

Reimplemented from Qrack::QInterface.

◆ Mtrx() [1/2]

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

Apply an arbitrary single bit unitary transformation.

Implements Qrack::QInterface.

◆ Mtrx() [2/2]

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

◆ MultiShotMeasureMask() [1/2]

std::map< bitCapInt, int > Qrack::QUnit::MultiShotMeasureMask ( const std::vector< bitCapInt > &  qPowers,
unsigned  shots 
)
virtual

Statistical measure of masked permutation probability.

"qPowers" contains powers of 2^n, each representing QInterface bit "n." The order of these values defines a mask for the result bitCapInt, of 2^0 ~ qPowers[0U] to 2^(qPowerCount - 1) ~ qPowers[qPowerCount - 1], in contiguous ascending order. "shots" specifies the number of samples to take as if totally re-preparing the pre-measurement state. This method returns a dictionary with keys, which are the (masked-order) measurement results, and values, which are the number of "shots" that produced that particular measurement result. This method does not "collapse" the state of this QInterface. (The idea is to efficiently simulate a potentially statistically random sample of multiple re-preparations of the state right before measurement, and to collect random measurement resutls, without forcing the user to re-prepare or "clone" the state.)

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ MultiShotMeasureMask() [2/2]

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

Statistical measure of masked permutation probability (returned as array)

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

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ Phase() [1/2]

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

Apply a single bit transformation that only effects phase.

Reimplemented from Qrack::QInterface.

◆ Phase() [2/2]

virtual void Qrack::QInterface::Phase ( const complex  topLeft,
const complex  bottomRight,
bitLenInt  qubitIndex 
)
inlinevirtual

Apply a single bit transformation that only effects phase.

Reimplemented in Qrack::QStabilizer, Qrack::QUnitClifford, Qrack::QUnit, Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, and Qrack::QBdtHybrid.

◆ PhaseParity() [1/2]

void Qrack::QUnit::PhaseParity ( real1  radians,
bitCapInt  mask 
)
virtual

◆ PhaseParity() [2/2]

void Qrack::QInterface::PhaseParity ( real1_f  radians,
bitCapInt  mask 
)
virtual

Parity phase gate.

Applies e^(i*angle) phase factor to all combinations of bits with odd parity, based upon permutations of qubits.

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

◆ PhaseRootN()

virtual void Qrack::QInterface::PhaseRootN ( bitLenInt  n,
bitLenInt  qubit 
)
inlinevirtual

"PhaseRootN" gate

Applies a 1/(2^N) phase rotation to the qubit at "qubitIndex."

◆ S() [1/2]

virtual void Qrack::QInterface::S ( bitLenInt  qubit)
inlinevirtual

S gate.

Applies a 1/4 phase rotation to the qubit at "qubitIndex."

Reimplemented in Qrack::QUnit, Qrack::QUnitClifford, and Qrack::QStabilizer.

◆ S() [2/2]

void Qrack::QUnit::S ( bitLenInt  qubit)
virtual

S gate.

Applies a 1/4 phase rotation to the qubit at "qubitIndex."

Reimplemented from Qrack::QInterface.

◆ SH()

virtual void Qrack::QInterface::SH ( bitLenInt  qubit)
inlinevirtual

Y-basis transformation gate.

Converts from Pauli Z basis to Y, (via H then S gates).

◆ SqrtH()

virtual void Qrack::QInterface::SqrtH ( bitLenInt  qubit)
inlinevirtual

Square root of Hadamard gate.

Applies the square root of the Hadamard gate on qubit at "qubitIndex."

◆ SqrtW()

virtual void Qrack::QInterface::SqrtW ( bitLenInt  qubit)
inlinevirtual

Square root of W gate.

Per 2019 Arute, Google's "quantum supremacy" experiment

◆ SqrtX()

virtual void Qrack::QInterface::SqrtX ( bitLenInt  qubit)
inlinevirtual

Square root of X gate.

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

◆ SqrtY()

virtual void Qrack::QInterface::SqrtY ( bitLenInt  qubit)
inlinevirtual

Square root of Y gate.

Applies the square root of the Pauli "Y" operator to the qubit at "qubitIndex." The Pauli "Y" operator is similar to a logical "NOT" with permutation phase effects.

◆ T()

virtual void Qrack::QInterface::T ( bitLenInt  qubit)
inlinevirtual

T gate.

Applies a 1/8 phase rotation to the qubit at "qubitIndex."

◆ TimeEvolve()

void Qrack::QInterface::TimeEvolve ( Hamiltonian  h,
real1_f  timeDiff 
)
virtual

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.

Warning
Hamiltonian components might not commute.

As a general point of linear algebra, where A and B are linear operators,

\begin{equation}e^{i (A + B) t} = e^{i A t} e^{i B t} \end{equation}

might NOT hold, if the operators A and B do not commute. As a rule of thumb, A will commute with B at least in the case that A and B act on entirely different sets of qubits. However, for defining the intended Hamiltonian, the programmer can be guaranteed that the exponential factors will be applied right-to-left, by left multiplication, in the order

\begin{equation} e^{-i H_{N - 1} t} e^{-i H_{N - 2} t} \ldots e^{-i H_0 t} \left|\psi \rangle\right. .\end{equation}

(For example, if A and B are single bit gates acting on the same bit, form their composition into one gate by the intended right-to-left fusion and apply them as a single HamiltonianOp.)

◆ U()

void Qrack::QInterface::U ( bitLenInt  target,
real1_f  theta,
real1_f  phi,
real1_f  lambda 
)
virtual

General unitary gate.

Applies a gate guaranteed to be unitary, from three angles, as commonly defined, spanning all possible single bit unitary gates, (up to a global phase factor which has no effect on Hermitian operator expectation values).

◆ U2()

virtual void Qrack::QInterface::U2 ( bitLenInt  target,
real1_f  phi,
real1_f  lambda 
)
inlinevirtual

2-parameter unitary gate

Applies a gate guaranteed to be unitary, from two angles, as commonly defined.

◆ UCInvert() [1/2]

void Qrack::QUnit::UCInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target,
bitCapInt  perm 
)
virtual

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

Reimplemented from Qrack::QInterface.

◆ UCInvert() [2/2]

virtual void Qrack::QInterface::UCInvert ( const std::vector< bitLenInt > &  controls,
complex  topRight,
complex  bottomLeft,
bitLenInt  target,
bitCapInt  perm 
)
inlinevirtual

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

Reimplemented in Qrack::QUnit.

◆ UCMtrx() [1/2]

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

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

Reimplemented in Qrack::QUnit, and Qrack::QEngine.

◆ UCMtrx() [2/2]

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

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

Reimplemented from Qrack::QInterface.

◆ UCPhase() [1/2]

void Qrack::QUnit::UCPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target,
bitCapInt  perm 
)
virtual

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

Reimplemented from Qrack::QInterface.

◆ UCPhase() [2/2]

virtual void Qrack::QInterface::UCPhase ( const std::vector< bitLenInt > &  controls,
complex  topLeft,
complex  bottomRight,
bitLenInt  target,
bitCapInt  perm 
)
inlinevirtual

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

Reimplemented in Qrack::QUnit.

◆ UniformlyControlledSingleBit() [1/3]

virtual void Qrack::QInterface::UniformlyControlledSingleBit ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubitIndex,
const complex mtrxs 
)
inlinevirtual

Apply a "uniformly controlled" arbitrary single bit unitary transformation.

(See https://arxiv.org/abs/quant-ph/0312218)

A different unitary 2x2 complex matrix is associated with each permutation of the control bits. The first control bit index in the "controls" array is the least significant bit of the permutation, proceeding to the most significant bit. "mtrxs" is a flat (1-dimensional) array where each subsequent set of 4 components is an arbitrary 2x2 single bit gate associated with the next permutation of the control bits, starting from 0. All combinations of control bits apply one of the 4 component (flat 2x2) matrices. For k control bits, there are therefore 4 * 2^k complex components in "mtrxs," representing 2^k complex matrices of 2x2 components. (The component ordering in each matrix is the same as all other gates with an arbitrary 2x2 applied to a single bit, such as Qrack::ApplySingleBit.)

Reimplemented in Qrack::QStabilizerHybrid.

◆ UniformlyControlledSingleBit() [2/3]

void Qrack::QInterface::UniformlyControlledSingleBit ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubitIndex,
const complex mtrxs,
const std::vector< bitCapInt > &  mtrxSkipPowers,
bitCapInt  mtrxSkipValueMask 
)
virtual

◆ UniformlyControlledSingleBit() [3/3]

void Qrack::QUnit::UniformlyControlledSingleBit ( const std::vector< bitLenInt > &  controls,
bitLenInt  qubitIndex,
const complex mtrxs,
const std::vector< bitCapInt > &  mtrxSkipPowers,
bitCapInt  mtrxSkipValueMask 
)
virtual

Reimplemented from Qrack::QInterface.

◆ X()

virtual void Qrack::QInterface::X ( bitLenInt  qubit)
inlinevirtual

X gate.

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

Reimplemented in Qrack::QEngineOCL, Qrack::QEngineCUDA, Qrack::QUnitClifford, Qrack::QStabilizer, Qrack::QUnit, Qrack::QStabilizerHybrid, Qrack::QEngine, Qrack::QBdtHybrid, and Qrack::QBdt.

◆ XMask()

void Qrack::QInterface::XMask ( bitCapInt  mask)
virtual

Masked X gate.

Applies the Pauli "X" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)

0). The Pauli "X" operator is equivalent to a logical "NOT."

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

◆ Y()

virtual void Qrack::QInterface::Y ( bitLenInt  qubit)
inlinevirtual

Y gate.

Applies the Pauli "Y" operator to the qubit at "qubitIndex." The Pauli "Y" operator is similar to a logical "NOT" with permutation phase. effects.

Reimplemented in Qrack::QUnitClifford, and Qrack::QStabilizer.

◆ YMask()

void Qrack::QInterface::YMask ( bitCapInt  mask)
virtual

Masked Y gate.

Applies the Pauli "Y" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)

0). The Pauli "Y" operator is similar to a logical "NOT" with permutation phase.

Reimplemented in Qrack::QStabilizerHybrid.

◆ Z()

virtual void Qrack::QInterface::Z ( bitLenInt  qubit)
inlinevirtual

Z gate.

Applies the Pauli "Z" operator to the qubit at "qubitIndex." The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.

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

◆ ZMask() [1/2]

void Qrack::QInterface::ZMask ( bitCapInt  mask)
virtual

Masked Z gate.

Applies the Pauli "Z" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)

0). The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.

Reimplemented in Qrack::QUnit, Qrack::QStabilizerHybrid, Qrack::QPager, and Qrack::QEngine.

◆ ZMask() [2/2]

virtual void Qrack::QUnit::ZMask ( bitCapInt  mask)
inlinevirtual

Masked Z gate.

Applies the Pauli "Z" operator to all qubits in the mask. A qubit index "n" is in the mask if (((1 << n) & mask)

0). The Pauli "Z" operator reverses the phase of |1> and leaves |0> unchanged.

Reimplemented from Qrack::QInterface.