QuEST_internal.h
Go to the documentation of this file.
1 // Distributed under MIT licence. See https://github.com/QuEST-Kit/QuEST/blob/master/LICENCE.txt for details
2 
11 # ifndef QUEST_INTERNAL_H
12 # define QUEST_INTERNAL_H
13 
14 # include "QuEST.h"
15 # include "QuEST_precision.h"
16 
17 # ifdef __cplusplus
18 extern "C" {
19 # endif
20 
21 
22 /*
23  * general functions
24  */
25 
26 long long int getQubitBitMask(int* controlQubits, int numControlQubits);
27 
28 long long int getControlFlipMask(int* controlQubits, int* controlState, int numControlQubits);
29 
30 unsigned long int hashString(char *str);
31 
33 
35 
37 
39 
41 
42 void ensureIndsIncrease(int* ind1, int* ind2);
43 
44 void getComplexPairFromRotation(qreal angle, Vector axis, Complex* alpha, Complex* beta);
45 
46 void getZYZRotAnglesFromComplexPair(Complex alpha, Complex beta, qreal* rz2, qreal* ry, qreal* rz1);
47 
48 void getComplexPairAndPhaseFromUnitary(ComplexMatrix2 u, Complex* alpha, Complex* beta, qreal* globalPhase);
49 
50 void shiftIndices(int* indices, int numIndices, int shift);
51 
52 void shiftSubregIndices(int* allInds, int* numIndsPerReg, int numRegs, int shift);
53 
55 
56 void getQuESTDefaultSeedKey(unsigned long int *key);
57 
58 
59 /*
60  * operations upon density matrices
61  */
62 
63 void densmatr_initPlusState(Qureg targetQureg);
64 
65 void densmatr_initClassicalState(Qureg qureg, long long int stateInd);
66 
67 void densmatr_initPureState(Qureg targetQureg, Qureg copyQureg);
68 
70 
72 
73 qreal densmatr_calcFidelity(Qureg qureg, Qureg pureState);
74 
76 
78 
79 qreal densmatr_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome);
80 
81 void densmatr_calcProbOfAllOutcomes(qreal* retProbs, Qureg qureg, int* qubits, int numQubits);
82 
83 void densmatr_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb);
84 
85 int densmatr_measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb);
86 
87 void densmatr_mixDephasing(Qureg qureg, int targetQubit, qreal dephase);
88 
89 void densmatr_mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal dephase);
90 
91 void densmatr_mixDepolarising(Qureg qureg, int targetQubit, qreal depolLevel);
92 
93 void densmatr_mixDamping(Qureg qureg, int targetQubit, qreal damping);
94 
95 void densmatr_mixTwoQubitDepolarising(Qureg qureg, int qubit1, int qubit2, qreal depolLevel);
96 
97 void densmatr_mixPauli(Qureg qureg, int qubit, qreal pX, qreal pY, qreal pZ);
98 
99 void densmatr_mixDensityMatrix(Qureg combineQureg, qreal otherProb, Qureg otherQureg);
100 
101 void densmatr_mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps);
102 
103 void densmatr_mixTwoQubitKrausMap(Qureg qureg, int target1, int target2, ComplexMatrix4 *ops, int numOps);
104 
105 void densmatr_mixMultiQubitKrausMap(Qureg qureg, int* targets, int numTargets, ComplexMatrixN* ops, int numOps);
106 
108 
110 
111 
112 /*
113  * operations upon state vectors
114  */
115 
116 void statevec_reportStateToScreen(Qureg qureg, QuESTEnv env, int reportRank);
117 
118 int statevec_compareStates(Qureg mq1, Qureg mq2, qreal precision);
119 
120 int statevec_initStateFromSingleFile(Qureg *qureg, char filename[200], QuESTEnv env);
121 
122 void statevec_initStateOfSingleQubit(Qureg *qureg, int qubitId, int outcome);
123 
124 void statevec_createQureg(Qureg *qureg, int numQubits, QuESTEnv env);
125 
126 void statevec_destroyQureg(Qureg qureg, QuESTEnv env);
127 
128 void statevec_initBlankState(Qureg qureg);
129 
130 void statevec_initZeroState(Qureg qureg);
131 
132 void statevec_initPlusState(Qureg qureg);
133 
134 void statevec_initDebugState(Qureg qureg);
135 
136 void statevec_initClassicalState(Qureg qureg, long long int stateInd);
137 
138 void statevec_setAmps(Qureg qureg, long long int startInd, qreal* reals, qreal* imags, long long int numAmps);
139 
140 void statevec_cloneQureg(Qureg targetQureg, Qureg copyQureg);
141 
142 void statevec_multiControlledPhaseFlip(Qureg qureg, int *controlQubits, int numControlQubits);
143 
144 void statevec_controlledPhaseFlip(Qureg qureg, int idQubit1, int idQubit2);
145 
146 void statevec_phaseShift(Qureg qureg, int targetQubit, qreal angle);
147 
148 void statevec_phaseShiftByTerm(Qureg qureg, int targetQubit, Complex term);
149 
150 void statevec_controlledPhaseShift(Qureg qureg, int idQubit1, int idQubit2, qreal angle);
151 
152 void statevec_multiControlledPhaseShift(Qureg qureg, int *controlQubits, int numControlQubits, qreal angle);
153 
154 void statevec_sGate(Qureg qureg, int targetQubit);
155 
156 void statevec_tGate(Qureg qureg, int targetQubit);
157 
158 void statevec_sGateConj(Qureg qureg, int targetQubit);
159 
160 void statevec_tGateConj(Qureg qureg, int targetQubit);
161 
162 void statevec_pauliX(Qureg qureg, int targetQubit);
163 
164 void statevec_pauliY(Qureg qureg, int targetQubit);
165 
166 void statevec_pauliYConj(Qureg qureg, int targetQubit);
167 
168 void statevec_pauliZ(Qureg qureg, int targetQubit);
169 
170 void statevec_controlledPauliY(Qureg qureg, int controlQubit, int targetQubit);
171 
172 void statevec_controlledPauliYConj(Qureg qureg, int controlQubit, int targetQubit);
173 
174 qreal statevec_getRealAmp(Qureg qureg, long long int index);
175 
176 qreal statevec_getImagAmp(Qureg qureg, long long int index);
177 
178 qreal statevec_getProbAmp(Qureg qureg, long long int index);
179 
181 
182 qreal statevec_calcFidelity(Qureg qureg, Qureg pureState);
183 
185 
186 qreal statevec_calcExpecPauliProd(Qureg qureg, int* targetQubits, enum pauliOpType* pauliCodes, int numTargets, Qureg workspace);
187 
188 qreal statevec_calcExpecPauliSum(Qureg qureg, enum pauliOpType* allCodes, qreal* termCoeffs, int numSumTerms, Qureg workspace);
189 
190 void statevec_compactUnitary(Qureg qureg, int targetQubit, Complex alpha, Complex beta);
191 
192 void statevec_unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u);
193 
194 void statevec_twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
195 
196 void statevec_controlledTwoQubitUnitary(Qureg qureg, int controlQubit, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
197 
198 void statevec_multiControlledTwoQubitUnitary(Qureg qureg, long long int ctrlMask, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
199 
200 void statevec_multiQubitUnitary(Qureg qureg, int* targets, int numTargets, ComplexMatrixN u);
201 
202 void statevec_controlledMultiQubitUnitary(Qureg qureg, int ctrl, int* targets, int numTargets, ComplexMatrixN u);
203 
204 void statevec_multiControlledMultiQubitUnitary(Qureg qureg, long long int ctrlMask, int* targs, int numTargs, ComplexMatrixN u);
205 
206 void statevec_rotateX(Qureg qureg, int rotQubit, qreal angle);
207 
208 void statevec_rotateY(Qureg qureg, int rotQubit, qreal angle);
209 
210 void statevec_rotateZ(Qureg qureg, int rotQubit, qreal angle);
211 
212 void statevec_rotateAroundAxis(Qureg qureg, int rotQubit, qreal angle, Vector axis);
213 
214 void statevec_rotateAroundAxisConj(Qureg qureg, int rotQubit, qreal angle, Vector axis);
215 
216 void statevec_controlledRotateX(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
217 
218 void statevec_controlledRotateY(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
219 
220 void statevec_controlledRotateZ(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
221 
222 void statevec_controlledRotateAroundAxis(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis);
223 
224 void statevec_controlledRotateAroundAxisConj(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis);
225 
226 void statevec_controlledCompactUnitary(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta);
227 
228 void statevec_controlledUnitary(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u);
229 
230 void statevec_multiControlledUnitary(Qureg qureg, long long int ctrlQubitsMask, long long int ctrlFlipMask, int targetQubit, ComplexMatrix2 u);
231 
232 void statevec_hadamard(Qureg qureg, int targetQubit);
233 
234 void statevec_controlledNot(Qureg qureg, int controlQubit, int targetQubit);
235 
236 void statevec_multiControlledMultiQubitNot(Qureg qureg, int ctrlMask, int targMask);
237 
238 qreal statevec_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome);
239 
240 void statevec_calcProbOfAllOutcomes(qreal* retProbs, Qureg qureg, int* qubits, int numQubits);
241 
242 void statevec_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb);
243 
244 int statevec_measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb);
245 
246 void statevec_swapQubitAmps(Qureg qureg, int qb1, int qb2);
247 
248 void statevec_sqrtSwapGate(Qureg qureg, int qb1, int qb2);
249 
250 void statevec_sqrtSwapGateConj(Qureg qureg, int qb1, int qb2);
251 
252 void statevec_multiRotateZ(Qureg qureg, long long int mask, qreal angle);
253 
254 void statevec_multiControlledMultiRotateZ(Qureg qureg, long long int ctrlMask, long long int targMask, qreal angle);
255 
256 void statevec_multiRotatePauli(Qureg qureg, int* targetQubits, enum pauliOpType* targetPaulis, int numTargets, qreal angle, int applyConj);
257 
258 void statevec_multiControlledMultiRotatePauli(Qureg qureg, long long int ctrlMask, int* targetQubits, enum pauliOpType* targetPaulis, int numTargets, qreal angle, int applyConj);
259 
260 void statevec_setWeightedQureg(Complex fac1, Qureg qureg1, Complex fac2, Qureg qureg2, Complex facOut, Qureg out);
261 
262 void statevec_applyPauliSum(Qureg inQureg, enum pauliOpType* allCodes, qreal* termCoeffs, int numSumTerms, Qureg outQureg);
263 
265 
267 
268 void statevec_applyPhaseFuncOverrides(Qureg qureg, int* qubits, int numQubits, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int numTerms, long long int* overrideInds, qreal* overridePhases, int numOverrides, int conj);
269 
270 void statevec_applyMultiVarPhaseFuncOverrides(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int* numTermsPerReg, long long int* overrideInds, qreal* overridePhases, int numOverrides, int conj);
271 
272 void statevec_applyParamNamedPhaseFuncOverrides(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal* params, int numParams, long long int* overrideInds, qreal* overridePhases, int numOverrides, int conj);
273 
274 
275 /*
276  * operations which differentiate between state-vectors and density matrices internally
277  * (or do not operate upon Quregs)
278  */
279 
280 void agnostic_applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps);
281 
282 void agnostic_applyQFT(Qureg qureg, int* qubits, int numQubits);
283 
284 DiagonalOp agnostic_createDiagonalOp(int numQubits, QuESTEnv env);
285 
287 
289 
290 void agnostic_setDiagonalOpElems(DiagonalOp op, long long int startInd, qreal* real, qreal* imag, long long int numElems);
291 
293 
294 # ifdef __cplusplus
295 }
296 # endif
297 
298 # endif // QUEST_INTERNAL_H
void agnostic_destroyDiagonalOp(DiagonalOp op)
Definition: QuEST_cpu.c:1368
void densmatr_mixDepolarising(Qureg qureg, int targetQubit, qreal depolLevel)
void densmatr_mixMultiQubitKrausMap(Qureg qureg, int *targets, int numTargets, ComplexMatrixN *ops, int numOps)
Definition: QuEST_common.c:701
Represents a 3-vector of real numbers.
Definition: QuEST.h:198
pauliOpType
Codes for specifying Pauli operators.
Definition: QuEST.h:96
void statevec_applyPauliSum(Qureg inQureg, enum pauliOpType *allCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)
Definition: QuEST_common.c:538
void densmatr_initPlusState(Qureg targetQureg)
Definition: QuEST_cpu.c:1165
qreal densmatr_calcInnerProduct(Qureg a, Qureg b)
qreal statevec_calcFidelity(Qureg qureg, Qureg pureState)
Definition: QuEST_common.c:380
void statevec_sqrtSwapGate(Qureg qureg, int qb1, int qb2)
Definition: QuEST_common.c:387
void statevec_sGateConj(Qureg qureg, int targetQubit)
Definition: QuEST_common.c:282
qreal densmatr_calcPurity(Qureg qureg)
Computes the trace of the density matrix squared.
void statevec_unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u)
void statevec_multiControlledMultiQubitUnitary(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...
void statevec_multiRotateZ(Qureg qureg, long long int mask, qreal angle)
Definition: QuEST_cpu.c:3316
void agnostic_syncDiagonalOp(DiagonalOp op)
Definition: QuEST_cpu.c:1373
void statevec_destroyQureg(Qureg qureg, QuESTEnv env)
Definition: QuEST_cpu.c:1328
qreal statevec_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)
void statevec_controlledPauliY(Qureg qureg, int controlQubit, int targetQubit)
void statevec_controlledPhaseShift(Qureg qureg, int idQubit1, int idQubit2, qreal angle)
Definition: QuEST_cpu.c:3226
void statevec_initStateOfSingleQubit(Qureg *qureg, int qubitId, int outcome)
Initialise the state vector of probability amplitudes such that one qubit is set to 'outcome' and all...
Definition: QuEST_cpu.c:1611
Represents a 4x4 matrix of complex numbers.
Definition: QuEST.h:175
void densmatr_initClassicalState(Qureg qureg, long long int stateInd)
Definition: QuEST_cpu.c:1126
Information about the environment the program is running in.
Definition: QuEST.h:362
void statevec_rotateX(Qureg qureg, int rotQubit, qreal angle)
Definition: QuEST_common.c:296
void statevec_multiControlledPhaseShift(Qureg qureg, int *controlQubits, int numControlQubits, qreal angle)
Definition: QuEST_cpu.c:3266
void statevec_pauliY(Qureg qureg, int targetQubit)
int densmatr_measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb)
Definition: QuEST_common.c:372
void statevec_rotateY(Qureg qureg, int rotQubit, qreal angle)
Definition: QuEST_common.c:302
Represents a general 2^N by 2^N matrix of complex numbers.
Definition: QuEST.h:186
void densmatr_mixPauli(Qureg qureg, int qubit, qreal pX, qreal pY, qreal pZ)
Definition: QuEST_common.c:743
void shiftIndices(int *indices, int numIndices, int shift)
Definition: QuEST_common.c:156
void statevec_controlledMultiQubitUnitary(Qureg qureg, int ctrl, int *targets, int numTargets, ComplexMatrixN u)
Definition: QuEST_common.c:579
void densmatr_mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps)
Definition: QuEST_common.c:644
#define qreal
void statevec_rotateAroundAxis(Qureg qureg, int rotQubit, qreal angle, Vector axis)
Definition: QuEST_common.c:314
DiagonalOp agnostic_createDiagonalOp(int numQubits, QuESTEnv env)
Definition: QuEST_cpu.c:1346
void statevec_controlledRotateAroundAxis(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis)
Definition: QuEST_common.c:330
void statevec_swapQubitAmps(Qureg qureg, int qb1, int qb2)
void statevec_controlledPauliYConj(Qureg qureg, int controlQubit, int targetQubit)
void statevec_rotateAroundAxisConj(Qureg qureg, int rotQubit, qreal angle, Vector axis)
Definition: QuEST_common.c:321
void agnostic_applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)
Definition: QuEST_common.c:840
void statevec_multiControlledMultiRotatePauli(Qureg qureg, long long int ctrlMask, int *targetQubits, enum pauliOpType *targetPaulis, int numTargets, qreal angle, int applyConj)
Definition: QuEST_common.c:453
qreal densmatr_calcTotalProb(Qureg qureg)
void statevec_multiControlledMultiQubitNot(Qureg qureg, int ctrlMask, int targMask)
void statevec_phaseShift(Qureg qureg, int targetQubit, qreal angle)
Definition: QuEST_common.c:254
void densmatr_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)
Renorms (/prob) every | * outcome * >< * outcome * | state, setting all others to zero.
Definition: QuEST_cpu.c:791
void statevec_controlledUnitary(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u)
Complex statevec_calcExpecDiagonalOp(Qureg qureg, DiagonalOp op)
void statevec_tGate(Qureg qureg, int targetQubit)
Definition: QuEST_common.c:275
void densmatr_mixDensityMatrix(Qureg combineQureg, qreal otherProb, Qureg otherQureg)
Definition: QuEST_cpu.c:901
void statevec_applyParamNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)
Definition: QuEST_cpu.c:4446
void statevec_multiControlledMultiRotateZ(Qureg qureg, long long int ctrlMask, long long int targMask, qreal angle)
Definition: QuEST_cpu.c:3358
phaseFunc
Flags for specifying named phase functions.
Definition: QuEST.h:231
void statevec_calcProbOfAllOutcomes(qreal *retProbs, Qureg qureg, int *qubits, int numQubits)
long long int getControlFlipMask(int *controlQubits, int *controlState, int numControlQubits)
Definition: QuEST_common.c:60
void statevec_initZeroState(Qureg qureg)
Definition: QuEST_cpu.c:1494
void densmatr_mixDephasing(Qureg qureg, int targetQubit, qreal dephase)
Definition: QuEST_cpu.c:85
qreal statevec_calcExpecPauliProd(Qureg qureg, int *targetQubits, enum pauliOpType *pauliCodes, int numTargets, Qureg workspace)
Definition: QuEST_common.c:509
void densmatr_calcProbOfAllOutcomes(qreal *retProbs, Qureg qureg, int *qubits, int numQubits)
void statevec_controlledRotateY(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Definition: QuEST_common.c:352
void statevec_applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)
Definition: QuEST_cpu.c:4268
void statevec_initBlankState(Qureg qureg)
Definition: QuEST_cpu.c:1464
void statevec_reportStateToScreen(Qureg qureg, QuESTEnv env, int reportRank)
Print the current state vector of probability amplitudes for a set of qubits to standard out.
Definition: QuEST_cpu.c:1439
void statevec_sqrtSwapGateConj(Qureg qureg, int qb1, int qb2)
Definition: QuEST_common.c:400
void statevec_applyDiagonalOp(Qureg qureg, DiagonalOp op)
Definition: QuEST_cpu.c:4047
void statevec_setAmps(Qureg qureg, long long int startInd, qreal *reals, qreal *imags, long long int numAmps)
Definition: QuEST_cpu.c:1248
void statevec_cloneQureg(Qureg targetQureg, Qureg copyQureg)
works for both statevectors and density matrices
Definition: QuEST_cpu.c:1572
void statevec_controlledRotateAroundAxisConj(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis)
Definition: QuEST_common.c:337
void densmatr_mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal dephase)
Definition: QuEST_cpu.c:90
void statevec_controlledRotateX(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Definition: QuEST_common.c:346
void statevec_multiControlledTwoQubitUnitary(Qureg qureg, long long int ctrlMask, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...
void statevec_initPlusState(Qureg qureg)
Definition: QuEST_cpu.c:1504
void statevec_tGateConj(Qureg qureg, int targetQubit)
Definition: QuEST_common.c:289
void statevec_compactUnitary(Qureg qureg, int targetQubit, Complex alpha, Complex beta)
Represents a diagonal complex operator on the full Hilbert state of a Qureg.
Definition: QuEST.h:297
void statevec_pauliZ(Qureg qureg, int targetQubit)
Definition: QuEST_common.c:261
A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...
Definition: QuEST.h:277
void ensureIndsIncrease(int *ind1, int *ind2)
Definition: QuEST_common.c:70
void densmatr_mixDamping(Qureg qureg, int targetQubit, qreal damping)
void statevec_multiControlledPhaseFlip(Qureg qureg, int *controlQubits, int numControlQubits)
Definition: QuEST_cpu.c:3718
Complex densmatr_calcExpecDiagonalOp(Qureg qureg, DiagonalOp op)
void densmatr_mixTwoQubitDepolarising(Qureg qureg, int qubit1, int qubit2, qreal depolLevel)
unsigned long int hashString(char *str)
Definition: QuEST_common.c:185
ComplexMatrix2 getConjugateMatrix2(ComplexMatrix2 src)
Definition: QuEST_common.c:105
void setConjugateMatrixN(ComplexMatrixN m)
Definition: QuEST_common.c:115
void statevec_multiRotatePauli(Qureg qureg, int *targetQubits, enum pauliOpType *targetPaulis, int numTargets, qreal angle, int applyConj)
applyConj=1 will apply conjugate operation, else applyConj=0
Definition: QuEST_common.c:414
void getComplexPairFromRotation(qreal angle, Vector axis, Complex *alpha, Complex *beta)
Definition: QuEST_common.c:120
Complex statevec_calcInnerProduct(Qureg bra, Qureg ket)
Terrible code which unnecessarily individually computes and sums the real and imaginary components of...
long long int getQubitBitMask(int *controlQubits, int numControlQubits)
Definition: QuEST_common.c:50
void statevec_setWeightedQureg(Complex fac1, Qureg qureg1, Complex fac2, Qureg qureg2, Complex facOut, Qureg out)
Definition: QuEST_cpu.c:4005
void statevec_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)
qreal statevec_getImagAmp(Qureg qureg, long long int index)
Represents a system of qubits.
Definition: QuEST.h:322
void statevec_initDebugState(Qureg qureg)
Initialise the state vector of probability amplitudes to an (unphysical) state with each component of...
Definition: QuEST_cpu.c:1657
void statevec_sGate(Qureg qureg, int targetQubit)
Definition: QuEST_common.c:268
void getComplexPairAndPhaseFromUnitary(ComplexMatrix2 u, Complex *alpha, Complex *beta, qreal *globalPhase)
maps U(r0c0, r0c1, r1c0, r1c1) to exp(i globalPhase) U(alpha, beta)
Definition: QuEST_common.c:142
void statevec_controlledNot(Qureg qureg, int controlQubit, int targetQubit)
void agnostic_initDiagonalOpFromPauliHamil(DiagonalOp op, PauliHamil hamil)
Definition: QuEST_cpu.c:1377
void statevec_rotateZ(Qureg qureg, int rotQubit, qreal angle)
Definition: QuEST_common.c:308
qreal densmatr_calcFidelity(Qureg qureg, Qureg pureState)
void statevec_initClassicalState(Qureg qureg, long long int stateInd)
Definition: QuEST_cpu.c:1536
void statevec_hadamard(Qureg qureg, int targetQubit)
void densmatr_mixTwoQubitKrausMap(Qureg qureg, int target1, int target2, ComplexMatrix4 *ops, int numOps)
Definition: QuEST_common.c:682
void statevec_multiControlledUnitary(Qureg qureg, long long int ctrlQubitsMask, long long int ctrlFlipMask, int targetQubit, ComplexMatrix2 u)
void statevec_controlledRotateZ(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Definition: QuEST_common.c:358
int statevec_initStateFromSingleFile(Qureg *qureg, char filename[200], QuESTEnv env)
Definition: QuEST_cpu.c:1691
void statevec_phaseShiftByTerm(Qureg qureg, int targetQubit, Complex term)
Definition: QuEST_cpu.c:3185
qreal statevec_calcExpecPauliSum(Qureg qureg, enum pauliOpType *allCodes, qreal *termCoeffs, int numSumTerms, Qureg workspace)
Definition: QuEST_common.c:524
void statevec_multiQubitUnitary(Qureg qureg, int *targets, int numTargets, ComplexMatrixN u)
Definition: QuEST_common.c:573
void statevec_pauliX(Qureg qureg, int targetQubit)
void agnostic_applyQFT(Qureg qureg, int *qubits, int numQubits)
Definition: QuEST_common.c:849
qreal getVectorMagnitude(Vector vec)
Definition: QuEST_common.c:79
void agnostic_setDiagonalOpElems(DiagonalOp op, long long int startInd, qreal *real, qreal *imag, long long int numElems)
Definition: QuEST_cpu.c:4228
void statevec_controlledPhaseFlip(Qureg qureg, int idQubit1, int idQubit2)
Definition: QuEST_cpu.c:3687
void conjugateMatrixN(ComplexMatrixN u)
qreal densmatr_calcHilbertSchmidtDistance(Qureg a, Qureg b)
int statevec_compareStates(Qureg mq1, Qureg mq2, qreal precision)
Definition: QuEST_cpu.c:1741
void getZYZRotAnglesFromComplexPair(Complex alpha, Complex beta, qreal *rz2, qreal *ry, qreal *rz1)
maps U(alpha, beta) to Rz(rz2) Ry(ry) Rz(rz1)
Definition: QuEST_common.c:130
Represents one complex number.
Definition: QuEST.h:103
void shiftSubregIndices(int *allInds, int *numIndsPerReg, int numRegs, int shift)
Definition: QuEST_common.c:161
void statevec_twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Definition: QuEST_common.c:561
void statevec_createQureg(Qureg *qureg, int numQubits, QuESTEnv env)
Definition: QuEST_cpu.c:1290
qreal densmatr_calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)
ComplexMatrix4 getConjugateMatrix4(ComplexMatrix4 src)
Definition: QuEST_common.c:110
void getQuESTDefaultSeedKey(unsigned long int *key)
Definition: QuEST_common.c:195
Complex getConjugateScalar(Complex scalar)
Definition: QuEST_common.c:91
int statevec_measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb)
Definition: QuEST_common.c:364
void statevec_controlledTwoQubitUnitary(Qureg qureg, int controlQubit, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Definition: QuEST_common.c:567
void statevec_controlledCompactUnitary(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta)
qreal statevec_getProbAmp(Qureg qureg, long long int index)
Definition: QuEST_common.c:248
qreal statevec_getRealAmp(Qureg qureg, long long int index)
bitEncoding
Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...
Definition: QuEST.h:269
void statevec_pauliYConj(Qureg qureg, int targetQubit)
qreal statevec_calcTotalProb(Qureg qureg)
Represents a 2x2 matrix of complex numbers.
Definition: QuEST.h:137
void densmatr_initPureState(Qureg targetQureg, Qureg copyQureg)
void statevec_applyMultiVarPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)
Definition: QuEST_cpu.c:4345
void densmatr_applyDiagonalOp(Qureg qureg, DiagonalOp op)