46 int deviceCount = -1);
63 std::shared_ptr<std::default_random_engine> rgp =
nullptr);
69 subEngineCount = substateEngines.size();
80 return Cohere(std::dynamic_pointer_cast<QEngineOCLMulti>(toCopy));
82 virtual std::map<QInterfacePtr, bitLenInt>
Cohere(std::vector<QInterfacePtr> toCopy);
86 Decohere(start, length, std::dynamic_pointer_cast<QEngineOCLMulti>(dest));
138 bitLenInt length,
bool clearCarry =
false);
147 bitLenInt valueLength,
unsigned char* values);
157 virtual void CopyState(QEngineOCLMultiPtr orig);
178 template <
typename CF,
typename F,
typename... Args>
179 void ControlledGate(
bool anti, bitLenInt controlBit, bitLenInt targetBit, CF cfn, F fn, Args... gfnArgs);
180 template <
typename CCF,
typename CF,
typename F,
typename... Args>
181 void DoublyControlledGate(
bool anti, bitLenInt controlBit1, bitLenInt controlBit2, bitLenInt targetBit, CCF ccfn,
182 CF cfn, F fn, Args... gfnArgs);
184 template <
typename F,
typename OF>
void RegOp(F fn, OF ofn, bitLenInt length, std::vector<bitLenInt> bits);
189 template <
typename F>
void CombineAndOp(F fn, std::vector<bitLenInt> bits);
193 void MetaX(bitLenInt start, bitLenInt length);
194 void MetaCNOT(
bool anti, std::vector<bitLenInt> controls, bitLenInt target);
195 template <
typename F,
typename... Args>
196 void MetaControlled(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, F fn, Args... gfnArgs);
197 template <
typename F,
typename... Args>
198 void SemiMetaControlled(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, F fn, Args... gfnArgs);
199 template <
typename F,
typename... Args>
200 void ControlledSkip(
bool anti, bitLenInt controlDepth, bitLenInt targetBit, F fn, Args... gfnArgs);
203 const bitCapInt* qPowersSorted,
bool doCalcNorm)
205 throw "Apply2x2 not implemented in interface";
214 bitLenInt
SeparateMetaCNOT(
bool anti, std::vector<bitLenInt> controls, bitLenInt target, bitLenInt length);
219 bitLenInt p = n >> 1;
virtual void RX(real1 radians, bitLenInt qubitIndex)
X axis rotation gate.
Definition: opencl_multi.cpp:733
virtual bitLenInt Cohere(QEngineOCLMultiPtr toCopy)
Definition: opencl_multi.cpp:338
virtual real1 ProbAll(bitCapInt fullRegister)
Direct measure of full register probability to be in permutation state.
Definition: opencl_multi.cpp:1210
virtual void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add classical BCD integer (without sign, with carry)
Definition: opencl_multi.cpp:811
virtual void Decohere(bitLenInt start, bitLenInt length, QEngineOCLMultiPtr dest)
Definition: opencl_multi.cpp:361
virtual void SetQuantumState(complex *inputState)
Set an arbitrary pure quantum state.
Definition: opencl_multi.cpp:305
virtual void CopyState(QInterfacePtr orig)
Direct copy of raw state vector to produce a clone.
Definition: qengine_opencl_multi.hpp:156
virtual real1 Prob(bitLenInt qubitIndex)
Direct measure of bit probability to be in |1> state.
Definition: opencl_multi.cpp:1170
Definition: parallel_for.hpp:22
virtual void DECBCDC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract BCD integer (without sign, with carry)
Definition: opencl_multi.cpp:847
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 classi...
Definition: opencl_multi.cpp:1085
void ControlledSkip(bool anti, bitLenInt controlDepth, bitLenInt targetBit, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:666
bitLenInt subEngineCount
Definition: qengine_opencl_multi.hpp:29
virtual void CY(bitLenInt control, bitLenInt target)
Controlled Y gate.
Definition: opencl_multi.cpp:719
virtual void Swap(bitLenInt qubitIndex1, bitLenInt qubitIndex2)
Swap values of two bits in register.
Definition: opencl_multi.cpp:1098
void Apply2x2(bitCapInt offset1, bitCapInt offset2, const complex *mtrx, const bitLenInt bitCount, const bitCapInt *qPowersSorted, bool doCalcNorm)
Definition: qengine_opencl_multi.hpp:202
virtual void X(bitLenInt qubitIndex)
X gate.
Definition: opencl_multi.cpp:706
void MetaX(bitLenInt start, bitLenInt length)
Definition: opencl_multi.cpp:514
virtual void DECBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Subtract BCD integer (without sign)
Definition: opencl_multi.cpp:842
virtual void INCBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add classical BCD integer (without sign)
Definition: opencl_multi.cpp:806
bitCapInt maxQPower
Definition: qinterface.hpp:102
virtual void ExpX(real1 radians, bitLenInt qubitIndex)
Pauli X exponentiation gate.
Definition: opencl_multi.cpp:749
virtual void CRT(real1 radians, bitLenInt control, bitLenInt target)
Controlled "phase shift gate".
Definition: opencl_multi.cpp:773
void CombineAndOp(F fn, std::vector< bitLenInt > bits)
Definition: opencl_multi.cpp:1350
virtual void DECS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Subtract a classical integer from the register, with sign and without carry.
Definition: opencl_multi.cpp:826
virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "XOR".
Definition: opencl_multi.cpp:1043
virtual void RT(real1 radians, bitLenInt qubitIndex)
Phase shift gate.
Definition: opencl_multi.cpp:729
#define real1
Definition: qinterface.hpp:36
virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add a classical integer to the register, with sign and without carry.
Definition: opencl_multi.cpp:790
bitLenInt maxDeviceOrder
Definition: qengine_opencl_multi.hpp:30
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.
Definition: opencl_multi.cpp:831
void(QEngineOCL::* GFn)(bitLenInt)
Definition: qengine_opencl_multi.hpp:171
virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Anti doubly-controlled NOT gate.
Definition: opencl_multi.cpp:417
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...
Definition: opencl_multi.cpp:1073
void ControlledGate(bool anti, bitLenInt controlBit, bitLenInt targetBit, CF cfn, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:228
void(QEngineOCL::* RGFn)(real1, bitLenInt)
Definition: qengine_opencl_multi.hpp:172
virtual void SetQubitCount(bitLenInt qb)
Definition: qengine_opencl_multi.hpp:65
virtual void Z(bitLenInt qubitIndex)
Z gate.
Definition: opencl_multi.cpp:717
virtual void CMUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length, bool clearCarry=false)
Controlled multiplication by integer.
Definition: opencl_multi.cpp:863
virtual bool M(bitLenInt qubitIndex)
Measurement gate.
Definition: opencl_multi.cpp:447
void MetaControlled(bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:563
virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "OR".
Definition: opencl_multi.cpp:1024
std::vector< QEngineOCLPtr > substateEngines
Definition: qengine_opencl_multi.hpp:32
#define complex
Definition: qinterface.hpp:35
virtual void Exp(real1 radians, bitLenInt qubitIndex)
(Identity) Exponentiation gate
Definition: opencl_multi.cpp:745
virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: opencl_multi.cpp:785
void ShuffleBuffers(QEngineOCLPtr engine1, QEngineOCLPtr engine2)
Definition: opencl_multi.cpp:119
void MetaCNOT(bool anti, std::vector< bitLenInt > controls, bitLenInt target)
Definition: opencl_multi.cpp:531
bitLenInt SeparateMetaCNOT(bool anti, std::vector< bitLenInt > controls, bitLenInt target, bitLenInt length)
Definition: opencl_multi.cpp:918
virtual void PhaseFlip()
Phase flip always - equivalent to Z X Z X on any bit in the QInterface.
Definition: opencl_multi.cpp:889
virtual void Dispose(bitLenInt start, bitLenInt length)
Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away...
Definition: opencl_multi.cpp:375
void SemiMetaControlled(bool anti, std::vector< bitLenInt > controls, bitLenInt target, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:626
virtual void CZ(bitLenInt control, bitLenInt target)
Controlled Z gate.
Definition: opencl_multi.cpp:724
virtual void Y(bitLenInt qubitIndex)
Y gate.
Definition: opencl_multi.cpp:715
virtual void RZ(real1 radians, bitLenInt qubitIndex)
Z axis rotation gate.
Definition: opencl_multi.cpp:741
virtual void CNOT(bitLenInt control, bitLenInt target)
Controlled NOT gate.
Definition: opencl_multi.cpp:404
virtual void ApplySingleBit(const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
Apply an arbitrary single bit unitary transformation.
Definition: opencl_multi.cpp:701
virtual void CRY(real1 radians, bitLenInt control, bitLenInt target)
Controlled Y axis rotation gate.
Definition: opencl_multi.cpp:765
OpenCL enhanced QEngineCPU implementation.
Definition: qengine_opencl.hpp:32
virtual void CRX(real1 radians, bitLenInt control, bitLenInt target)
Controlled X axis rotation gate.
Definition: opencl_multi.cpp:761
std::vector< int > deviceIDs
Definition: qengine_opencl_multi.hpp:34
virtual void Decohere(bitLenInt start, bitLenInt length, QInterfacePtr dest)
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".
Definition: qengine_opencl_multi.hpp:84
#define bitCapInt
Definition: qinterface.hpp:22
virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
Bitwise "AND".
Definition: opencl_multi.cpp:1005
#define bitLenInt
Definition: qinterface.hpp:21
OpenCL enhanced QEngineCPU implementation.
Definition: qengine_opencl_multi.hpp:25
QEngineOCLMulti(bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, int deviceCount=-1)
Initialize a Qrack::QEngineOCLMulti object.
Definition: opencl_multi.cpp:36
void Init(bitLenInt qBitCount, bitCapInt initState)
Definition: opencl_multi.cpp:64
void CombineEngines(bitLenInt bit)
Definition: opencl_multi.cpp:1220
virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: opencl_multi.cpp:780
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract classical integer (without sign)
Definition: opencl_multi.cpp:816
"Qrack::OCLEngine" manages the single OpenCL context.
Definition: oclengine.hpp:130
virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-controlled NOT gate.
Definition: opencl_multi.cpp:389
std::vector< std::vector< cl::Buffer > > substateBuffers
Definition: qengine_opencl_multi.hpp:33
virtual void CRZ(real1 radians, bitLenInt control, bitLenInt target)
Controlled Z axis rotation gate.
Definition: opencl_multi.cpp:769
virtual void SetPermutation(bitCapInt perm)
Set to a specific permutation.
Definition: opencl_multi.cpp:312
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:99
bool doNormalize
Definition: qinterface.hpp:104
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.
Definition: opencl_multi.cpp:1061
void NormalizeState(real1 nrm=-999.0)
Definition: opencl_multi.cpp:1426
virtual bitLenInt Cohere(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qengine_opencl_multi.hpp:78
std::shared_ptr< QEngineOCLMulti > QEngineOCLMultiPtr
Definition: qengine_opencl_multi.hpp:21
bitLenInt qubitCount
Definition: qinterface.hpp:101
void(QEngineOCL::* CGFn)(bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:173
void ApplyM(bitCapInt qPower, bool result, complex nrm)
Definition: qengine_opencl_multi.hpp:207
virtual void ExpY(real1 radians, bitLenInt qubitIndex)
Pauli Y exponentiation gate.
Definition: opencl_multi.cpp:753
virtual void ZeroPhaseFlip(bitLenInt start, bitLenInt length)
Reverse the phase of the state where the register equals zero.
Definition: opencl_multi.cpp:879
void DoublyControlledGate(bool anti, bitLenInt controlBit1, bitLenInt controlBit2, bitLenInt targetBit, CCF ccfn, CF cfn, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:258
virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract classical integer (without sign, with carry)
Definition: opencl_multi.cpp:821
virtual void DIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length)
Divide by integer.
Definition: opencl_multi.cpp:858
OCLEngine * clObj
Definition: qengine_opencl_multi.hpp:31
std::shared_ptr< QEngineOCL > QEngineOCLPtr
Definition: qengine_opencl.hpp:27
virtual void RY(real1 radians, bitLenInt qubitIndex)
Y axis rotation gate.
Definition: opencl_multi.cpp:737
virtual void H(bitLenInt qubitIndex)
Hadamard gate.
Definition: opencl_multi.cpp:445
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.
Definition: opencl_multi.cpp:795
bitCapInt subMaxQPower
Definition: qengine_opencl_multi.hpp:28
virtual void MUL(bitCapInt toMul, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt length, bool clearCarry=false)
Multiply by integer.
Definition: opencl_multi.cpp:852
virtual void ExpZ(real1 radians, bitLenInt qubitIndex)
Pauli Z exponentiation gate.
Definition: opencl_multi.cpp:757
void SingleBitGate(bool doNormalize, bitLenInt bit, F fn, Args...gfnArgs)
Definition: opencl_multi.cpp:144
void(QEngineOCL::* ASBFn)(const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
Definition: qengine_opencl_multi.hpp:176
void SeparateEngines()
Definition: opencl_multi.cpp:1284
virtual void AntiCNOT(bitLenInt control, bitLenInt target)
Anti controlled NOT gate.
Definition: opencl_multi.cpp:432
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:46
virtual void CDIV(bitCapInt toDiv, bitLenInt inOutStart, bitLenInt carryStart, bitLenInt controlBit, bitLenInt length)
Controlled division by power of integer.
Definition: opencl_multi.cpp:871
bitCapInt log2(bitCapInt n)
Definition: qengine_opencl_multi.hpp:216
void RegOp(F fn, OF ofn, bitLenInt length, std::vector< bitLenInt > bits)
Definition: opencl_multi.cpp:1383
Definition: complex16simd.hpp:21
bitLenInt subQubitCount
Definition: qengine_opencl_multi.hpp:27
void(QEngineOCL::* CRGFn)(real1, bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:174
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.
Definition: opencl_multi.cpp:884
void(QEngineOCL::* CCGFn)(bitLenInt, bitLenInt, bitLenInt)
Definition: qengine_opencl_multi.hpp:175