29 template <
class B
idirectionalIterator>
30 void reverse(BidirectionalIterator first, BidirectionalIterator last,
bitCapInt stride);
31 template <
class B
idirectionalIterator>
32 void rotate(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last,
bitCapInt stride);
45 complex phaseFac =
complex(-999.0, -999.0),
bool partialInit =
false);
55 std::map<QInterfacePtr, bitLenInt>
Cohere(std::vector<QInterfacePtr> toCopy);
166 bitLenInt valueLength,
unsigned char* values);
196 virtual bool ForceM(
bitLenInt qubitIndex,
bool result,
bool doForce =
true,
real1 nrmlzr = 1.0);
204 const bitCapInt* qPowersSorted,
bool doCalcNorm);
virtual void Y(bitLenInt qubitIndex)
Apply Pauli Y matrix to bit.
Definition: gates.cpp:123
QEngineCPU(bitLenInt qBitCount, bitCapInt initState, std::shared_ptr< std::default_random_engine > rgp=nullptr, complex phaseFac=complex(-999.0,-999.0), bool partialInit=false)
Initialize a coherent unit with qBitCount number of bits, to initState unsigned integer permutation s...
Definition: state.cpp:36
virtual void H(bitLenInt qubitIndex)=0
Hadamard gate.
virtual void ExpZ(real1 radians, bitLenInt qubitIndex)
Exponentiate Pauli Z operator.
Definition: rotational.cpp:79
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:81
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 Exp(real1 radians, bitLenInt qubitIndex)
Exponentiate identity operator.
Definition: rotational.cpp:54
virtual void ExpX(real1 radians, bitLenInt qubitIndex)
Exponentiate Pauli X operator.
Definition: rotational.cpp:62
virtual void ExpY(real1 radians, bitLenInt qubitIndex)
Exponentiate Pauli Y operator.
Definition: rotational.cpp:70
virtual void INCBCDC(bitCapInt toAdd, bitLenInt start, bitLenInt length, bitLenInt carryIndex)
Add BCD integer (without sign, with carry)
Definition: operators.cpp:217
virtual void Decohere(bitLenInt start, bitLenInt length, QInterfacePtr dest)
Minimally decohere a set of contiguous bits from the full coherent unit, into "destination.".
Definition: state.cpp:387
virtual real1 GetNorm(bool update=true)
Definition: qengine_cpu.hpp:187
virtual void CZ(bitLenInt control, bitLenInt target)
Apply controlled Pauli Z matrix to bit.
Definition: gates.cpp:152
virtual void SetQuantumState(complex *inputState)
Set arbitrary pure quantum state, in unsigned int permutation basis.
Definition: state.cpp:88
virtual void CRZ(real1 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:122
virtual void CopyState(QInterfacePtr orig)
Direct copy of raw state vector to produce a clone.
Definition: state.cpp:71
virtual void EnableNormalize(bool doN)
Definition: qengine_cpu.hpp:49
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
#define real1
Definition: qinterface.hpp:35
virtual void CRT(real1 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:87
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 ApplySingleBit(const complex *mtrx, bool doCalcNorm, bitLenInt qubitIndex)
Apply an arbitrary single bit unitary transformation.
Definition: qengine.cpp:37
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:455
virtual void RX(real1 radians, bitLenInt qubitIndex)
x axis rotation gate - Rotates as e^(-i*/2) around Pauli x axis
Definition: rotational.cpp:27
virtual void RY(real1 radians, bitLenInt qubitIndex)
y axis rotation gate - Rotates as e^(-i*/2) around Pauli y axis
Definition: rotational.cpp:36
virtual bitLenInt Cohere(QInterfacePtr toCopy)
Combine another QInterface with this one, after the last bit index of this one.
Definition: qengine_cpu.hpp:54
bool doNormalize
Definition: qengine_cpu.hpp:39
virtual void ApplyAntiControlled2x2(bitLenInt control, bitLenInt target, const complex *mtrx, bool doCalcNorm)
Definition: qengine.cpp:55
virtual void RZ(real1 radians, bitLenInt qubitIndex)
z axis rotation gate - Rotates as e^(-i*/2) around Pauli z axis
Definition: rotational.cpp:45
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:34
void DecohereDispose(bitLenInt start, bitLenInt length, QEngineCPUPtr dest)
Minimally decohere a set of contigious bits from the full coherent unit.
Definition: state.cpp:318
virtual void RT(real1 radians, bitLenInt qubitIndex)
"Phase shift gate" - Rotates as e^(-i*/2) around |1> state
Definition: rotational.cpp:18
std::shared_ptr< QEngineCPU > QEngineCPUPtr
Definition: qengine_cpu.hpp:26
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:392
virtual void Z(bitLenInt qubitIndex)
Apply Pauli Z matrix to bit.
Definition: gates.cpp:132
virtual real1 ProbAll(bitCapInt fullRegister)
PSEUDO-QUANTUM Direct measure of full register probability to be in permutation state.
Definition: state.cpp:422
virtual void CNOT(bitLenInt control, bitLenInt target)
Controlled not.
Definition: gates.cpp:78
virtual void UpdateRunningNorm()
Definition: state.cpp:453
~QEngineCPU()
Definition: qengine_cpu.hpp:47
#define bitCapInt
Definition: qinterface.hpp:22
#define bitLenInt
Definition: qinterface.hpp:21
virtual void AND(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
"AND" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:20
virtual void XOR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
"XOR" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:60
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 real1 Prob(bitLenInt qubitIndex)
PSEUDO-QUANTUM Direct measure of bit probability to be in |1> state.
Definition: state.cpp:395
virtual void CRX(real1 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:100
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:172
General purpose QEngineCPU implementation.
Definition: qengine_cpu.hpp:37
virtual complex * GetState()
Definition: state.cpp:69
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:94
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
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:96
virtual void CRY(real1 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:111
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 DECBCD(bitCapInt toAdd, bitLenInt start, bitLenInt length)
Subtract BCD integer (without sign)
Definition: operators.cpp:482
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:41
virtual void NormalizeState(real1 nrm=-999.0)
Definition: state.cpp:431
virtual void DEC(bitCapInt toSub, bitLenInt start, bitLenInt length)
Subtract integer (without sign)
Definition: operators.cpp:461
virtual void SetNorm(real1 n)
Definition: qengine_cpu.hpp:194
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
complex * stateVec
Definition: qengine_cpu.hpp:41
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
virtual bool ForceM(bitLenInt qubitIndex, bool result, bool doForce=true, real1 nrmlzr=1.0)
PSEUDO-QUANTUM - Acts like a measurement gate, except with a specified forced result.
Definition: gates.cpp:21
virtual void SetPermutation(bitCapInt perm)
Set to a specific permutation.
Definition: qengine_cpu.hpp:52
virtual void OR(bitLenInt inputBit1, bitLenInt inputBit2, bitLenInt outputBit, bitLenInt length)
"OR" compare two bits in QEngineCPU, and store result in outputBit
Definition: operators.cpp:40
real1 runningNorm
Definition: qengine_cpu.hpp:40