Qrack  9.0
General classical-emulating-quantum development framework
Functions
Utility functions
Collaboration diagram for Utility functions:

Functions

real1_f Qrack::QEngineCPU::Prob (bitLenInt qubitIndex)
 PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state. More...
 
real1_f Qrack::QEngineCPU::CtrlOrAntiProb (bool controlState, bitLenInt control, bitLenInt target)
 PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state, if control is in |0>/|1>, false/true, "controlState". More...
 
real1_f Qrack::QEngineCPU::ProbReg (bitLenInt start, bitLenInt length, bitCapInt permutation)
 Direct measure of register permutation probability. More...
 
real1_f Qrack::QEngineCPU::ProbMask (bitCapInt mask, bitCapInt permutation)
 Direct measure of masked permutation probability. More...
 
real1_f Qrack::QEngineCPU::ProbParity (bitCapInt mask)
 Overall probability of any odd permutation of the masked set of bits. More...
 
bitCapInt Qrack::QEngineCPU::MAll ()
 Measure permutation state of all coherent bits. More...
 
bool Qrack::QEngineCPU::ForceMParity (bitCapInt mask, bool result, bool doForce=true)
 Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result. More...
 
void Qrack::QEngineCPU::NormalizeState (real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)
 Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate. More...
 
real1_f Qrack::QEngineCPU::SumSqrDiff (QInterfacePtr toCompare)
 
real1_f Qrack::QEngineCPU::SumSqrDiff (QEngineCPUPtr toCompare)
 
QInterfacePtr Qrack::QEngineCPU::Clone ()
 Clone this QInterface. More...
 
virtual real1_f Qrack::QInterface::Prob (bitLenInt qubitIndex)=0
 Direct measure of bit probability to be in |1> state. More...
 
virtual real1_f Qrack::QInterface::CProb (bitLenInt control, bitLenInt target)
 Direct measure of bit probability to be in |1> state, if control bit is |1>. More...
 
virtual real1_f Qrack::QInterface::ACProb (bitLenInt control, bitLenInt target)
 Direct measure of bit probability to be in |1> state, if control bit is |0>. More...
 
virtual real1_f Qrack::QInterface::ProbAll (bitCapInt fullRegister)
 Direct measure of full permutation probability. More...
 
virtual real1_f Qrack::QInterface::ProbReg (bitLenInt start, bitLenInt length, bitCapInt permutation)
 Direct measure of register permutation probability. More...
 
virtual real1_f Qrack::QInterface::ProbMask (bitCapInt mask, bitCapInt permutation)
 Direct measure of masked permutation probability. More...
 
virtual void Qrack::QInterface::ProbMaskAll (bitCapInt mask, real1 *probsArray)
 Direct measure of masked permutation probability. More...
 
virtual void Qrack::QInterface::ProbBitsAll (const std::vector< bitLenInt > &bits, real1 *probsArray)
 Direct measure of listed permutation probability. More...
 
virtual real1_f Qrack::QInterface::ExpectationBitsAll (const std::vector< bitLenInt > &bits, bitCapInt offset=0U)
 Get permutation expectation value of bits. More...
 
virtual real1_f Qrack::QInterface::ExpectationBitsFactorized (const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U)
 Get expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f Qrack::QInterface::ExpectationBitsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0)
 Get (reduced density matrix) expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f Qrack::QInterface::ExpectationFloatsFactorized (const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Get expectation value of bits, given a (floating-point) array of qubit weights. More...
 
virtual real1_f Qrack::QInterface::ExpectationFloatsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< real1_f > &weights)
 Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weights. More...
 
virtual real1_f Qrack::QInterface::ProbRdm (bitLenInt qubitIndex)
 Direct measure of bit probability to be in |1> state, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f Qrack::QInterface::ProbAllRdm (bool roundRz, bitCapInt fullRegister)
 Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f Qrack::QInterface::ProbMaskRdm (bool roundRz, bitCapInt mask, bitCapInt permutation)
 Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f Qrack::QInterface::ExpectationBitsAllRdm (bool roundRz, const std::vector< bitLenInt > &bits, bitCapInt offset=0U)
 Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual std::map< bitCapInt, int > Qrack::QInterface::MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots)
 Statistical measure of masked permutation probability. More...
 
virtual void Qrack::QInterface::MultiShotMeasureMask (const std::vector< bitCapInt > &qPowers, unsigned shots, unsigned long long *shotsArray)
 Statistical measure of masked permutation probability (returned as array) More...
 
virtual void Qrack::QInterface::SetBit (bitLenInt qubit, bool value)
 Set individual bit to pure |0> (false) or |1> (true) state. More...
 
virtual bool Qrack::QInterface::ApproxCompare (QInterfacePtr toCompare, real1_f error_tol=TRYDECOMPOSE_EPSILON)
 Compare state vectors approximately, component by component, to determine whether this state vector is the same as the target. More...
 
virtual real1_f Qrack::QInterface::SumSqrDiff (QInterfacePtr toCompare)=0
 
virtual bool Qrack::QInterface::TryDecompose (bitLenInt start, QInterfacePtr dest, real1_f error_tol=TRYDECOMPOSE_EPSILON)
 
virtual void Qrack::QInterface::UpdateRunningNorm (real1_f norm_thresh=REAL1_DEFAULT_ARG)=0
 Force a calculation of the norm of the state vector, in order to make it unit length before the next probability or measurement operation. More...
 
virtual void Qrack::QInterface::NormalizeState (real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)=0
 Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate. More...
 
virtual void Qrack::QInterface::Finish ()
 If asynchronous work is still running, block until it finishes. More...
 
virtual bool Qrack::QInterface::isFinished ()
 Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done. More...
 
virtual void Qrack::QInterface::Dump ()
 If asynchronous work is still running, let the simulator know that it can be aborted. More...
 
virtual bool Qrack::QInterface::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 Qrack::QInterface::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 Qrack::QInterface::isClifford (bitLenInt qubit)
 Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is not or cannot be determined. More...
 
virtual bool Qrack::QInterface::isOpenCL ()
 Returns "true" if current simulation is OpenCL-based. More...
 
virtual bool Qrack::QInterface::TrySeparate (const std::vector< bitLenInt > &qubits, real1_f error_tol)
 Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed. More...
 
virtual bool Qrack::QInterface::TrySeparate (bitLenInt qubit)
 Single-qubit TrySeparate() More...
 
virtual bool Qrack::QInterface::TrySeparate (bitLenInt qubit1, bitLenInt qubit2)
 Two-qubit TrySeparate() More...
 
virtual double Qrack::QInterface::GetUnitaryFidelity ()
 When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1.0 fidelity, we compound the "unitary fidelity" by successive multiplication by one minus two times the true unitary probability discarded in each single rounding event. More...
 
virtual void Qrack::QInterface::ResetUnitaryFidelity ()
 Reset the internal fidelity calculation tracker to 1.0. More...
 
virtual void Qrack::QInterface::SetSdrp (real1_f sdrp)
 Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1) More...
 
virtual void Qrack::QInterface::SetReactiveSeparate (bool isAggSep)
 Set reactive separation option (on by default if available) More...
 
virtual bool Qrack::QInterface::GetReactiveSeparate ()
 Get reactive separation option. More...
 
virtual void Qrack::QInterface::SetTInjection (bool useGadget)
 Set the option to use T-injection gadgets (off by default) More...
 
virtual bool Qrack::QInterface::GetTInjection ()
 Get the option to use T-injection gadgets. More...
 
virtual QInterfacePtr Qrack::QInterface::Clone ()=0
 Clone this QInterface. More...
 
virtual void Qrack::QInterface::SetDevice (int64_t dID)=0
 Set the device index, if more than one device is available. More...
 
virtual int64_t Qrack::QInterface::GetDevice ()
 Get the device index. More...
 
bitCapIntOcl Qrack::QInterface::GetMaxSize ()
 Get maximum number of amplitudes that can be allocated on current device. More...
 
virtual real1_f Qrack::QInterface::FirstNonzeroPhase ()
 Get phase of lowest permutation nonzero amplitude. More...
 
virtual void Qrack::QInterface::DepolarizingChannelWeak1Qb (bitLenInt qubit, real1_f lambda)
 Simulate a local qubit depolarizing noise channel, under a stochastic "weak simulation condition." Under "weak" condition, sampling and exact state queries are not accurate, but sampling can be achieved via repeated full execution of a noisy circuit, for each hardware-realistic measurement sample. More...
 
virtual bitLenInt Qrack::QInterface::DepolarizingChannelStrong1Qb (bitLenInt qubit, real1_f lambda)
 Simulate a local qubit depolarizing noise channel, under a "strong simulation condition." "Strong" condition supports measurement sampling and direct queries of state, but the expression of state is in terms of one retained ancillary qubit per applied noise channel. More...
 
virtual real1_f Qrack::QUnit::Prob (bitLenInt qubit)
 Direct measure of bit probability to be in |1> state. More...
 
virtual real1_f Qrack::QUnit::ProbAll (bitCapInt perm)
 Direct measure of full permutation probability. More...
 
virtual real1_f Qrack::QUnit::ProbAllRdm (bool roundRz, bitCapInt perm)
 Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets. More...
 
virtual real1_f Qrack::QUnit::ProbParity (bitCapInt mask)
 Overall probability of any odd permutation of the masked set of bits. More...
 
virtual bool Qrack::QUnit::ForceMParity (bitCapInt mask, bool result, bool doForce=true)
 Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result. More...
 
virtual real1_f Qrack::QUnit::SumSqrDiff (QInterfacePtr toCompare)
 
virtual real1_f Qrack::QUnit::SumSqrDiff (QUnitPtr toCompare)
 
virtual real1_f Qrack::QUnit::ExpectationBitsFactorized (const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U)
 Get expectation value of bits, given an array of qubit weights. More...
 
virtual real1_f Qrack::QUnit::ExpectationBitsFactorizedRdm (bool roundRz, const std::vector< bitLenInt > &bits, const std::vector< bitCapInt > &perms, bitCapInt offset=0U)
 Get (reduced density matrix) expectation value of bits, given an array of qubit weights. More...
 
virtual void Qrack::QUnit::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 void Qrack::QUnit::NormalizeState (real1_f nrm=REAL1_DEFAULT_ARG, real1_f norm_thresh=REAL1_DEFAULT_ARG, real1_f phaseArg=ZERO_R1_F)
 Apply the normalization factor found by UpdateRunningNorm() or on the fly by a single bit gate. More...
 
virtual void Qrack::QUnit::Finish ()
 If asynchronous work is still running, block until it finishes. More...
 
virtual bool Qrack::QUnit::isFinished ()
 Returns "false" if asynchronous work is still running, and "true" if all previously dispatched asynchronous work is done. More...
 
virtual void Qrack::QUnit::Dump ()
 If asynchronous work is still running, let the simulator know that it can be aborted. More...
 
virtual bool Qrack::QUnit::isClifford (bitLenInt qubit)
 Returns "true" if current qubit state is identifiably within the Clifford set, or "false" if it is not or cannot be determined. More...
 
virtual bool Qrack::QUnit::TrySeparate (const std::vector< bitLenInt > &qubits, real1_f error_tol)
 Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed. More...
 
virtual bool Qrack::QUnit::TrySeparate (bitLenInt qubit)
 Single-qubit TrySeparate() More...
 
virtual bool Qrack::QUnit::TrySeparate (bitLenInt qubit1, bitLenInt qubit2)
 Two-qubit TrySeparate() More...
 
virtual double Qrack::QUnit::GetUnitaryFidelity ()
 When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1.0 fidelity, we compound the "unitary fidelity" by successive multiplication by one minus two times the true unitary probability discarded in each single rounding event. More...
 
virtual void Qrack::QUnit::ResetUnitaryFidelity ()
 Reset the internal fidelity calculation tracker to 1.0. More...
 
virtual void Qrack::QUnit::SetSdrp (real1_f sdrp)
 Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1) More...
 
virtual QInterfacePtr Qrack::QUnit::Clone ()
 Clone this QInterface. More...
 

Detailed Description

Function Documentation

◆ ACProb()

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

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

Warning
PSEUDO-QUANTUM

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

◆ ApproxCompare()

virtual bool Qrack::QInterface::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 in Qrack::QUnitClifford, Qrack::QStabilizerHybrid, and Qrack::QStabilizer.

◆ Clone() [1/3]

QInterfacePtr Qrack::QEngineCPU::Clone ( )
virtual

Clone this QInterface.

Implements Qrack::QInterface.

◆ Clone() [2/3]

QInterfacePtr Qrack::QUnit::Clone ( )
virtual

Clone this QInterface.

Implements Qrack::QInterface.

Reimplemented in Qrack::QUnitMulti.

◆ Clone() [3/3]

virtual QInterfacePtr Qrack::QInterface::Clone ( )
pure virtual

◆ CProb()

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

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

Warning
PSEUDO-QUANTUM

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

◆ CtrlOrAntiProb()

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

PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state, if control is in |0>/|1>, false/true, "controlState".

Reimplemented from Qrack::QEngine.

◆ DepolarizingChannelStrong1Qb()

bitLenInt Qrack::QInterface::DepolarizingChannelStrong1Qb ( bitLenInt  qubit,
real1_f  lambda 
)
virtual

Simulate a local qubit depolarizing noise channel, under a "strong simulation condition." "Strong" condition supports measurement sampling and direct queries of state, but the expression of state is in terms of one retained ancillary qubit per applied noise channel.

condition, sampling and exact state queries are not accurate, but sampling can be achieved via repeated full execution of a noisy circuit, for each hardware-realistic measurement sample.

This method returns a newly-allocated qubit ancilla index which must be retained to maintain "strong" simulation. Note that "strong" ancilla can be measured at any time and discarded, but this makes the simulation condition "weak".

◆ DepolarizingChannelWeak1Qb()

void Qrack::QInterface::DepolarizingChannelWeak1Qb ( bitLenInt  qubit,
real1_f  lambda 
)
virtual

Simulate a local qubit depolarizing noise channel, under a stochastic "weak simulation condition." Under "weak" condition, sampling and exact state queries are not accurate, but sampling can be achieved via repeated full execution of a noisy circuit, for each hardware-realistic measurement sample.

◆ Dump() [1/2]

virtual void Qrack::QInterface::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 in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QPager, Qrack::QHybrid, Qrack::QEngineCPU, and Qrack::QBdtHybrid.

◆ Dump() [2/2]

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

◆ ExpectationBitsAll()

virtual real1_f Qrack::QInterface::ExpectationBitsAll ( const std::vector< bitLenInt > &  bits,
bitCapInt  offset = 0U 
)
inlinevirtual

Get permutation expectation value of bits.

The permutation expectation value of all included bits is returned, with bits valued from low to high as the order of the "bits" array parameter argument.

Warning
PSEUDO-QUANTUM

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

◆ ExpectationBitsAllRdm()

virtual real1_f Qrack::QInterface::ExpectationBitsAllRdm ( bool  roundRz,
const std::vector< bitLenInt > &  bits,
bitCapInt  offset = 0U 
)
inlinevirtual

Get permutation expectation value of bits, treating all ancillary qubits as post-selected T gate gadgets.

The permutation expectation value of all included bits is returned, with bits valued from low to high as the order of the "bits" array parameter argument.

Warning
PSEUDO-QUANTUM

Reimplemented in Qrack::QStabilizerHybrid.

◆ ExpectationBitsFactorized() [1/2]

real1_f Qrack::QInterface::ExpectationBitsFactorized ( const std::vector< bitLenInt > &  bits,
const std::vector< bitCapInt > &  perms,
bitCapInt  offset = 0U 
)
virtual

Get expectation value of bits, given an array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry.

Warning
PSEUDO-QUANTUM

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

◆ ExpectationBitsFactorized() [2/2]

virtual real1_f Qrack::QUnit::ExpectationBitsFactorized ( const std::vector< bitLenInt > &  bits,
const std::vector< bitCapInt > &  perms,
bitCapInt  offset = 0U 
)
inlinevirtual

Get expectation value of bits, given an array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ExpectationBitsFactorizedRdm() [1/2]

virtual real1_f Qrack::QInterface::ExpectationBitsFactorizedRdm ( bool  roundRz,
const std::vector< bitLenInt > &  bits,
const std::vector< bitCapInt > &  perms,
bitCapInt  offset = 0 
)
inlinevirtual

Get (reduced density matrix) expectation value of bits, given an array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry. If there are stabilizer ancillae, they are traced out of the reduced density matrix, giving an approximate result.

Warning
PSEUDO-QUANTUM

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

◆ ExpectationBitsFactorizedRdm() [2/2]

virtual real1_f Qrack::QUnit::ExpectationBitsFactorizedRdm ( bool  roundRz,
const std::vector< bitLenInt > &  bits,
const std::vector< bitCapInt > &  perms,
bitCapInt  offset = 0U 
)
inlinevirtual

Get (reduced density matrix) expectation value of bits, given an array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "perms" weight entry. If there are stabilizer ancillae, they are traced out of the reduced density matrix, giving an approximate result.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ExpectationFloatsFactorized()

real1_f Qrack::QInterface::ExpectationFloatsFactorized ( const std::vector< bitLenInt > &  bits,
const std::vector< real1_f > &  weights 
)
virtual

Get expectation value of bits, given a (floating-point) array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "weights" entry.

Warning
PSEUDO-QUANTUM

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

◆ ExpectationFloatsFactorizedRdm()

virtual real1_f Qrack::QInterface::ExpectationFloatsFactorizedRdm ( bool  roundRz,
const std::vector< bitLenInt > &  bits,
const std::vector< real1_f > &  weights 
)
inlinevirtual

Get (reduced density matrix) expectation value of bits, given a (floating-point) array of qubit weights.

The weighter-per-qubit expectation value of is returned, with each "bits" entry corresponding to a "weights" entry. If there are stabilizer ancillae, they are traced out of the reduced density matrix, giving an approximate result.

Warning
PSEUDO-QUANTUM

Reimplemented in Qrack::QStabilizerHybrid.

◆ Finish() [1/2]

virtual void Qrack::QInterface::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 in Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, Qrack::QPager, Qrack::QHybrid, Qrack::QEngineOCL, Qrack::QEngineCUDA, Qrack::QEngineCPU, and Qrack::QBdtHybrid.

◆ Finish() [2/2]

void Qrack::QUnit::Finish ( )
virtual

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

virtual real1_f Qrack::QInterface::FirstNonzeroPhase ( )
inlinevirtual

Get phase of lowest permutation nonzero amplitude.

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

◆ ForceMParity() [1/2]

bool Qrack::QEngineCPU::ForceMParity ( bitCapInt  mask,
bool  result,
bool  doForce = true 
)
virtual

Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result.

Warning
PSEUDO-QUANTUM

Implements Qrack::QParity.

◆ ForceMParity() [2/2]

bool Qrack::QUnit::ForceMParity ( bitCapInt  mask,
bool  result,
bool  doForce = true 
)
virtual

Act as if is a measurement of parity of the masked set of qubits was applied, except force the (usually random) result.

Warning
PSEUDO-QUANTUM

Implements Qrack::QParity.

◆ GetDevice()

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

Get the device index.

("-1" is default).

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

◆ GetMaxSize()

bitCapIntOcl Qrack::QInterface::GetMaxSize ( )
inline

Get maximum number of amplitudes that can be allocated on current device.

◆ GetReactiveSeparate()

virtual bool Qrack::QInterface::GetReactiveSeparate ( )
inlinevirtual

Get reactive separation option.

If reactive separation is available, as in Qrack::QUnit, then turning this option on attempts to more-aggresively recover separability of subsystems. It can either hurt or help performance, though it commonly helps.

Reimplemented in Qrack::QUnit.

◆ GetTInjection()

virtual bool Qrack::QInterface::GetTInjection ( )
inlinevirtual

Get the option to use T-injection gadgets.

If T-injection gadgets are available, as in Qrack::QStabilizerHybrid, then turning this option on attempts to simulate Clifford+T with polynomial resource gadgets. It can either hurt or help performance, though it commonly helps.

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

◆ GetUnitaryFidelity() [1/2]

virtual double Qrack::QInterface::GetUnitaryFidelity ( )
inlinevirtual

When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1.0 fidelity, we compound the "unitary fidelity" by successive multiplication by one minus two times the true unitary probability discarded in each single rounding event.

Then, an overall square-root is applied to the final fidelity estimate. This is a useful metric on fidelity that requires no heavy calculational overhead to compute, and it tends to be usually only slightly pessimistic compared to random circuit sampling fidelity calculated via the inner product. This calculation is automatically reset to 1.0 by SetPermutation() or MAll() or can be manually reset by "QInterface::ResetUnitaryFidelity()".

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

◆ GetUnitaryFidelity() [2/2]

virtual double Qrack::QUnit::GetUnitaryFidelity ( )
inlinevirtual

When "Schmidt-decomposition rounding parameter" ("SDRP") is being used, starting from initial 1.0 fidelity, we compound the "unitary fidelity" by successive multiplication by one minus two times the true unitary probability discarded in each single rounding event.

Then, an overall square-root is applied to the final fidelity estimate. This is a useful metric on fidelity that requires no heavy calculational overhead to compute, and it tends to be usually only slightly pessimistic compared to random circuit sampling fidelity calculated via the inner product. This calculation is automatically reset to 1.0 by SetPermutation() or MAll() or can be manually reset by "QInterface::ResetUnitaryFidelity()".

Reimplemented from Qrack::QInterface.

◆ isBinaryDecisionTree()

virtual bool Qrack::QInterface::isBinaryDecisionTree ( )
inlinevirtual

Returns "true" if current state representation is definitely a binary decision tree, "false" if it is definitely not, or "true" if it cannot be determined.

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

◆ isClifford() [1/3]

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

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

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

◆ isClifford() [2/3]

virtual bool Qrack::QInterface::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 in Qrack::QUnitClifford, Qrack::QUnit, Qrack::QStabilizerHybrid, and Qrack::QStabilizer.

◆ isClifford() [3/3]

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

◆ isFinished() [1/2]

virtual bool Qrack::QInterface::isFinished ( )
inlinevirtual

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

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

◆ isFinished() [2/2]

bool Qrack::QUnit::isFinished ( )
virtual

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

Reimplemented from Qrack::QInterface.

◆ isOpenCL()

virtual bool Qrack::QInterface::isOpenCL ( )
inlinevirtual

Returns "true" if current simulation is OpenCL-based.

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

◆ MAll()

bitCapInt Qrack::QEngineCPU::MAll ( )
virtual

Measure permutation state of all coherent bits.

Reimplemented from Qrack::QInterface.

◆ MultiShotMeasureMask() [1/2]

std::map< bitCapInt, int > Qrack::QInterface::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 in Qrack::QUnitClifford, Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, and Qrack::QEngine.

◆ MultiShotMeasureMask() [2/2]

void Qrack::QInterface::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 in Qrack::QUnitClifford, Qrack::QUnit, Qrack::QTensorNetwork, Qrack::QStabilizerHybrid, and Qrack::QEngine.

◆ NormalizeState() [1/3]

void Qrack::QEngineCPU::NormalizeState ( real1_f  nrm = REAL1_DEFAULT_ARG,
real1_f  norm_thresh = REAL1_DEFAULT_ARG,
real1_f  phaseArg = ZERO_R1_F 
)
virtual

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

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

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ NormalizeState() [2/3]

void Qrack::QUnit::NormalizeState ( real1_f  nrm = REAL1_DEFAULT_ARG,
real1_f  norm_thresh = REAL1_DEFAULT_ARG,
real1_f  phaseArg = ZERO_R1_F 
)
virtual

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

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

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ NormalizeState() [3/3]

virtual void Qrack::QInterface::NormalizeState ( real1_f  nrm = REAL1_DEFAULT_ARG,
real1_f  norm_thresh = REAL1_DEFAULT_ARG,
real1_f  phaseArg = ZERO_R1_F 
)
pure virtual

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

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

Warning
PSEUDO-QUANTUM

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

◆ Prob() [1/3]

virtual real1_f Qrack::QUnit::Prob ( bitLenInt  qubitIndex)
inlinevirtual

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

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

◆ Prob() [2/3]

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

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

Implements Qrack::QInterface.

◆ Prob() [3/3]

virtual real1_f Qrack::QInterface::Prob ( bitLenInt  qubitIndex)
pure virtual

◆ ProbAll() [1/2]

virtual real1_f Qrack::QInterface::ProbAll ( bitCapInt  fullRegister)
inlinevirtual

Direct measure of full permutation probability.

Warning
PSEUDO-QUANTUM

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

◆ ProbAll() [2/2]

virtual real1_f Qrack::QUnit::ProbAll ( bitCapInt  fullRegister)
inlinevirtual

Direct measure of full permutation probability.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ProbAllRdm() [1/2]

virtual real1_f Qrack::QInterface::ProbAllRdm ( bool  roundRz,
bitCapInt  fullRegister 
)
inlinevirtual

Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets.

Warning
PSEUDO-QUANTUM

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

◆ ProbAllRdm() [2/2]

virtual real1_f Qrack::QUnit::ProbAllRdm ( bool  roundRz,
bitCapInt  fullRegister 
)
inlinevirtual

Direct measure of full permutation probability, treating all ancillary qubits as post-selected T gate gadgets.

Warning
PSEUDO-QUANTUM

Reimplemented from Qrack::QInterface.

◆ ProbBitsAll()

void Qrack::QInterface::ProbBitsAll ( const std::vector< bitLenInt > &  bits,
real1 probsArray 
)
virtual

Direct measure of listed permutation probability.

The probabilities of all included permutations of bits, with bits valued from low to high as the order of the "bits" array parameter argument, are returned in the "probsArray" parameter.

Warning
PSEUDO-QUANTUM

◆ ProbMask() [1/2]

real1_f Qrack::QEngineCPU::ProbMask ( bitCapInt  mask,
bitCapInt  permutation 
)
virtual

Direct measure of masked permutation probability.

Returns probability of permutation of the mask.

"mask" masks the bits to check the probability of. "permutation" sets the 0 or 1 value for each bit in the mask. Bits which are set in the mask can be set to 0 or 1 in the permutation, while reset bits in the mask should be 0 in the permutation.

Warning
PSEUDO-QUANTUM

Implements Qrack::QEngine.

◆ ProbMask() [2/2]

real1_f Qrack::QInterface::ProbMask ( bitCapInt  mask,
bitCapInt  permutation 
)
virtual

Direct measure of masked permutation probability.

Returns probability of permutation of the mask.

"mask" masks the bits to check the probability of. "permutation" sets the 0 or 1 value for each bit in the mask. Bits which are set in the mask can be set to 0 or 1 in the permutation, while reset bits in the mask should be 0 in the permutation.

Warning
PSEUDO-QUANTUM

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

◆ ProbMaskAll()

void Qrack::QInterface::ProbMaskAll ( bitCapInt  mask,
real1 probsArray 
)
virtual

Direct measure of masked permutation probability.

"mask" masks the bits to check the probability of. The probabilities of all permutations of the masked bits, from left/low to right/high are returned in the "probsArray" argument.

Warning
PSEUDO-QUANTUM

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

◆ ProbMaskRdm()

virtual real1_f Qrack::QInterface::ProbMaskRdm ( bool  roundRz,
bitCapInt  mask,
bitCapInt  permutation 
)
inlinevirtual

Direct measure of masked permutation probability, treating all ancillary qubits as post-selected T gate gadgets.

"mask" masks the bits to check the probability of. "permutation" sets the 0 or 1 value for each bit in the mask. Bits which are set in the mask can be set to 0 or 1 in the permutation, while reset bits in the mask should be 0 in the permutation.

Warning
PSEUDO-QUANTUM

Reimplemented in Qrack::QStabilizerHybrid.

◆ ProbParity() [1/2]

real1_f Qrack::QEngineCPU::ProbParity ( bitCapInt  mask)
virtual

Overall probability of any odd permutation of the masked set of bits.

Implements Qrack::QParity.

◆ ProbParity() [2/2]

real1_f Qrack::QUnit::ProbParity ( bitCapInt  mask)
virtual

Overall probability of any odd permutation of the masked set of bits.

Implements Qrack::QParity.

◆ ProbRdm()

virtual real1_f Qrack::QInterface::ProbRdm ( bitLenInt  qubitIndex)
inlinevirtual

Direct measure of bit probability to be in |1> state, treating all ancillary qubits as post-selected T gate gadgets.

Warning
PSEUDO-QUANTUM

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

◆ ProbReg() [1/2]

real1_f Qrack::QEngineCPU::ProbReg ( bitLenInt  start,
bitLenInt  length,
bitCapInt  permutation 
)
virtual

Direct measure of register permutation probability.

Returns probability of permutation of the register.

Warning
PSEUDO-QUANTUM

Implements Qrack::QEngine.

◆ ProbReg() [2/2]

real1_f Qrack::QInterface::ProbReg ( bitLenInt  start,
bitLenInt  length,
bitCapInt  permutation 
)
virtual

Direct measure of register permutation probability.

Returns probability of permutation of the register.

Warning
PSEUDO-QUANTUM

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

◆ ResetUnitaryFidelity() [1/2]

virtual void Qrack::QInterface::ResetUnitaryFidelity ( )
inlinevirtual

Reset the internal fidelity calculation tracker to 1.0.

Reimplemented in Qrack::QUnit.

◆ ResetUnitaryFidelity() [2/2]

virtual void Qrack::QUnit::ResetUnitaryFidelity ( )
inlinevirtual

Reset the internal fidelity calculation tracker to 1.0.

Reimplemented from Qrack::QInterface.

◆ SetBit()

virtual void Qrack::QInterface::SetBit ( bitLenInt  qubit,
bool  value 
)
inlinevirtual

Set individual bit to pure |0> (false) or |1> (true) state.

To set a bit, the bit is first measured. If the result of measurement matches "value," the bit is considered set. If the result of measurement is the opposite of "value," an X gate is applied to the bit. The state ends up entirely in the "value" state, with a random phase factor.

◆ SetDevice()

virtual void Qrack::QInterface::SetDevice ( int64_t  dID)
pure virtual

◆ SetReactiveSeparate()

virtual void Qrack::QInterface::SetReactiveSeparate ( bool  isAggSep)
inlinevirtual

Set reactive separation option (on by default if available)

If reactive separation is available, as in Qrack::QUnit, then turning this option on attempts to more-aggresively recover separability of subsystems. It can either hurt or help performance, though it commonly helps.

Reimplemented in Qrack::QUnit.

◆ SetSdrp() [1/2]

virtual void Qrack::QInterface::SetSdrp ( real1_f  sdrp)
inlinevirtual

Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1)

Reimplemented in Qrack::QUnit.

◆ SetSdrp() [2/2]

virtual void Qrack::QUnit::SetSdrp ( real1_f  sdrp)
inlinevirtual

Set the "Schmidt decomposition rounding parameter" value, (between 0 and 1)

Reimplemented from Qrack::QInterface.

◆ SetTInjection()

virtual void Qrack::QInterface::SetTInjection ( bool  useGadget)
inlinevirtual

Set the option to use T-injection gadgets (off by default)

If T-injection gadgets are available, as in Qrack::QStabilizerHybrid, then turning this option on attempts to simulate Clifford+T with polynomial resource gadgets. It can either hurt or help performance, though it commonly helps.

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

◆ SumSqrDiff() [1/5]

real1_f Qrack::QEngineCPU::SumSqrDiff ( QEngineCPUPtr  toCompare)

◆ SumSqrDiff() [2/5]

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

Implements Qrack::QInterface.

◆ SumSqrDiff() [3/5]

virtual real1_f Qrack::QUnit::SumSqrDiff ( QInterfacePtr  toCompare)
inlinevirtual

Implements Qrack::QInterface.

◆ SumSqrDiff() [4/5]

virtual real1_f Qrack::QInterface::SumSqrDiff ( QInterfacePtr  toCompare)
pure virtual

◆ SumSqrDiff() [5/5]

real1_f Qrack::QUnit::SumSqrDiff ( QUnitPtr  toCompare)
virtual

◆ TryDecompose()

bool Qrack::QInterface::TryDecompose ( bitLenInt  start,
QInterfacePtr  dest,
real1_f  error_tol = TRYDECOMPOSE_EPSILON 
)
virtual

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

◆ TrySeparate() [1/6]

virtual bool Qrack::QInterface::TrySeparate ( bitLenInt  qubit)
inlinevirtual

◆ TrySeparate() [2/6]

bool Qrack::QUnit::TrySeparate ( bitLenInt  qubit)
virtual

Single-qubit TrySeparate()

Reimplemented from Qrack::QInterface.

◆ TrySeparate() [3/6]

virtual bool Qrack::QInterface::TrySeparate ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
inlinevirtual

◆ TrySeparate() [4/6]

bool Qrack::QUnit::TrySeparate ( bitLenInt  qubit1,
bitLenInt  qubit2 
)
virtual

Two-qubit TrySeparate()

Reimplemented from Qrack::QInterface.

◆ TrySeparate() [5/6]

virtual bool Qrack::QInterface::TrySeparate ( const std::vector< bitLenInt > &  qubits,
real1_f  error_tol 
)
inlinevirtual

Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed.

This method is used to manually attempt internal separation of a QUnit subsytem. We attempt a Decompose() operation, on a state which might not be separable. If the state is not separable, we abort and return false. Otherwise, we complete the operation, add the separated subsystem back in place into the QUnit "shards," and return true.

Warning
PSEUDO-QUANTUM

This should never change the logical/physical state of the QInterface, only possibly its internal representation, for simulation optimization purposes. This is not a truly quantum computational operation, but it also does not lead to nonphysical effects.

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

◆ TrySeparate() [6/6]

bool Qrack::QUnit::TrySeparate ( const std::vector< bitLenInt > &  qubits,
real1_f  error_tol 
)
virtual

Qrack::QUnit types maintain explicit separation of representations of qubits, which reduces memory usage and increases gate speed.

This method is used to manually attempt internal separation of a QUnit subsytem. We attempt a Decompose() operation, on a state which might not be separable. If the state is not separable, we abort and return false. Otherwise, we complete the operation, add the separated subsystem back in place into the QUnit "shards," and return true.

Warning
PSEUDO-QUANTUM

This should never change the logical/physical state of the QInterface, only possibly its internal representation, for simulation optimization purposes. This is not a truly quantum computational operation, but it also does not lead to nonphysical effects.

Reimplemented from Qrack::QInterface.

◆ UpdateRunningNorm() [1/2]

void Qrack::QUnit::UpdateRunningNorm ( real1_f  norm_thresh = REAL1_DEFAULT_ARG)
virtual

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.

◆ UpdateRunningNorm() [2/2]

virtual void Qrack::QInterface::UpdateRunningNorm ( real1_f  norm_thresh = REAL1_DEFAULT_ARG)
pure virtual

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

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