30 template <
class B
idirectionalIterator>
31 void reverse(BidirectionalIterator first, BidirectionalIterator last,
bitCapInt stride);
32 template <
class B
idirectionalIterator>
33 void rotate(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last,
bitCapInt stride);
54 virtual void SetRandomSeed(uint32_t seed) { rand_generator->seed(seed); }
57 std::map<QInterfacePtr, bitLenInt>
Cohere(std::vector<QInterfacePtr> toCopy);
61 Decohere(start, length, std::dynamic_pointer_cast<QEngineCPU>(dest));
114 virtual void RT(
double radians,
bitLenInt qubitIndex);
115 virtual void RX(
double radians,
bitLenInt qubitIndex);
117 virtual void RY(
double radians,
bitLenInt qubitIndex);
119 virtual void RZ(
double radians,
bitLenInt qubitIndex);
185 bitLenInt valueLength,
unsigned char* values);
215 const bitCapInt* qPowersSorted,
bool doCalcNorm);
virtual void Y(bitLenInt qubitIndex)
Apply Pauli Y matrix to bit.
Definition: gates.cpp:123
virtual void H(bitLenInt qubitIndex)=0
Hadamard gate.
virtual void H(bitLenInt qubitIndex)
Hadamard gate.
Definition: gates.cpp:104
virtual void ROL(bitLenInt shift, bitLenInt start, bitLenInt length)
"Circular shift left" - shift bits left, and carry last bits.
Definition: operators.cpp:18
virtual void CY(bitLenInt control, bitLenInt target)
Apply controlled Pauli Y matrix to bit.
Definition: gates.cpp:141
virtual void INCSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Add an integer to the register, with sign and with carry.
Definition: operators.cpp:349
virtual void ResetStateVec(complex *nStateVec)
Definition: state.cpp:70
Definition: parallel_for.hpp:22
virtual void AntiCCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
"Anti-doubly-controlled not" - Apply "not" if control bits are both zero, do not apply if either cont...
Definition: gates.cpp:62
virtual void INCBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add BCD integer (without sign)
Definition: operators.cpp:166
virtual void RY(double radians, bitLenInt qubitIndex)
y axis rotation gate - Rotates as e^(-i*/2) around Pauli y axis
Definition: rotational.cpp:36
virtual void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add BCD integer (without sign, with carry)
Definition: operators.cpp:217
virtual void CZ(bitLenInt control, bitLenInt target)
Apply controlled Pauli Z matrix to bit.
Definition: gates.cpp:152
virtual void CRX(double radians, bitLenInt control, bitLenInt target)
Controlled x axis rotation - if control bit is true, rotates as e^(-i*/2) around Pauli x axis...
Definition: rotational.cpp:67
virtual void SetQuantumState(complex *inputState)
Set arbitrary pure quantum state, in unsigned int permutation basis.
Definition: state.cpp:77
virtual void CLXOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
"XOR" compare a qubit in QEngineCPU with a classical bit, and store result in outputBit ...
Definition: operators.cpp:160
virtual void CRY(double radians, bitLenInt control, bitLenInt target)
Controlled y axis rotation - if control bit is true, rotates as e^(-i*) around Pauli y axis...
Definition: rotational.cpp:78
virtual void CopyState(QInterfacePtr orig)
Direct copy of raw state vector to produce a clone.
Definition: state.cpp:60
virtual void INCS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Add an integer to the register, with sign and without carry.
Definition: operators.cpp:297
virtual void RT(double radians, bitLenInt qubitIndex)
"Phase shift gate" - Rotates as e^(-i*/2) around |1> state
Definition: rotational.cpp:18
virtual void ApplyDoublyAntiControlled2x2(bitLenInt control1, bitLenInt control2, bitLenInt target, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:79
virtual void CCNOT(bitLenInt control1, bitLenInt control2, bitLenInt target)
Doubly-controlled not.
Definition: gates.cpp:45
virtual void DECBCDC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract BCD integer (without sign, with carry)
Definition: operators.cpp:705
virtual void ApplyDoublyControlled2x2(bitLenInt control1, bitLenInt control2, bitLenInt target, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:66
virtual complex * AllocStateVec(bitCapInt elemCount)
Definition: state.cpp:439
virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
"XOR" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:122
virtual void CRT(double radians, bitLenInt control, bitLenInt target)
Controlled "phase shift gate" - if control bit is true, rotates target bit as e^(-i*/2) around |1> st...
Definition: rotational.cpp:54
virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
"AND" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:20
virtual bitLenInt Cohere(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qengine_cpu.hpp:56
virtual void ApplyAntiControlled2x2(bitLenInt control, bitLenInt target, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:55
virtual void INCC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add integer (without sign, with carry)
Definition: operators.cpp:75
#define complex
Definition: qinterface.hpp:30
virtual void ApplySingleBit(bitLenInt qubitIndex, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:37
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_cpu.hpp:59
virtual void SetRandomSeed(uint32_t seed)
Definition: qengine_cpu.hpp:54
std::shared_ptr< QEngineCPU > QEngineCPUPtr
Definition: qengine_cpu.hpp:27
virtual void SetBit(bitLenInt qubitIndex1, bool value)
Set individual bit to pure |0> (false) or |1> (true) state.
Definition: gates.cpp:20
virtual void ApplyControlled2x2(bitLenInt control, bitLenInt target, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:44
virtual void Dispose(bitLenInt start, bitLenInt length)
Minimally decohere a set of contigious bits from the full coherent unit, throwing these qubits away...
Definition: state.cpp:349
virtual void Z(bitLenInt qubitIndex)
Apply Pauli Z matrix to bit.
Definition: gates.cpp:132
virtual void CLOR(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
"OR" compare a qubit in QEngineCPU with a classical bit, and store result in outputBit ...
Definition: operators.cpp:111
virtual void CNOT(bitLenInt control, bitLenInt target)
Controlled not.
Definition: gates.cpp:78
virtual void UpdateRunningNorm()
Definition: state.cpp:437
double runningNorm
Definition: qengine_cpu.hpp:41
~QEngineCPU()
Definition: qengine_cpu.hpp:50
virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit)
"OR" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:71
#define bitCapInt
Definition: qinterface.hpp:21
QEngineCPU(bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, complex phaseFac=complex(-999.0,-999.0))
Initialize a coherent unit with qBitCount number of bits, to initState unsigned integer permutation s...
Definition: state.cpp:26
#define bitLenInt
Definition: qinterface.hpp:20
virtual void INC(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Add integer (without sign)
Definition: operators.cpp:144
void rotate(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, bitCapInt stride)
Definition: qengine.cpp:28
virtual void RZ(double radians, bitLenInt qubitIndex)
z axis rotation gate - Rotates as e^(-i*/2) around Pauli z axis
Definition: rotational.cpp:45
virtual void RX(double radians, bitLenInt qubitIndex)
x axis rotation gate - Rotates as e^(-i*/2) around Pauli x axis
Definition: rotational.cpp:27
virtual void Apply2x2(bitCapInt offset1, bitCapInt offset2, const complex *mtrx, const bitLenInt bitCount, const bitCapInt *qPowersSorted, bool doCalcNorm)
Apply a 2x2 matrix to the state vector.
Definition: state.cpp:144
General purpose QEngineCPU implementation.
Definition: qengine_cpu.hpp:38
virtual complex * GetState()
Definition: state.cpp:58
std::shared_ptr< std::default_random_engine > rand_generator
Definition: qengine_cpu.hpp:44
virtual bool M(bitLenInt qubitIndex)
Measurement gate.
Definition: gates.cpp:18
A "Qrack::QInterface" is an abstract interface exposing qubit permutation state vector with methods t...
Definition: qinterface.hpp:81
virtual void DECS(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex)
Subtract an integer from the register, with sign and without carry.
Definition: operators.cpp:538
virtual void X(bitLenInt qubitIndex)
NOT gate, which is also Pauli x matrix.
Definition: gates.cpp:114
double Rand()
Generate a random double from 0 to 1.
Definition: qengine_cpu.hpp:211
virtual void DECC(bitCapInt toSub, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Subtract integer (without sign, with carry)
Definition: operators.cpp:109
bitLenInt qubitCount
Definition: qinterface.hpp:83
uint32_t randomSeed
Definition: qengine_cpu.hpp:40
virtual void ROR(bitLenInt shift, bitLenInt start, bitLenInt length)
"Circular shift right" - shift bits right, and carry first bits.
Definition: operators.cpp:46
virtual void CLAND(bitLenInt inputQBit, bool inputClassicalBit, bitLenInt outputBit)
"AND" compare a qubit in QEngineCPU with a classical bit, and store result in outputBit ...
Definition: operators.cpp:60
virtual void DECBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Subtract BCD integer (without sign)
Definition: operators.cpp:482
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:34
virtual void NormalizeState()
Definition: state.cpp:426
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract integer (without sign)
Definition: operators.cpp:461
virtual double ProbAll(bitCapInt fullRegister)
PSEUDO-QUANTUM Direct measure of full register probability to be in permutation state.
Definition: state.cpp:417
void reverse(BidirectionalIterator first, BidirectionalIterator last, bitCapInt stride)
Definition: qengine.cpp:18
virtual void AntiCNOT(bitLenInt control, bitLenInt target)
"Anti-controlled not" - Apply "not" if control bit is zero, do not apply if control bit is one...
Definition: gates.cpp:91
Definition: complex16simd.hpp:21
virtual void CRZ(double radians, bitLenInt control, bitLenInt target)
Controlled z axis rotation - if control bit is true, rotates as e^(-i*) around Pauli z axis...
Definition: rotational.cpp:89
complex * stateVec
Definition: qengine_cpu.hpp:42
virtual void DECSC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt overflowIndex, bitLenInt carryIndex)
Subtract an integer from the register, with sign and with carry.
Definition: operators.cpp:590
std::uniform_real_distribution< double > rand_distribution
Definition: qengine_cpu.hpp:45
virtual double Prob(bitLenInt qubitIndex)
PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state.
Definition: state.cpp:397
virtual void SetPermutation(bitCapInt perm)
Set to a specific permutation.
Definition: qengine_cpu.hpp:53