13# ifndef QUEST_CPU_INTERNAL_H
14# define QUEST_CPU_INTERNAL_H
16# include "QuEST_precision.h"
26static inline int extractBit (
const int locationOfBitFromRight,
const long long int theEncodedNumber) {
27 return (theEncodedNumber & ( 1LL << locationOfBitFromRight )) >> locationOfBitFromRight;
30static inline long long int flipBit(
const long long int number,
const int bitInd) {
31 return (number ^ (1LL << bitInd));
34static inline int maskContainsBit(
const long long int mask,
const int bitInd) {
35 return mask & (1LL << bitInd);
38static inline int isOddParity(
const long long int number,
const int qb1,
const int qb2) {
39 return extractBit(qb1, number) != extractBit(qb2, number);
42static inline long long int insertZeroBit(
const long long int number,
const int index) {
43 long long int left, right;
44 left = (number >> index) << index;
45 right = number - left;
46 return (left << 1) ^ right;
49static inline long long int insertTwoZeroBits(
const long long int number,
const int bit1,
const int bit2) {
50 int small = (bit1 < bit2)? bit1 : bit2;
51 int big = (bit1 < bit2)? bit2 : bit1;
52 return insertZeroBit(insertZeroBit(number, small), big);
62void densmatr_initPureStateLocal(
Qureg targetQureg,
Qureg copyQureg);
70qreal densmatr_findProbabilityOfZeroLocal(
Qureg qureg,
int measureQubit);
72void densmatr_mixDepolarisingLocal(
Qureg qureg,
int targetQubit,
qreal depolLevel);
74void densmatr_mixDepolarisingDistributed(
Qureg qureg,
int targetQubit,
qreal depolLevel);
76void densmatr_mixDampingLocal(
Qureg qureg,
int targetQubit,
qreal damping);
78void densmatr_mixDampingDistributed(
Qureg qureg,
int targetQubit,
qreal damping);
80void densmatr_mixTwoQubitDepolarisingLocal(
Qureg qureg,
int qubit1,
int qubit2,
qreal delta,
qreal gamma);
82void densmatr_mixTwoQubitDepolarisingLocalPart1(
Qureg qureg,
int qubit1,
int qubit2,
qreal delta);
84void densmatr_mixTwoQubitDepolarisingDistributed(
Qureg qureg,
int targetQubit,
87void densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3(
Qureg qureg,
int targetQubit,
94void densmatr_calcProbOfAllOutcomesLocal(
qreal* retProbs,
Qureg qureg,
int* qubits,
int numQubits);
103void statevec_compactUnitaryLocal (
Qureg qureg,
int targetQubit,
Complex alpha,
Complex beta);
105void statevec_compactUnitaryDistributed (
Qureg qureg,
107 ComplexArray stateVecUp,
108 ComplexArray stateVecLo,
109 ComplexArray stateVecOut);
113void statevec_unitaryDistributed (
Qureg qureg,
115 ComplexArray stateVecUp,
116 ComplexArray stateVecLo,
117 ComplexArray stateVecOut);
119void statevec_controlledCompactUnitaryLocal (
Qureg qureg,
int controlQubit,
int targetQubit,
122void statevec_controlledCompactUnitaryDistributed (
Qureg qureg,
int controlQubit,
124 ComplexArray stateVecUp,
125 ComplexArray stateVecLo,
126 ComplexArray stateVecOut);
128void statevec_controlledUnitaryLocal(
Qureg qureg,
int controlQubit,
int targetQubit,
ComplexMatrix2 u);
130void statevec_controlledUnitaryDistributed (
Qureg qureg,
int controlQubit,
132 ComplexArray stateVecUp,
133 ComplexArray stateVecLo,
134 ComplexArray stateVecOut);
136void statevec_multiControlledUnitaryLocal(
Qureg qureg,
int targetQubit,
137 long long int ctrlQubitsMask,
long long int ctrlFlipMask,
ComplexMatrix2 u);
139void statevec_multiControlledUnitaryDistributed (
Qureg qureg,
141 long long int ctrlQubitsMask,
long long int ctrlFlipMask,
143 ComplexArray stateVecUp,
144 ComplexArray stateVecLo,
145 ComplexArray stateVecOut);
147void statevec_pauliXLocal(
Qureg qureg,
int targetQubit);
149void statevec_pauliXDistributed (
Qureg qureg,
150 ComplexArray stateVecIn,
151 ComplexArray stateVecOut);
153void statevec_pauliYLocal(
Qureg qureg,
int targetQubit,
int conjFac);
155void statevec_pauliYDistributed(
Qureg qureg,
156 ComplexArray stateVecIn,
157 ComplexArray stateVecOut,
158 int updateUpper,
int conjFac);
160void statevec_controlledPauliYLocal(
Qureg qureg,
int controlQubit,
int targetQubit,
int conjFactor);
162void statevec_controlledPauliYDistributed(
Qureg qureg,
int controlQubit,
163 ComplexArray stateVecIn,
164 ComplexArray stateVecOut,
int conjFactor);
166void statevec_hadamardLocal (
Qureg qureg,
int targetQubit);
168void statevec_hadamardDistributed (
Qureg qureg,
169 ComplexArray stateVecUp,
170 ComplexArray stateVecLo,
171 ComplexArray stateVecOut,
int updateUpper);
173void statevec_controlledNotLocal(
Qureg qureg,
int controlQubit,
int targetQubit);
175void statevec_controlledNotDistributed (
Qureg qureg,
int controlQubit,
176 ComplexArray stateVecIn,
177 ComplexArray stateVecOut);
179void statevec_multiControlledMultiQubitNotLocal(
Qureg qureg,
int ctrlMask,
int targMask);
181void statevec_multiControlledMultiQubitNotDistributed(
Qureg qureg,
int ctrlMask,
int targMask,
182 ComplexArray stateVecIn,
183 ComplexArray stateVecOut);
185qreal statevec_findProbabilityOfZeroLocal (
Qureg qureg,
int measureQubit);
187qreal statevec_findProbabilityOfZeroDistributed (
Qureg qureg);
189void statevec_collapseToKnownProbOutcomeLocal(
Qureg qureg,
int measureQubit,
int outcome,
qreal totalProbability);
191void statevec_collapseToKnownProbOutcomeDistributedRenorm (
Qureg qureg,
int measureQubit,
qreal totalProbability);
193void statevec_collapseToOutcomeDistributedSetZero(
Qureg qureg);
195void statevec_swapQubitAmpsLocal(
Qureg qureg,
int qb1,
int qb2);
197void statevec_swapQubitAmpsDistributed(
Qureg qureg,
int pairRank,
int qb1,
int qb2);
199void statevec_multiControlledTwoQubitUnitaryLocal(
Qureg qureg,
long long int ctrlMask,
int q1,
int q2,
ComplexMatrix4 u);
201void statevec_multiControlledMultiQubitUnitaryLocal(
Qureg qureg,
long long int ctrlMask,
int* targs,
int numTargs,
ComplexMatrixN u);
205void statevec_calcProbOfAllOutcomesLocal(
qreal* retProbs,
Qureg qureg,
int* qubits,
int numQubits);
#define qreal
A precision-agnostic floating point number, as determined by QuEST_PREC.
Represents a 2x2 matrix of complex numbers.
Definition: QuEST.h:155
Represents a 4x4 matrix of complex numbers.
Definition: QuEST.h:193
Represents a general 2^N by 2^N matrix of complex numbers.
Definition: QuEST.h:204
Represents one complex number.
Definition: QuEST.h:121
Represents a diagonal complex operator on the full Hilbert state of a Qureg.
Definition: QuEST.h:317
Represents a system of qubits.
Definition: QuEST.h:361