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

OpenCL enhanced QEngineCPU implementation. More...

#include <qengine_opencl_multi.hpp>

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

Public Member Functions

 QEngineOCLMulti (bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, int deviceCount=-1)
 Initialize a Qrack::QEngineOCLMulti object. More...
 
 QEngineOCLMulti (bitLenInt qBitCount, bitCapInt initState, std::vector< int > devIDs, std::shared_ptr< std::default_random_engine > rgp=nullptr)
 Initialize a Qrack::QEngineOCLMulit object. More...
 
virtual void SetQubitCount (bitLenInt qb)
 
virtual void SetQuantumState (complex *inputState)
 Set an arbitrary pure quantum state. More...
 
virtual void SetPermutation (bitCapInt perm)
 Set to a specific permutation. More...
 
virtual bitLenInt Cohere (QEngineOCLMultiPtr toCopy)
 
virtual bitLenInt Cohere (QInterfacePtr toCopy)
 Combine another QInterface with this one, after the last bit index of this one. More...
 
virtual std::map< QInterfacePtr, bitLenIntCohere (std::vector< QInterfacePtr > toCopy)
 
virtual void Decohere (bitLenInt start, bitLenInt length, QEngineOCLMultiPtr dest)
 
virtual void Decohere (bitLenInt start, bitLenInt length, QInterfacePtr dest)
 Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.". More...
 
virtual void Dispose (bitLenInt start, bitLenInt length)
 Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away. More...
 
virtual void ApplySingleBit (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
 Apply an arbitrary single bit unitary transformation. More...
 
virtual void CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Doubly-controlled NOT gate. More...
 
virtual void AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target)
 Anti doubly-controlled NOT gate. More...
 
virtual void CNOT (bitLenInt control, bitLenInt target)
 Controlled NOT gate. More...
 
virtual void AntiCNOT (bitLenInt control, bitLenInt target)
 Anti controlled NOT gate. More...
 
virtual void H (bitLenInt qubitIndex)
 Hadamard gate. More...
 
virtual bool M (bitLenInt qubitIndex)
 Measurement gate. More...
 
virtual void X (bitLenInt qubitIndex)
 X gate. More...
 
virtual void Y (bitLenInt qubitIndex)
 Y gate. More...
 
virtual void Z (bitLenInt qubitIndex)
 Z gate. More...
 
virtual void CY (bitLenInt control, bitLenInt target)
 Controlled Y gate. More...
 
virtual void CZ (bitLenInt control, bitLenInt target)
 Controlled Z gate. More...
 
virtual void RT (real1 radians, bitLenInt qubitIndex)
 Phase shift gate. More...
 
virtual void RX (real1 radians, bitLenInt qubitIndex)
 X axis rotation gate. More...
 
virtual void RY (real1 radians, bitLenInt qubitIndex)
 Y axis rotation gate. More...
 
virtual void RZ (real1 radians, bitLenInt qubitIndex)
 Z axis rotation gate. More...
 
virtual void Exp (real1 radians, bitLenInt qubitIndex)
 (Identity) Exponentiation gate More...
 
virtual void ExpX (real1 radians, bitLenInt qubitIndex)
 Pauli X exponentiation gate. More...
 
virtual void ExpY (real1 radians, bitLenInt qubitIndex)
 Pauli Y exponentiation gate. More...
 
virtual void ExpZ (real1 radians, bitLenInt qubitIndex)
 Pauli Z exponentiation gate. More...
 
virtual void CRX (real1 radians, bitLenInt control, bitLenInt target)
 Controlled X axis rotation gate. More...
 
virtual void CRY (real1 radians, bitLenInt control, bitLenInt target)
 Controlled Y axis rotation gate. More...
 
virtual void CRZ (real1 radians, bitLenInt control, bitLenInt target)
 Controlled Z axis rotation gate. More...
 
virtual void CRT (real1 radians, bitLenInt control, bitLenInt target)
 Controlled "phase shift gate". More...
 
virtual void INC (bitCapInt toAdd, bitLenInt start, bitLenInt length)
 Add integer (without sign) More...
 
virtual void INCC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add integer (without sign, with carry) More...
 
virtual void INCS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Add a classical integer to the register, with sign and without carry. More...
 
virtual void INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
 Add a classical integer to the register, with sign and with carry. More...
 
virtual void INCSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add a classical integer to the register, with sign and with (phase-based) carry. More...
 
virtual void INCBCD (bitCapInt toAdd, bitLenInt start, bitLenInt length)
 Add classical BCD integer (without sign) More...
 
virtual void INCBCDC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Add classical BCD integer (without sign, with carry) More...
 
virtual void DEC (bitCapInt toSub, bitLenInt start, bitLenInt length)
 Subtract classical integer (without sign) More...
 
virtual void DECC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract classical integer (without sign, with carry) More...
 
virtual void DECS (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
 Subtract a classical integer from the register, with sign and without carry. More...
 
virtual void DECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
 Subtract a classical integer from the register, with sign and with carry. More...
 
virtual void DECSC (bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract a classical integer from the register, with sign and with carry. More...
 
virtual void DECBCD (bitCapInt toAdd, bitLenInt start, bitLenInt length)
 Subtract BCD integer (without sign) More...
 
virtual void DECBCDC (bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
 Subtract BCD integer (without sign, with carry) More...
 
virtual void ZeroPhaseFlip (bitLenInt start, bitLenInt length)
 Reverse the phase of the state where the register equals zero. More...
 
virtual void CPhaseFlipIfLess (bitCapInt greaterPerm, bitLenInt start, bitLenInt length, bitLenInt flagIndex)
 The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation. More...
 
virtual void PhaseFlip ()
 Phase flip always - equivalent to Z X Z X on any bit in the QInterface. More...
 
virtual bitCapInt IndexedLDA (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, unsigned char *values)
 Set 8 bit register bits by a superposed index-offset-based read from classical memory. More...
 
virtual bitCapInt IndexedADC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values)
 Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory. More...
 
virtual bitCapInt IndexedSBC (bitLenInt indexStart, bitLenInt indexLength, bitLenInt valueStart, bitLenInt valueLength, bitLenInt carryIndex, unsigned char *values)
 Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory. More...
 
virtual void Swap (bitLenInt qubitIndex1, bitLenInt qubitIndex2)
 Swap values of two bits in register. More...
 
virtual void Swap (bitLenInt start1, bitLenInt start2, bitLenInt length)
 Bitwise swap. More...
 
virtual void CopyState (QInterfacePtr orig)
 Direct copy of raw state vector to produce a clone. More...
 
virtual void CopyState (QEngineOCLMultiPtr orig)
 
virtual real1 Prob (bitLenInt qubitIndex)
 Direct measure of bit probability to be in |1> state. More...
 
virtual real1 ProbAll (bitCapInt fullRegister)
 Direct measure of full register probability to be in permutation state. More...
 
virtual void X (bitLenInt start, bitLenInt length)
 Bitwise Pauli X (or logical "NOT") operator. More...
 
virtual void CNOT (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled-not. More...
 
virtual void AntiCNOT (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise "anti-"controlled-not. More...
 
virtual void CCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length)
 Bitwise doubly controlled-not. More...
 
virtual void AntiCCNOT (bitLenInt control1, bitLenInt control2, bitLenInt target, bitLenInt length)
 Bitwise doubly "anti-"controlled-not. More...
 
virtual void AND (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
 Bitwise "AND". More...
 
virtual void OR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
 Bitwise "OR". More...
 
virtual void XOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
 Bitwise "XOR". More...
 
- Public Member Functions inherited from Qrack::QInterface
 QInterface (bitLenInt n, std::shared_ptr< std::default_random_engine > rgp=nullptr)
 
virtual ~QInterface ()
 Destructor of QInterface. More...
 
int GetQubitCount ()
 Get the count of bits in this register. More...
 
int GetMaxQPower ()
 Get the maximum number of basis states, namely $ n^2 $ for $ n $ qubits. More...
 
virtual void AND (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
 Quantum analog of classical "AND" gate. More...
 
virtual void OR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
 Quantum analog of classical "OR" gate. More...
 
virtual void XOR (bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
 Quantum analog of classical "XOR" gate. More...
 
virtual void CLAND (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
 Quantum analog of classical "AND" gate. More...
 
virtual void CLOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
 Quantum analog of classical "OR" gate. More...
 
virtual void CLXOR (bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
 Quantum analog of classical "XOR" gate. More...
 
virtual void RTDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction phase shift gate. More...
 
virtual void RXDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction X axis rotation gate. More...
 
virtual void ExpDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction (identity) exponentiation gate. More...
 
virtual void ExpXDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli X exponentiation gate. More...
 
virtual void ExpYDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli Y exponentiation gate. More...
 
virtual void ExpZDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Pauli Z exponentiation gate. More...
 
virtual void CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction X axis rotation gate. More...
 
virtual void RYDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Y axis rotation gate. More...
 
virtual void CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction y axis rotation gate. More...
 
virtual void RZDyad (int numerator, int denomPower, bitLenInt qubitIndex)
 Dyadic fraction Z axis rotation gate. More...
 
virtual void CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction Z axis rotation gate. More...
 
virtual void CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target)
 Controlled dyadic fraction "phase shift gate". More...
 
virtual void H (bitLenInt start, bitLenInt length)
 Bitwise Hadamard. More...
 
virtual void Y (bitLenInt start, bitLenInt length)
 Bitwise Pauli Y operator. More...
 
virtual void Z (bitLenInt start, bitLenInt length)
 Bitwise Pauli Z operator. More...
 
virtual void CLAND (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "AND". More...
 
virtual void CLOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "OR". More...
 
virtual void CLXOR (bitLenInt qInputStart, bitCapInt classicalInput, bitLenInt outputStart, bitLenInt length)
 Classical bitwise "XOR". More...
 
virtual void RT (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise phase shift gate. More...
 
virtual void RTDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction phase shift gate. More...
 
virtual void RX (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise X axis rotation gate. More...
 
virtual void RXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction X axis rotation gate. More...
 
virtual void CRX (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled X axis rotation gate. More...
 
virtual void CRXDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction X axis rotation gate. More...
 
virtual void RY (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise Y axis rotation gate. More...
 
virtual void RYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction Y axis rotation gate. More...
 
virtual void CRY (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Y axis rotation gate. More...
 
virtual void CRYDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction y axis rotation gate. More...
 
virtual void RZ (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise Z axis rotation gate. More...
 
virtual void RZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise dyadic fraction Z axis rotation gate. More...
 
virtual void CRZ (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Z axis rotation gate. More...
 
virtual void CRZDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction Z axis rotation gate. More...
 
virtual void CRT (real1 radians, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled "phase shift gate". More...
 
virtual void CRTDyad (int numerator, int denomPower, bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled dyadic fraction "phase shift gate". More...
 
virtual void Exp (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise (identity) exponentiation gate. More...
 
virtual void ExpDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction (identity) exponentiation gate. More...
 
virtual void ExpX (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli X exponentiation gate. More...
 
virtual void ExpXDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli X exponentiation gate. More...
 
virtual void ExpY (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli Y exponentiation gate. More...
 
virtual void ExpYDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli Y exponentiation gate. More...
 
virtual void ExpZ (real1 radians, bitLenInt start, bitLenInt length)
 Bitwise Pauli Z exponentiation gate. More...
 
virtual void ExpZDyad (int numerator, int denomPower, bitLenInt start, bitLenInt length)
 Bitwise Dyadic fraction Pauli Z exponentiation gate. More...
 
virtual void CY (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Y gate. More...
 
virtual void CZ (bitLenInt control, bitLenInt target, bitLenInt length)
 Bitwise controlled Z gate. More...
 
virtual void ASL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Arithmetic shift left, with last 2 bits as sign and carry. More...
 
virtual void ASR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Arithmetic shift right, with last 2 bits as sign and carry. More...
 
virtual void LSL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Logical shift left, filling the extra bits with |0> More...
 
virtual void LSR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Logical shift right, filling the extra bits with |0> More...
 
virtual void ROL (bitLenInt shift, bitLenInt start, bitLenInt length)
 Circular shift left - shift bits left, and carry last bits. More...
 
virtual void ROR (bitLenInt shift, bitLenInt start, bitLenInt length)
 Circular shift right - shift bits right, and carry first bits. More...
 
virtual void QFT (bitLenInt start, bitLenInt length)
 Quantum Fourier Transform - Apply the quantum Fourier transform to the register. More...
 
virtual void SetReg (bitLenInt start, bitLenInt length, bitCapInt value)
 Set register bits to given permutation. More...
 
virtual bitCapInt MReg (bitLenInt start, bitLenInt length)
 Measure permutation state of a register. More...
 
virtual void Reverse (bitLenInt first, bitLenInt last)
 Reverse all of the bits in a sequence. More...
 
virtual void SetBit (bitLenInt qubitIndex1, bool value)
 Set individual bit to pure |0> (false) or |1> (true) state. More...
 
- Public Member Functions inherited from Qrack::ParallelFor
 ParallelFor ()
 
virtual ~ParallelFor ()
 
void SetConcurrencyLevel (int32_t num)
 
int32_t GetConcurrencyLevel ()
 
void par_for_inc (const bitCapInt begin, const bitCapInt itemCount, IncrementFunc, ParallelFunc fn)
 Iterate through the permutations a maximum of end-begin times, allowing the caller to control the incrementation offset through 'inc'. More...
 
void par_for (const bitCapInt begin, const bitCapInt end, ParallelFunc fn)
 Call fn once for every numerical value between begin and end. More...
 
void par_for_skip (const bitCapInt begin, const bitCapInt end, const bitCapInt skipPower, const bitLenInt skipBitCount, ParallelFunc fn)
 Skip over the skipPower bits. More...
 
void par_for_mask (const bitCapInt, const bitCapInt, const bitCapInt *maskArray, const bitLenInt maskLen, ParallelFunc fn)
 Skip over the bits listed in maskArray in the same fashion as par_for_skip. More...
 
real1 par_norm (const bitCapInt maxQPower, const complex *stateArray)
 Calculate the normal for the array. More...
 

Protected Types

typedef void(QEngineOCL::* GFn) (bitLenInt)
 
typedef void(QEngineOCL::* RGFn) (real1, bitLenInt)
 
typedef void(QEngineOCL::* CGFn) (bitLenInt, bitLenInt)
 
typedef void(QEngineOCL::* CRGFn) (real1, bitLenInt, bitLenInt)
 
typedef void(QEngineOCL::* CCGFn) (bitLenInt, bitLenInt, bitLenInt)
 
typedef void(QEngineOCL::* ASBFn) (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
 

Protected Member Functions

template<typename F , typename... Args>
void SingleBitGate (bool doNormalize, bitLenInt bit, F fn, Args...gfnArgs)
 
template<typename CF , typename F , typename... Args>
void ControlledGate (bool anti, bitLenInt controlBit, bitLenInt targetBit, CF cfn, F fn, Args...gfnArgs)
 
template<typename CCF , typename CF , typename F , typename... Args>
void DoublyControlledGate (bool anti, bitLenInt controlBit1, bitLenInt controlBit2, bitLenInt targetBit, CCF ccfn, CF cfn, F fn, Args...gfnArgs)
 
template<typename F , typename OF >
void RegOp (F fn, OF ofn, bitLenInt length, std::vector< bitLenInt > bits)
 
void CombineEngines (bitLenInt bit)
 
void SeparateEngines ()
 
template<typename F >
void CombineAndOp (F fn, std::vector< bitLenInt > bits)
 
template<typename F >
void CombineAndOpSafe (F fn, std::vector< bitLenInt > bits)
 
void NormalizeState ()
 
void MetaX (bitLenInt start, bitLenInt length)
 
void MetaCNOT (bool anti, std::vector< bitLenInt > controls, bitLenInt target)
 
template<typename F , typename... Args>
void MetaControlled (bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
 
template<typename F , typename... Args>
void SemiMetaControlled (bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
 
template<typename F , typename... Args>
void ControlledSkip (bool anti, bitLenInt controlDepth, bitLenInt targetBit, F fn, Args...gfnArgs)
 
- Protected Member Functions inherited from Qrack::QInterface
virtual real1 Rand ()
 Generate a random real1 from 0 to 1. More...
 
virtual void SetRandomSeed (uint32_t seed)
 

Protected Attributes

real1 runningNorm
 
bitLenInt subQubitCount
 
bitCapInt subMaxQPower
 
bitLenInt subEngineCount
 
bitLenInt maxDeviceOrder
 
size_t subBufferSize
 
OCLEngineclObj
 
std::vector< QEngineOCLPtrsubstateEngines
 
std::vector< std::vector< cl::Buffer > > substateBuffers
 
std::vector< int > deviceIDs
 
- Protected Attributes inherited from Qrack::QInterface
bitLenInt qubitCount
 
bitCapInt maxQPower
 
uint32_t randomSeed
 
std::shared_ptr< std::default_random_engine > rand_generator
 
std::uniform_real_distribution< real1rand_distribution
 

Private Member Functions

void Init (bitLenInt qBitCount, bitCapInt initState)
 
void ShuffleBuffers (complex *stateVec1, complex *stateVec2)
 
bitLenInt SeparateMetaCNOT (bool anti, std::vector< bitLenInt > controls, bitLenInt target, bitLenInt length)
 
bitCapInt log2 (bitCapInt n)
 

Additional Inherited Members

- Public Types inherited from Qrack::ParallelFor
typedef std::function< void(const bitCapInt, const int cpu)> ParallelFunc
 Called once per value between begin and end. More...
 
typedef std::function< bitCapInt(const bitCapInt, const int cpu)> IncrementFunc
 

Detailed Description

OpenCL enhanced QEngineCPU implementation.

Member Typedef Documentation

typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::ASBFn) (const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
protected
typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::CCGFn) (bitLenInt, bitLenInt, bitLenInt)
protected
typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::CGFn) (bitLenInt, bitLenInt)
protected
typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::CRGFn) (real1, bitLenInt, bitLenInt)
protected
typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::GFn) (bitLenInt)
protected
typedef void(QEngineOCL::* Qrack::QEngineOCLMulti::RGFn) (real1, bitLenInt)
protected

Constructor & Destructor Documentation

Qrack::QEngineOCLMulti::QEngineOCLMulti ( bitLenInt  qBitCount,
bitCapInt  initState,
std::shared_ptr< std::default_random_engine >  rgp = nullptr,
int  deviceCount = -1 
)

Initialize a Qrack::QEngineOCLMulti object.

Specify the number of qubits and an initial permutation state. Additionally, optionally specify a pointer to a random generator engine object and a number of sub-engines, (usually one per device, though this can be over-allocated,) to break the object into. The "deviceCount" should be a power of 2, but it will be floored to a power of two if the parameter is not already a power of two. The QEngineOCL can not use more than 1 power of 2 devices per qubit. (2^N devices for N qubits.) Powers of 2 in excess of the qubit count will only be used if this engine acquires additional qubits.

Qrack::QEngineOCLMulti::QEngineOCLMulti ( bitLenInt  qBitCount,
bitCapInt  initState,
std::vector< int >  devIDs,
std::shared_ptr< std::default_random_engine >  rgp = nullptr 
)

Initialize a Qrack::QEngineOCLMulit object.

Specify the number of qubits and an initial permutation state. Additionally, optionally specify a list of device IDs for sub-engines and a pointer to a random generator engine object.

"devIDs" is a list of integers that represent the index of OpenCL devices in the OCLEngine singleton, to select how equal sized sub-engines are distributed between devices in this engine. The QEngineOCLMulti will only have a power of 2 count of subengines at a time, and not more than 1 power of 2 devices per qubit. (2^N devices for N qubits.) Devices in excess of the highest power of two in the list count will essentially be ignored. Powers of 2 in excess of the qubit count will only be used if this engine acquires additional qubits. It might be possible to load balance this way, for example, by allocating 3 sub-engines on one device index and one sub-engine on a second device index. (Whether this is an efficient load balancing mechanism will depend on the particulars of the system architecture and instance initialization.)

Member Function Documentation

void Qrack::QEngineOCLMulti::AND ( bitLenInt  inputStart1,
bitLenInt  inputStart2,
bitLenInt  outputStart,
bitLenInt  length 
)
virtual

Bitwise "AND".

"AND" compare two bit ranges in QInterface, and store result in range starting at output

"AND" registers at "inputStart1" and "inputStart2," of "length" bits, placing the result in "outputStart".

Reimplemented from Qrack::QInterface.

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

Anti doubly-controlled NOT gate.

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

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::AntiCCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target,
bitLenInt  length 
)
virtual

Bitwise doubly "anti-"controlled-not.

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::AntiCNOT ( bitLenInt  control,
bitLenInt  target 
)
virtual

Anti controlled NOT gate.

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

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::AntiCNOT ( bitLenInt  inputBits,
bitLenInt  targetBits,
bitLenInt  length 
)
virtual

Bitwise "anti-"controlled-not.

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::ApplySingleBit ( const complex mtrx,
bool  doCalcNorm,
bitLenInt  qubitIndex 
)
virtual

Apply an arbitrary single bit unitary transformation.

If float rounding from the application of the matrix might change the state vector norm, "doCalcNorm" should be set to true.

Implements Qrack::QInterface.

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

Doubly-controlled NOT gate.

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CCNOT ( bitLenInt  control1,
bitLenInt  control2,
bitLenInt  target,
bitLenInt  length 
)
virtual

Bitwise doubly controlled-not.

Reimplemented from Qrack::QInterface.

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

Controlled NOT gate.

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CNOT ( bitLenInt  inputBits,
bitLenInt  targetBits,
bitLenInt  length 
)
virtual

Bitwise controlled-not.

Reimplemented from Qrack::QInterface.

bitLenInt Qrack::QEngineOCLMulti::Cohere ( QEngineOCLMultiPtr  toCopy)
virtual
virtual bitLenInt Qrack::QEngineOCLMulti::Cohere ( QInterfacePtr  toCopy)
inlinevirtual

Combine another QInterface with this one, after the last bit index of this one.

"Cohere" combines the quantum description of state of two independent QInterface objects into one object, containing the full permutation basis of the full object. The "inputState" bits are added after the last qubit index of the QInterface to which we "Cohere." Informally, "Cohere" is equivalent to "just setting another group of qubits down next to the first" without interacting them. Schroedinger's equation can form a description of state for two independent subsystems at once or "separable quantum subsystems" without interacting them. Once the description of state of the independent systems is combined, we can interact them, and we can describe their entanglements to each other, in which case they are no longer independent. A full entangled description of quantum state is not possible for two independent quantum subsystems until we "Cohere" them.

"Cohere" multiplies the probabilities of the indepedent permutation states of the two subsystems to find the probabilites of the entire set of combined permutations, by simple combinatorial reasoning. If the probablity of the "left-hand" subsystem being in |00> is 1/4, and the probablity of the "right-hand" subsystem being in |101> is 1/8, than the probability of the combined |00101> permutation state is 1/32, and so on for all permutations of the new combined state.

If the programmer doesn't want to "cheat" quantum mechanically, then the original copy of the state which is duplicated into the larger QInterface should be "thrown away" to satisfy "no clone theorem." This is not semantically enforced in Qrack, because optimization of an emulator might be acheived by "cloning" "under-the-hood" while only exposing a quantum mechanically consistent API or instruction set.

Returns the quantum bit offset that the QInterface was appended at, such that bit 5 in toCopy is equal to offset+5 in this object.

Implements Qrack::QInterface.

std::map< QInterfacePtr, bitLenInt > Qrack::QEngineOCLMulti::Cohere ( std::vector< QInterfacePtr toCopy)
virtual

Implements Qrack::QInterface.

template<typename F >
void Qrack::QEngineOCLMulti::CombineAndOp ( fn,
std::vector< bitLenInt bits 
)
protected
template<typename F >
void Qrack::QEngineOCLMulti::CombineAndOpSafe ( fn,
std::vector< bitLenInt bits 
)
protected
void Qrack::QEngineOCLMulti::CombineEngines ( bitLenInt  bit)
protected
template<typename CF , typename F , typename... Args>
void Qrack::QEngineOCLMulti::ControlledGate ( bool  anti,
bitLenInt  controlBit,
bitLenInt  targetBit,
CF  cfn,
fn,
Args...  gfnArgs 
)
protected
template<typename F , typename... Args>
void Qrack::QEngineOCLMulti::ControlledSkip ( bool  anti,
bitLenInt  controlDepth,
bitLenInt  targetBit,
fn,
Args...  gfnArgs 
)
protected
virtual void Qrack::QEngineOCLMulti::CopyState ( QInterfacePtr  orig)
inlinevirtual

Direct copy of raw state vector to produce a clone.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CopyState ( QEngineOCLMultiPtr  orig)
virtual
void Qrack::QEngineOCLMulti::CPhaseFlipIfLess ( bitCapInt  greaterPerm,
bitLenInt  start,
bitLenInt  length,
bitLenInt  flagIndex 
)
virtual

The 6502 uses its carry flag also as a greater-than/less-than flag, for the CMP operation.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CRT ( real1  radians,
bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled "phase shift gate".

If control bit is set to 1, rotates target bit as $ e^{-i*\theta/2} $ around |1> state.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CRX ( real1  radians,
bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled X axis rotation gate.

If "control" is 1, rotates as $ e^{-i*\theta/2} $ on Pauli x axis.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CRY ( real1  radians,
bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled Y axis rotation gate.

If "control" is set to 1, rotates as $ e^{-i*\theta/2} $ around Pauli Y axis.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::CRZ ( real1  radians,
bitLenInt  control,
bitLenInt  target 
)
virtual

Controlled Z axis rotation gate.

If "control" is set to 1, rotates as $ e^{-i*\theta/2} $ around Pauli Zaxis.

Implements Qrack::QInterface.

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

Controlled Y gate.

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

Implements Qrack::QInterface.

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

Controlled Z gate.

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DEC ( bitCapInt  toSub,
bitLenInt  start,
bitLenInt  length 
)
virtual

Subtract classical integer (without sign)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECBCD ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length 
)
virtual

Subtract BCD integer (without sign)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECBCDC ( bitCapInt  toSub,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Subtract BCD integer (without sign, with carry)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECC ( bitCapInt  toSub,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Subtract classical integer (without sign, with carry)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::Decohere ( bitLenInt  start,
bitLenInt  length,
QEngineOCLMultiPtr  dest 
)
virtual
virtual void Qrack::QEngineOCLMulti::Decohere ( bitLenInt  start,
bitLenInt  length,
QInterfacePtr  dest 
)
inlinevirtual

Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".

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

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

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

$ prob(|(left) 1000>) = prob(|1000 00>) + prob(|1000 10>) + prob(|1000 01>) + prob(|1000 11>). $

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECS ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex 
)
virtual

Subtract a classical integer from the register, with sign and without carry.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECSC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex,
bitLenInt  carryIndex 
)
virtual

Subtract a classical integer from the register, with sign and with carry.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::DECSC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Subtract a classical integer from the register, with sign and with carry.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::Dispose ( bitLenInt  start,
bitLenInt  length 
)
virtual

Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away.

Minimally decohere a set of contigious bits from the full coherent unit, discarding these bits. The length of this coherent unit is reduced by the length of bits decohered. For quantum mechanical accuracy, the bit set removed and the bit set left behind should be quantum mechanically "separable."

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

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

$ prob(|(left) 1000>) = prob(|1000 00>) + prob(|1000 10>) + prob(|1000 01>) + prob(|1000 11>). $

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

Implements Qrack::QInterface.

template<typename CCF , typename CF , typename F , typename... Args>
void Qrack::QEngineOCLMulti::DoublyControlledGate ( bool  anti,
bitLenInt  controlBit1,
bitLenInt  controlBit2,
bitLenInt  targetBit,
CCF  ccfn,
CF  cfn,
fn,
Args...  gfnArgs 
)
protected
void Qrack::QEngineOCLMulti::Exp ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

(Identity) Exponentiation gate

Applies $ e^{-i*\theta*I} $, exponentiation of the identity operator

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::ExpX ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Pauli X exponentiation gate.

Applies $ e^{-i*\theta*\sigma_x} $, exponentiation of the Pauli X operator

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::ExpY ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Pauli Y exponentiation gate.

Applies $ e^{-i*\theta*\sigma_y} $, exponentiation of the Pauli Y operator

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::ExpZ ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Pauli Z exponentiation gate.

Applies $ e^{-i*\theta*\sigma_z} $, exponentiation of the Pauli Z operator

Implements Qrack::QInterface.

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

Hadamard gate.

Applies a Hadamard gate on qubit at "qubitIndex."

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length 
)
virtual

Add integer (without sign)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCBCD ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length 
)
virtual

Add classical BCD integer (without sign)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCBCDC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Add classical BCD integer (without sign, with carry)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Add integer (without sign, with carry)

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCS ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex 
)
virtual

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCSC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  overflowIndex,
bitLenInt  carryIndex 
)
virtual

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::INCSC ( bitCapInt  toAdd,
bitLenInt  start,
bitLenInt  length,
bitLenInt  carryIndex 
)
virtual

Add a classical integer to the register, with sign and with (phase-based) carry.

Implements Qrack::QInterface.

bitCapInt Qrack::QEngineOCLMulti::IndexedADC ( bitLenInt  indexStart,
bitLenInt  indexLength,
bitLenInt  valueStart,
bitLenInt  valueLength,
bitLenInt  carryIndex,
unsigned char *  values 
)
virtual

Add to entangled 8 bit register state with a superposed index-offset-based read from classical memory.

inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value + values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See IndexedLDA() for context.

While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().

Implements Qrack::QInterface.

bitCapInt Qrack::QEngineOCLMulti::IndexedLDA ( bitLenInt  indexStart,
bitLenInt  indexLength,
bitLenInt  valueStart,
bitLenInt  valueLength,
unsigned char *  values 
)
virtual

Set 8 bit register bits by a superposed index-offset-based read from classical memory.

"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits are first cleared, then the separable |input, 00000000> permutation state is mapped to |input, values[input]>, with "values[input]" placed in the "outputStart" register.

While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM.

The physical motivation for this addressing mode can be explained as follows: say that we have a superconducting quantum interface device (SQUID) based chip. SQUIDs have already been demonstrated passing coherently superposed electrical currents. In a sufficiently quantum-mechanically isolated qubit chip with a classical cache, with both classical RAM and registers likely cryogenically isolated from the environment, SQUIDs could (hopefully) pass coherently superposed electrical currents into the classical RAM cache to load values into a qubit register. The state loaded would be a superposition of the values of all RAM to which coherently superposed electrical currents were passed.

In qubit system similar to the MOS 6502, say we have qubit-based "accumulator" and "X index" registers, and say that we start with a superposed X index register. In (classical) X addressing mode, the X index register value acts an offset into RAM from a specified starting address. The X addressing mode of a LoaD Accumulator (LDA) instruction, by the physical mechanism described above, should load the accumulator in quantum parallel with the values of every different address of RAM pointed to in superposition by the X index register. The superposed values in the accumulator are entangled with those in the X index register, by way of whatever values the classical RAM pointed to by X held at the time of the load. (If the RAM at index "36" held an unsigned char value of "27," then the value "36" in the X index register becomes entangled with the value "27" in the accumulator, and so on in quantum parallel for all superposed values of the X index register, at once.) If the X index register or accumulator are then measured, the two registers will both always collapse into a random but valid key-value pair of X index offset and value at that classical RAM address.

Note that a "superposed store operation in classical RAM" is not possible by analagous reasoning. Classical RAM would become entangled with both the accumulator and the X register. When the state of the registers was collapsed, we would find that only one "store" operation to a single memory address had actually been carried out, consistent with the address offset in the collapsed X register and the byte value in the collapsed accumulator. It would not be possible by this model to write in quantum parallel to more than one address of classical memory at a time.

Implements Qrack::QInterface.

bitCapInt Qrack::QEngineOCLMulti::IndexedSBC ( bitLenInt  indexStart,
bitLenInt  indexLength,
bitLenInt  valueStart,
bitLenInt  valueLength,
bitLenInt  carryIndex,
unsigned char *  values 
)
virtual

Subtract from an entangled 8 bit register state with a superposed index-offset-based read from classical memory.

"inputStart" is the start index of 8 qubits that act as an index into the 256 byte "values" array. The "outputStart" bits would usually already be entangled with the "inputStart" bits via a IndexedLDA() operation. With the "inputStart" bits being a "key" and the "outputStart" bits being a value, the permutation state |key, value> is mapped to |key, value - values[key]>. This is similar to classical parallel addition of two arrays. However, when either of the registers are measured, both registers will collapse into one random VALID key-value pair, with any addition or subtraction done to the "value." See QInterface::IndexedLDA for context.

While a QInterface represents an interacting set of qubit-based registers, or a virtual quantum chip, the registers need to interact in some way with (classical or quantum) RAM. IndexedLDA is a RAM access method similar to the X addressing mode of the MOS 6502 chip, if the X register can be in a state of coherent superposition when it loads from RAM. "IndexedADC" and "IndexedSBC" perform add and subtract (with carry) operations on a state usually initially prepared with IndexedLDA().

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::Init ( bitLenInt  qBitCount,
bitCapInt  initState 
)
private
bitCapInt Qrack::QEngineOCLMulti::log2 ( bitCapInt  n)
inlineprivate
bool Qrack::QEngineOCLMulti::M ( bitLenInt  qubitIndex)
virtual

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::MetaCNOT ( bool  anti,
std::vector< bitLenInt controls,
bitLenInt  target 
)
protected
template<typename F , typename... Args>
void Qrack::QEngineOCLMulti::MetaControlled ( bool  anti,
std::vector< bitLenInt controls,
bitLenInt  target,
fn,
Args...  gfnArgs 
)
protected
void Qrack::QEngineOCLMulti::MetaX ( bitLenInt  start,
bitLenInt  length 
)
protected
void Qrack::QEngineOCLMulti::NormalizeState ( )
protected
void Qrack::QEngineOCLMulti::OR ( bitLenInt  inputStart1,
bitLenInt  inputStart2,
bitLenInt  outputStart,
bitLenInt  length 
)
virtual

Bitwise "OR".

"OR" compare two bit ranges in QInterface, and store result in range starting at output

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::PhaseFlip ( )
virtual

Phase flip always - equivalent to Z X Z X on any bit in the QInterface.

Implements Qrack::QInterface.

real1 Qrack::QEngineOCLMulti::Prob ( bitLenInt  qubitIndex)
virtual

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

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

real1 Qrack::QEngineOCLMulti::ProbAll ( bitCapInt  fullRegister)
virtual

Direct measure of full register probability to be in permutation state.

Warning
PSEUDO-QUANTUM

Implements Qrack::QInterface.

template<typename F , typename OF >
void Qrack::QEngineOCLMulti::RegOp ( fn,
OF  ofn,
bitLenInt  length,
std::vector< bitLenInt bits 
)
protected
void Qrack::QEngineOCLMulti::RT ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Phase shift gate.

Rotates as $ e^{-i*\theta/2} $ around |1> state

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::RX ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

X axis rotation gate.

Rotates as $ e^{-i*\theta/2} $ around Pauli X axis

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::RY ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Y axis rotation gate.

Rotates as $ e^{-i*\theta/2} $ around Pauli y axis.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::RZ ( real1  radians,
bitLenInt  qubitIndex 
)
virtual

Z axis rotation gate.

Rotates as $ e^{-i*\theta/2} $ around Pauli Z axis.

Implements Qrack::QInterface.

template<typename F , typename... Args>
void Qrack::QEngineOCLMulti::SemiMetaControlled ( bool  anti,
std::vector< bitLenInt controls,
bitLenInt  target,
fn,
Args...  gfnArgs 
)
protected
void Qrack::QEngineOCLMulti::SeparateEngines ( )
protected
bitLenInt Qrack::QEngineOCLMulti::SeparateMetaCNOT ( bool  anti,
std::vector< bitLenInt controls,
bitLenInt  target,
bitLenInt  length 
)
private
void Qrack::QEngineOCLMulti::SetPermutation ( bitCapInt  perm)
virtual

Set to a specific permutation.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::SetQuantumState ( complex inputState)
virtual

Set an arbitrary pure quantum state.

Implements Qrack::QInterface.

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

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::ShuffleBuffers ( complex stateVec1,
complex stateVec2 
)
private
template<typename F , typename... Args>
void Qrack::QEngineOCLMulti::SingleBitGate ( bool  doNormalize,
bitLenInt  bit,
fn,
Args...  gfnArgs 
)
protected
void Qrack::QEngineOCLMulti::Swap ( bitLenInt  qubitIndex1,
bitLenInt  qubitIndex2 
)
virtual

Swap values of two bits in register.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::Swap ( bitLenInt  start1,
bitLenInt  start2,
bitLenInt  length 
)
virtual

Bitwise swap.

Reimplemented from Qrack::QInterface.

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

X gate.

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

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::X ( bitLenInt  start,
bitLenInt  length 
)
virtual

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

Reimplemented from Qrack::QInterface.

void Qrack::QEngineOCLMulti::XOR ( bitLenInt  inputStart1,
bitLenInt  inputStart2,
bitLenInt  outputStart,
bitLenInt  length 
)
virtual

Bitwise "XOR".

"XOR" compare two bit ranges in QInterface, and store result in range starting at output

Reimplemented from Qrack::QInterface.

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

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.

Implements Qrack::QInterface.

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

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.

Implements Qrack::QInterface.

void Qrack::QEngineOCLMulti::ZeroPhaseFlip ( bitLenInt  start,
bitLenInt  length 
)
virtual

Reverse the phase of the state where the register equals zero.

Implements Qrack::QInterface.

Member Data Documentation

OCLEngine* Qrack::QEngineOCLMulti::clObj
protected
std::vector<int> Qrack::QEngineOCLMulti::deviceIDs
protected
bitLenInt Qrack::QEngineOCLMulti::maxDeviceOrder
protected
real1 Qrack::QEngineOCLMulti::runningNorm
protected
size_t Qrack::QEngineOCLMulti::subBufferSize
protected
bitLenInt Qrack::QEngineOCLMulti::subEngineCount
protected
bitCapInt Qrack::QEngineOCLMulti::subMaxQPower
protected
bitLenInt Qrack::QEngineOCLMulti::subQubitCount
protected
std::vector<std::vector<cl::Buffer> > Qrack::QEngineOCLMulti::substateBuffers
protected
std::vector<QEngineOCLPtr> Qrack::QEngineOCLMulti::substateEngines
protected

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