QuEST.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 
32 # ifndef QUEST_H
33 # define QUEST_H
34 
35 # include "QuEST_precision.h"
36 
37 // prevent C++ name mangling
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /*
44  * private structures
45  */
46 
47 // hide these from doxygen
49 
55 enum phaseGateType {SIGMA_Z=0, S_GATE=1, T_GATE=2};
56 
62 typedef struct {
63 
64  char* buffer; // generated QASM string
65  int bufferSize; // maximum number of chars before overflow
66  int bufferFill; // number of chars currently in buffer
67  int isLogging; // whether gates are being added to buffer
68 
69 } QASMLogger;
70 
77 typedef struct ComplexArray
78 {
79  qreal *real;
80  qreal *imag;
81 } ComplexArray;
82 
84 
85 
86 
87 /*
88  * public structures
89  */
90 
97 
103 typedef struct Complex
104 {
107 } Complex;
108 
137 typedef struct ComplexMatrix2
138 {
139  qreal real[2][2];
140  qreal imag[2][2];
142 
175 typedef struct ComplexMatrix4
176 {
177  qreal real[4][4];
178  qreal imag[4][4];
180 
186 typedef struct ComplexMatrixN
187 {
192 
198 typedef struct Vector
199 {
200  qreal x, y, z;
201 } Vector;
202 
231 enum phaseFunc {
235 
270 
277 typedef struct PauliHamil
278 {
288 } PauliHamil;
289 
297 typedef struct DiagonalOp
298 {
302  long long int numElemsPerChunk;
306  int chunkId;
312  ComplexArray deviceOperator;
313 } DiagonalOp;
314 
322 typedef struct Qureg
323 {
332  long long int numAmpsPerChunk;
334  long long int numAmpsTotal;
336  int chunkId;
339 
341  ComplexArray stateVec;
343  ComplexArray pairStateVec;
344 
346  ComplexArray deviceStateVec;
349 
351  QASMLogger* qasmLog;
352 
353 } Qureg;
354 
362 typedef struct QuESTEnv
363 {
364  int rank;
365  int numRanks;
366  unsigned long int* seeds;
367  int numSeeds;
368 } QuESTEnv;
369 
370 
371 
372 /*
373  * public functions
374  */
375 
532 Qureg createQureg(int numQubits, QuESTEnv env);
533 
626 Qureg createDensityQureg(int numQubits, QuESTEnv env);
627 
648 
669 void destroyQureg(Qureg qureg, QuESTEnv env);
670 
724 ComplexMatrixN createComplexMatrixN(int numQubits);
725 
743 
744 #ifndef __cplusplus
745 #ifndef _WIN32
746 
768 void initComplexMatrixN(ComplexMatrixN m, qreal real[][1<<m.numQubits], qreal imag[][1<<m.numQubits]);
769 #endif
770 #endif
771 
807 PauliHamil createPauliHamil(int numQubits, int numSumTerms);
808 
815 void destroyPauliHamil(PauliHamil hamil);
816 
864 
902 void initPauliHamil(PauliHamil hamil, qreal* coeffs, enum pauliOpType* codes);
903 
982 DiagonalOp createDiagonalOp(int numQubits, QuESTEnv env);
983 
997 
1016 void syncDiagonalOp(DiagonalOp op);
1017 
1044 void initDiagonalOp(DiagonalOp op, qreal* real, qreal* imag);
1045 
1099 
1143 
1190 void setDiagonalOpElems(DiagonalOp op, long long int startInd, qreal* real, qreal* imag, long long int numElems);
1191 
1228 void applyDiagonalOp(Qureg qureg, DiagonalOp op);
1229 
1261 
1285 void reportState(Qureg qureg);
1286 
1294 void reportStateToScreen(Qureg qureg, QuESTEnv env, int reportRank);
1295 
1302 void reportQuregParams(Qureg qureg);
1303 
1326 void reportPauliHamil(PauliHamil hamil);
1327 
1338 int getNumQubits(Qureg qureg);
1339 
1356 long long int getNumAmps(Qureg qureg);
1357 
1366 void initBlankState(Qureg qureg);
1367 
1380 void initZeroState(Qureg qureg);
1381 
1399 void initPlusState(Qureg qureg);
1400 
1436 void initClassicalState(Qureg qureg, long long int stateInd);
1437 
1456 void initPureState(Qureg qureg, Qureg pure);
1457 
1468 void initDebugState(Qureg qureg);
1469 
1495 void initStateFromAmps(Qureg qureg, qreal* reals, qreal* imags);
1496 
1542 void setAmps(Qureg qureg, long long int startInd, qreal* reals, qreal* imags, long long int numAmps);
1543 
1564 void cloneQureg(Qureg targetQureg, Qureg copyQureg);
1565 
1600 void phaseShift(Qureg qureg, int targetQubit, qreal angle);
1601 
1645 void controlledPhaseShift(Qureg qureg, int idQubit1, int idQubit2, qreal angle);
1646 
1688 void multiControlledPhaseShift(Qureg qureg, int *controlQubits, int numControlQubits, qreal angle);
1689 
1728 void controlledPhaseFlip (Qureg qureg, int idQubit1, int idQubit2);
1729 
1773 void multiControlledPhaseFlip(Qureg qureg, int *controlQubits, int numControlQubits);
1774 
1806 void sGate(Qureg qureg, int targetQubit);
1807 
1839 void tGate(Qureg qureg, int targetQubit);
1840 
1856 QuESTEnv createQuESTEnv(void);
1857 
1869 void destroyQuESTEnv(QuESTEnv env);
1870 
1880 void syncQuESTEnv(QuESTEnv env);
1881 
1890 int syncQuESTSuccess(int successCode);
1891 
1898 void reportQuESTEnv(QuESTEnv env);
1899 
1917 void getEnvironmentString(QuESTEnv env, char str[200]);
1918 
1944 void copyStateToGPU(Qureg qureg);
1945 
1971 void copyStateFromGPU(Qureg qureg);
1972 
1992 Complex getAmp(Qureg qureg, long long int index);
1993 
2013 qreal getRealAmp(Qureg qureg, long long int index);
2014 
2034 qreal getImagAmp(Qureg qureg, long long int index);
2035 
2055 qreal getProbAmp(Qureg qureg, long long int index);
2056 
2077 Complex getDensityAmp(Qureg qureg, long long int row, long long int col);
2078 
2104 qreal calcTotalProb(Qureg qureg);
2105 
2146 void compactUnitary(Qureg qureg, int targetQubit, Complex alpha, Complex beta);
2147 
2187 void unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u);
2188 
2225 void rotateX(Qureg qureg, int rotQubit, qreal angle);
2226 
2264 void rotateY(Qureg qureg, int rotQubit, qreal angle);
2265 
2304 void rotateZ(Qureg qureg, int rotQubit, qreal angle);
2305 
2332 void rotateAroundAxis(Qureg qureg, int rotQubit, qreal angle, Vector axis);
2333 
2372 void controlledRotateX(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
2373 
2411 void controlledRotateY(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
2412 
2451 void controlledRotateZ(Qureg qureg, int controlQubit, int targetQubit, qreal angle);
2452 
2491 void controlledRotateAroundAxis(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis);
2492 
2542 void controlledCompactUnitary(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta);
2543 
2593 void controlledUnitary(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u);
2594 
2657 void multiControlledUnitary(Qureg qureg, int* controlQubits, int numControlQubits, int targetQubit, ComplexMatrix2 u);
2658 
2694 void pauliX(Qureg qureg, int targetQubit);
2695 
2729 void pauliY(Qureg qureg, int targetQubit);
2730 
2767 void pauliZ(Qureg qureg, int targetQubit);
2768 
2799 void hadamard(Qureg qureg, int targetQubit);
2800 
2843 void controlledNot(Qureg qureg, int controlQubit, int targetQubit);
2844 
2919 void multiControlledMultiQubitNot(Qureg qureg, int* ctrls, int numCtrls, int* targs, int numTargs);
2920 
2976 void multiQubitNot(Qureg qureg, int* targs, int numTargs);
2977 
3018 void controlledPauliY(Qureg qureg, int controlQubit, int targetQubit);
3019 
3052 qreal calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome);
3053 
3141 void calcProbOfAllOutcomes(qreal* outcomeProbs, Qureg qureg, int* qubits, int numQubits);
3142 
3176 qreal collapseToOutcome(Qureg qureg, int measureQubit, int outcome);
3177 
3201 int measure(Qureg qureg, int measureQubit);
3202 
3227 int measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb);
3228 
3255 
3308 
3331 void seedQuESTDefault(QuESTEnv *env);
3332 
3360 void seedQuEST(QuESTEnv *env, unsigned long int *seedArray, int numSeeds);
3361 
3404 void getQuESTSeeds(QuESTEnv env, unsigned long int** seeds, int* numSeeds);
3405 
3414 void startRecordingQASM(Qureg qureg);
3415 
3425 void stopRecordingQASM(Qureg qureg);
3426 
3433 void clearRecordedQASM(Qureg qureg);
3434 
3442 void printRecordedQASM(Qureg qureg);
3443 
3453 void writeRecordedQASMToFile(Qureg qureg, char* filename);
3454 
3484 void mixDephasing(Qureg qureg, int targetQubit, qreal prob);
3485 
3516 void mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal prob);
3517 
3559 void mixDepolarising(Qureg qureg, int targetQubit, qreal prob);
3560 
3597 void mixDamping(Qureg qureg, int targetQubit, qreal prob);
3598 
3664 void mixTwoQubitDepolarising(Qureg qureg, int qubit1, int qubit2, qreal prob);
3665 
3705 void mixPauli(Qureg qureg, int targetQubit, qreal probX, qreal probY, qreal probZ);
3706 
3727 void mixDensityMatrix(Qureg combineQureg, qreal prob, Qureg otherQureg);
3728 
3755 qreal calcPurity(Qureg qureg);
3756 
3787 qreal calcFidelity(Qureg qureg, Qureg pureState);
3788 
3831 void swapGate(Qureg qureg, int qubit1, int qubit2);
3832 
3833 
3879 void sqrtSwapGate(Qureg qureg, int qb1, int qb2);
3880 
3940 void multiStateControlledUnitary(Qureg qureg, int* controlQubits, int* controlState, int numControlQubits, int targetQubit, ComplexMatrix2 u);
3941 
3975 void multiRotateZ(Qureg qureg, int* qubits, int numQubits, qreal angle);
3976 
4030 void multiRotatePauli(Qureg qureg, int* targetQubits, enum pauliOpType* targetPaulis, int numTargets, qreal angle);
4031 
4100 void multiControlledMultiRotateZ(Qureg qureg, int* controlQubits, int numControls, int* targetQubits, int numTargets, qreal angle);
4101 
4201 void multiControlledMultiRotatePauli(Qureg qureg, int* controlQubits, int numControls, int* targetQubits, enum pauliOpType* targetPaulis, int numTargets, qreal angle);
4202 
4252 qreal calcExpecPauliProd(Qureg qureg, int* targetQubits, enum pauliOpType* pauliCodes, int numTargets, Qureg workspace);
4253 
4307 qreal calcExpecPauliSum(Qureg qureg, enum pauliOpType* allPauliCodes, qreal* termCoeffs, int numSumTerms, Qureg workspace);
4308 
4348 qreal calcExpecPauliHamil(Qureg qureg, PauliHamil hamil, Qureg workspace);
4349 
4416 void twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
4417 
4483 void controlledTwoQubitUnitary(Qureg qureg, int controlQubit, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
4484 
4562 void multiControlledTwoQubitUnitary(Qureg qureg, int* controlQubits, int numControlQubits, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
4563 
4645 void multiQubitUnitary(Qureg qureg, int* targs, int numTargs, ComplexMatrixN u);
4646 
4718 void controlledMultiQubitUnitary(Qureg qureg, int ctrl, int* targs, int numTargs, ComplexMatrixN u);
4719 
4807 void multiControlledMultiQubitUnitary(Qureg qureg, int* ctrls, int numCtrls, int* targs, int numTargs, ComplexMatrixN u);
4808 
4852 void mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps);
4853 
4891 void mixTwoQubitKrausMap(Qureg qureg, int target1, int target2, ComplexMatrix4 *ops, int numOps);
4892 
4941 void mixMultiQubitKrausMap(Qureg qureg, int* targets, int numTargets, ComplexMatrixN* ops, int numOps);
4942 
4975 
4999 void setWeightedQureg(Complex fac1, Qureg qureg1, Complex fac2, Qureg qureg2, Complex facOut, Qureg out);
5000 
5058 void applyPauliSum(Qureg inQureg, enum pauliOpType* allPauliCodes, qreal* termCoeffs, int numSumTerms, Qureg outQureg);
5059 
5102 void applyPauliHamil(Qureg inQureg, PauliHamil hamil, Qureg outQureg);
5103 
5182 void applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps);
5183 
5203 void applyMatrix2(Qureg qureg, int targetQubit, ComplexMatrix2 u);
5204 
5255 void applyMatrix4(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u);
5256 
5323 void applyMatrixN(Qureg qureg, int* targs, int numTargs, ComplexMatrixN u);
5324 
5376 void applyMultiControlledMatrixN(Qureg qureg, int* ctrls, int numCtrls, int* targs, int numTargs, ComplexMatrixN u);
5377 
5417 void invalidQuESTInputError(const char* errMsg, const char* errFunc);
5418 
5419 #ifndef __cplusplus
5420 #ifndef _WIN32
5421  // hide this function from doxygen
5423 
5462  int numQubits, qreal re[][1<<numQubits], qreal im[][1<<numQubits],
5463  qreal** reStorage, qreal** imStorage);
5464 #endif
5465 #endif
5466 
5468 // hide this function from doxygen
5470 #define UNPACK_ARR(...) __VA_ARGS__
5471 
5473 #ifndef __cplusplus
5474 
5521 #define getStaticComplexMatrixN(numQubits, re, im) \
5522  bindArraysToStackComplexMatrixN( \
5523  numQubits, \
5524  (qreal[1<<numQubits][1<<numQubits]) UNPACK_ARR re, \
5525  (qreal[1<<numQubits][1<<numQubits]) UNPACK_ARR im, \
5526  (double*[1<<numQubits]) {NULL}, (double*[1<<numQubits]) {NULL} \
5527  )
5528 #endif
5529 
5636 void applyPhaseFunc(Qureg qureg, int* qubits, int numQubits, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int numTerms);
5637 
5747 void applyPhaseFuncOverrides(Qureg qureg, int* qubits, int numQubits, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int numTerms, long long int* overrideInds, qreal* overridePhases, int numOverrides);
5748 
5908 void applyMultiVarPhaseFunc(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int* numTermsPerReg);
5909 
5990 void 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);
5991 
6130 void applyNamedPhaseFunc(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode);
6131 
6203 void applyNamedPhaseFuncOverrides(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, long long int* overrideInds, qreal* overridePhases, int numOverrides);
6204 
6321 void applyParamNamedPhaseFunc(Qureg qureg, int* qubits, int* numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal* params, int numParams);
6322 
6396 void 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);
6397 
6490 void applyFullQFT(Qureg qureg);
6491 
6606 void applyQFT(Qureg qureg, int* qubits, int numQubits);
6607 
6630 void applyProjector(Qureg qureg, int qubit, int outcome);
6631 
6632 // end prevention of C++ name mangling
6633 #ifdef __cplusplus
6634 }
6635 #endif
6636 
6637 #endif // QUEST_H
6638 
void controlledRotateZ(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Applies a controlled rotation by a given angle around the Z-axis of the Bloch-sphere.
Definition: QuEST.c:244
void mixDephasing(Qureg qureg, int targetQubit, qreal prob)
Mixes a density matrix qureg to induce single-qubit dephasing noise.
Definition: QuEST.c:1250
@ INVERSE_PRODUCT
Definition: QuEST.h:233
qreal getProbAmp(Qureg qureg, long long int index)
Get the probability of a state-vector at an index in the full state vector.
Definition: QuEST.c:932
void initBlankState(Qureg qureg)
Initialises a qureg to have all-zero-amplitudes.
Definition: QuEST.c:119
Represents a 3-vector of real numbers.
Definition: QuEST.h:198
void destroyQuESTEnv(QuESTEnv env)
Destroy the QuEST environment.
pauliOpType
Codes for specifying Pauli operators.
Definition: QuEST.h:96
void applyPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms)
Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...
Definition: QuEST.c:726
void applyMultiControlledMatrixN(Qureg qureg, int *ctrls, int numCtrls, int *targs, int numTargs, ComplexMatrixN u)
Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits.
Definition: QuEST.c:1114
void twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Apply a general two-qubit unitary (including a global phase factor).
Definition: QuEST.c:256
void controlledRotateX(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Applies a controlled rotation by a given angle around the X-axis of the Bloch-sphere.
Definition: QuEST.c:220
void applyNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, long long int *overrideInds, qreal *overridePhases, int numOverrides)
Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...
Definition: QuEST.c:813
void reportQuregParams(Qureg qureg)
Report metainformation about a set of qubits: number of qubits, number of probability amplitudes.
Definition: QuEST_common.c:237
void copyStateFromGPU(Qureg qureg)
In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg....
Definition: QuEST_cpu.c:45
void initPauliHamil(PauliHamil hamil, qreal *coeffs, enum pauliOpType *codes)
Initialise PauliHamil instance hamil with the given term coefficients and Pauli codes (one for every ...
Definition: QuEST.c:1504
qreal real[4][4]
Definition: QuEST.h:177
void syncQuESTEnv(QuESTEnv env)
Guarantees that all code up to the given point has been executed on all nodes (if running in distribu...
void initPureState(Qureg qureg, Qureg pure)
Initialise qureg into to a given pure state of an equivalent Hilbert dimension.
Definition: QuEST.c:145
void applyProjector(Qureg qureg, int qubit, int outcome)
Force the target qubit of qureg into the given classical outcome, via a non-renormalising projection.
Definition: QuEST.c:888
@ PAULI_Z
Definition: QuEST.h:96
void rotateAroundAxis(Qureg qureg, int rotQubit, qreal angle, Vector axis)
Rotate a single qubit by a given angle around a given Vector on the Bloch-sphere.
Definition: QuEST.c:601
@ DISTANCE
Definition: QuEST.h:234
void mixDepolarising(Qureg qureg, int targetQubit, qreal prob)
Mixes a density matrix qureg to induce single-qubit homogeneous depolarising noise.
Definition: QuEST.c:1272
int rank
Definition: QuEST.h:364
void seedQuESTDefault(QuESTEnv *env)
Seeds the random number generator with the (master node) current time and process ID.
Definition: QuEST.c:1614
qreal calcTotalProb(Qureg qureg)
A debugging function which calculates the probability of the qubits in qureg being in any state,...
Definition: QuEST.c:1143
void mixDamping(Qureg qureg, int targetQubit, qreal prob)
Mixes a density matrix qureg to induce single-qubit amplitude damping (decay to 0 state).
Definition: QuEST.c:1283
void destroyComplexMatrixN(ComplexMatrixN matr)
Destroy a ComplexMatrixN instance created with createComplexMatrixN()
Definition: QuEST.c:1369
int numChunks
The number of nodes between which the elements of this operator are split.
Definition: QuEST.h:304
void applyNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode)
Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...
Definition: QuEST.c:796
void calcProbOfAllOutcomes(qreal *outcomeProbs, Qureg qureg, int *qubits, int numQubits)
Populates outcomeProbs with the probabilities of every outcome of the sub-register contained in qubit...
Definition: QuEST.c:1176
void reportPauliHamil(PauliHamil hamil)
Print the PauliHamil to screen.
Definition: QuEST.c:1598
ComplexArray pairStateVec
Temporary storage for a chunk of the state vector received from another process in the MPI version.
Definition: QuEST.h:343
@ PAULI_I
Definition: QuEST.h:96
void multiControlledMultiQubitNot(Qureg qureg, int *ctrls, int numCtrls, int *targs, int numTargs)
Apply a NOT (or Pauli X) gate with multiple control and target qubits.
Definition: QuEST.c:549
Complex getDensityAmp(Qureg qureg, long long int row, long long int col)
Get an amplitude from a density matrix at a given row and column.
Definition: QuEST.c:949
DiagonalOp createDiagonalOpFromPauliHamilFile(char *fn, QuESTEnv env)
Creates and initialiases a diagonal operator from the Z Pauli Hamiltonian encoded in file with filena...
Definition: QuEST.c:1558
ComplexMatrixN createComplexMatrixN(int numQubits)
Allocate dynamic memory for a square complex matrix of any size, which can be passed to functions lik...
Definition: QuEST.c:1348
qreal getImagAmp(Qureg qureg, long long int index)
Get the imaginary component of the complex probability amplitude at an index in the state vector.
Definition: QuEST.c:925
void controlledRotateAroundAxis(Qureg qureg, int controlQubit, int targetQubit, qreal angle, Vector axis)
Applies a controlled rotation by a given angle around a given vector on the Bloch-sphere.
Definition: QuEST.c:614
void mixKrausMap(Qureg qureg, int target, ComplexMatrix2 *ops, int numOps)
Apply a general single-qubit Kraus map to a density matrix, as specified by at most four Kraus operat...
Definition: QuEST.c:1314
void getEnvironmentString(QuESTEnv env, char str[200])
Sets str to a string containing information about the runtime environment, including whether simulati...
void syncDiagonalOp(DiagonalOp op)
Update the GPU memory with the current values in op.real and op.imag.
Definition: QuEST.c:1531
void destroyDiagonalOp(DiagonalOp op, QuESTEnv env)
Destroys a DiagonalOp created with createDiagonalOp(), freeing its memory.
Definition: QuEST.c:1524
qreal z
Definition: QuEST.h:200
void multiControlledTwoQubitUnitary(Qureg qureg, int *controlQubits, int numControlQubits, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Apply a general multi-controlled two-qubit unitary (including a global phase factor).
Definition: QuEST.c:282
qreal collapseToOutcome(Qureg qureg, int measureQubit, int outcome)
Updates qureg to be consistent with measuring measureQubit in the given outcome (0 or 1),...
Definition: QuEST.c:966
int numSeeds
Definition: QuEST.h:367
int numChunks
Number of chunks the state vector is broken up into – the number of MPI processes used.
Definition: QuEST.h:338
@ TWOS_COMPLEMENT
Definition: QuEST.h:269
qreal calcPurity(Qureg qureg)
Calculates the purity of a density matrix, by the trace of the density matrix squared.
Definition: QuEST.c:1185
qreal calcProbOfOutcome(Qureg qureg, int measureQubit, int outcome)
Gives the probability of a specified qubit being measured in the given outcome (0 or 1).
Definition: QuEST.c:1166
ComplexArray deviceOperator
A copy of the elements stored persistently on the GPU.
Definition: QuEST.h:312
void getQuESTSeeds(QuESTEnv env, unsigned long int **seeds, int *numSeeds)
Obtain the seeds presently used in random number generation.
Definition: QuEST.c:1622
void clearRecordedQASM(Qureg qureg)
Clear all QASM so far recorded.
Definition: QuEST.c:95
int measure(Qureg qureg, int measureQubit)
Measures a single qubit, collapsing it randomly to 0 or 1.
Definition: QuEST.c:998
qreal calcFidelity(Qureg qureg, Qureg pureState)
Calculates the fidelity of qureg (a state-vector or density matrix) against a reference pure state (n...
Definition: QuEST.c:1191
void unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u)
Apply a general single-qubit unitary (including a global phase factor).
Definition: QuEST.c:348
int chunkId
The position of the chunk of the operator held by this process in the full operator.
Definition: QuEST.h:306
ComplexArray deviceStateVec
Storage for wavefunction amplitudes in the GPU version.
Definition: QuEST.h:346
@ NORM
Definition: QuEST.h:232
void mixTwoQubitDepolarising(Qureg qureg, int qubit1, int qubit2, qreal prob)
Mixes a density matrix qureg to induce two-qubit homogeneous depolarising noise.
Definition: QuEST.c:1291
Complex calcExpecDiagonalOp(Qureg qureg, DiagonalOp op)
Computes the expected value of the diagonal operator op for state qureg.
Definition: QuEST.c:1228
void sGate(Qureg qureg, int targetQubit)
Apply the single-qubit S gate.
Definition: QuEST.c:465
void cloneQureg(Qureg targetQureg, Qureg copyQureg)
Overwrite the amplitudes of targetQureg with those from copyQureg.
Definition: QuEST.c:164
Represents a 4x4 matrix of complex numbers.
Definition: QuEST.h:175
@ SCALED_INVERSE_DISTANCE
Definition: QuEST.h:234
void rotateY(Qureg qureg, int rotQubit, qreal angle)
Rotate a single qubit by a given angle around the Y-axis of the Bloch-sphere.
Definition: QuEST.c:198
void applyPauliHamil(Qureg inQureg, PauliHamil hamil, Qureg outQureg)
Modifies outQureg to be the result of applying PauliHamil (a Hermitian but not necessarily unitary op...
Definition: QuEST.c:1059
Information about the environment the program is running in.
Definition: QuEST.h:362
void applyQFT(Qureg qureg, int *qubits, int numQubits)
Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register qureg.
Definition: QuEST.c:866
@ UNSIGNED
Definition: QuEST.h:269
PauliHamil createPauliHamilFromFile(char *fn)
Creates a PauliHamil instance, a real-weighted sum of products of Pauli operators,...
Definition: QuEST.c:1420
void applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)
Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...
Definition: QuEST.c:743
void multiControlledPhaseShift(Qureg qureg, int *controlQubits, int numControlQubits, qreal angle)
Introduce a phase factor on state of the passed qubits.
Definition: QuEST.c:510
void setDiagonalOpElems(DiagonalOp op, long long int startInd, qreal *real, qreal *imag, long long int numElems)
Modifies a subset (starting at index startInd, and ending at index startInd + numElems) of the elemen...
Definition: QuEST.c:1543
ComplexMatrixN bindArraysToStackComplexMatrixN(int numQubits, qreal re[][1<< numQubits], qreal im[][1<< numQubits], qreal **reStorage, qreal **imStorage)
Definition: QuEST_common.c:652
Represents a general 2^N by 2^N matrix of complex numbers.
Definition: QuEST.h:186
@ INVERSE_DISTANCE
Definition: QuEST.h:234
#define qreal
void multiRotatePauli(Qureg qureg, int *targetQubits, enum pauliOpType *targetPaulis, int numTargets, qreal angle)
Apply a multi-qubit multi-Pauli rotation, also known as a Pauli gadget, on a selected number of qubit...
Definition: QuEST.c:685
void stopRecordingQASM(Qureg qureg)
Disable QASM recording.
Definition: QuEST.c:91
void setAmps(Qureg qureg, long long int startInd, qreal *reals, qreal *imags, long long int numAmps)
Overwrites a subset of the amplitudes in state-vector qureg, with those passed in reals and imags.
Definition: QuEST.c:1021
void multiControlledPhaseFlip(Qureg qureg, int *controlQubits, int numControlQubits)
Apply the multiple-qubit controlled phase flip gate, also known as the multiple-qubit controlled paul...
Definition: QuEST.c:587
void multiQubitUnitary(Qureg qureg, int *targs, int numTargs, ComplexMatrixN u)
Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubit...
Definition: QuEST.c:296
void multiControlledMultiRotateZ(Qureg qureg, int *controlQubits, int numControls, int *targetQubits, int numTargets, qreal angle)
Apply a multi-controlled multi-target Z rotation, also known as a controlled phase gadget.
Definition: QuEST.c:668
@ PAULI_X
Definition: QuEST.h:96
Complex getAmp(Qureg qureg, long long int index)
Get the complex amplitude at a given index in the state vector.
Definition: QuEST.c:939
void controlledPauliY(Qureg qureg, int controlQubit, int targetQubit)
Apply the controlled pauliY (single control, single target) gate, also known as the c-Y and c-sigma-Y...
Definition: QuEST.c:563
void reportState(Qureg qureg)
Print the current state vector of probability amplitudes for a set of qubits to file.
Definition: QuEST_common.c:219
void initComplexMatrixN(ComplexMatrixN m, qreal real[][1<< m.numQubits], qreal imag[][1<< m.numQubits])
Initialises a ComplexMatrixN instance to have the passed real and imag values.
Definition: QuEST.c:1386
int measureWithStats(Qureg qureg, int measureQubit, qreal *outcomeProb)
Measures a single qubit, collapsing it randomly to 0 or 1, and additionally gives the probability of ...
Definition: QuEST.c:985
int numQubitsInStateVec
Number of qubits in the state-vector - this is double the number represented for mixed states.
Definition: QuEST.h:329
qreal calcExpecPauliHamil(Qureg qureg, PauliHamil hamil, Qureg workspace)
Computes the expected value of qureg under Hermitian operator hamil.
Definition: QuEST.c:1219
void multiControlledMultiQubitUnitary(Qureg qureg, int *ctrls, int numCtrls, int *targs, int numTargs, ComplexMatrixN u)
Apply a general multi-controlled multi-qubit unitary (including a global phase factor).
Definition: QuEST.c:330
void rotateX(Qureg qureg, int rotQubit, qreal angle)
Rotate a single qubit by a given angle around the X-axis of the Bloch-sphere.
Definition: QuEST.c:187
void invalidQuESTInputError(const char *errMsg, const char *errFunc)
An internal function called when invalid arguments are passed to a QuEST API call,...
void setWeightedQureg(Complex fac1, Qureg qureg1, Complex fac2, Qureg qureg2, Complex facOut, Qureg out)
Modifies qureg out to the result of (facOut out + fac1 qureg1 + fac2 qureg2), imposing no constraints...
Definition: QuEST.c:1037
int chunkId
The position of the chunk of the state vector held by this process in the full state vector.
Definition: QuEST.h:336
void multiControlledMultiRotatePauli(Qureg qureg, int *controlQubits, int numControls, int *targetQubits, enum pauliOpType *targetPaulis, int numTargets, qreal angle)
Apply a multi-controlled multi-target multi-Pauli rotation, also known as a controlled Pauli gadget.
Definition: QuEST.c:705
qreal calcHilbertSchmidtDistance(Qureg a, Qureg b)
Computes the Hilbert Schmidt distance between two density matrices a and b, defined as the Frobenius ...
Definition: QuEST.c:1237
qreal y
Definition: QuEST.h:200
qreal imag[2][2]
Definition: QuEST.h:140
qreal * imag
The imaginary values of the 2^numQubits complex elements.
Definition: QuEST.h:310
qreal x
Definition: QuEST.h:200
void pauliZ(Qureg qureg, int targetQubit)
Apply the single-qubit Pauli-Z (also known as the Z, sigma-Z or phase-flip) gate.
Definition: QuEST.c:454
phaseFunc
Flags for specifying named phase functions.
Definition: QuEST.h:231
long long int numAmpsPerChunk
Number of probability amplitudes held in stateVec by this process In the non-MPI version,...
Definition: QuEST.h:332
void applyDiagonalOp(Qureg qureg, DiagonalOp op)
Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.
Definition: QuEST.c:1127
qreal * termCoeffs
The real coefficient of each Pauli product. This is an array of length PauliHamil....
Definition: QuEST.h:283
void applyMatrix4(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Apply a general 4-by-4 matrix, which may be non-unitary.
Definition: QuEST.c:1093
void swapGate(Qureg qureg, int qubit1, int qubit2)
Performs a SWAP gate between qubit1 and qubit2.
Definition: QuEST.c:627
enum pauliOpType * pauliCodes
The Pauli operators acting on each qubit, flattened over every operator.
Definition: QuEST.h:281
void initStateFromAmps(Qureg qureg, qreal *reals, qreal *imags)
Initialise qureg by specifying all amplitudes.
Definition: QuEST.c:157
void copyStateToGPU(Qureg qureg)
In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU...
Definition: QuEST_cpu.c:42
@ SCALED_PRODUCT
Definition: QuEST.h:233
void writeRecordedQASMToFile(Qureg qureg, char *filename)
Writes recorded QASM to a file, throwing an error if inaccessible.
Definition: QuEST.c:103
int numRanks
Definition: QuEST.h:365
qreal imag[4][4]
Definition: QuEST.h:178
qreal getRealAmp(Qureg qureg, long long int index)
Get the real component of the complex probability amplitude at an index in the state vector.
Definition: QuEST.c:918
void controlledPhaseFlip(Qureg qureg, int idQubit1, int idQubit2)
Apply the (two-qubit) controlled phase flip gate, also known as the controlled pauliZ gate.
Definition: QuEST.c:575
int numQubits
The number of qubits this operator can act on (informing its size)
Definition: QuEST.h:300
int numSumTerms
The number of terms in the weighted sum, or the number of Pauli products.
Definition: QuEST.h:285
Represents a diagonal complex operator on the full Hilbert state of a Qureg.
Definition: QuEST.h:297
@ PAULI_Y
Definition: QuEST.h:96
A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...
Definition: QuEST.h:277
int getNumQubits(Qureg qureg)
Returns the number of qubits represented by qureg.
Definition: QuEST.c:908
Complex calcInnerProduct(Qureg bra, Qureg ket)
Computes the inner product of two equal-size state vectors, given by.
Definition: QuEST.c:1150
void destroyQureg(Qureg qureg, QuESTEnv env)
Deallocate a Qureg, freeing its memory.
Definition: QuEST.c:77
void 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)
Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...
Definition: QuEST.c:848
@ SCALED_INVERSE_SHIFTED_NORM
Definition: QuEST.h:232
void controlledMultiQubitUnitary(Qureg qureg, int ctrl, int *targs, int numTargs, ComplexMatrixN u)
Apply a general controlled multi-qubit unitary (including a global phase factor).
Definition: QuEST.c:313
void multiQubitNot(Qureg qureg, int *targs, int numTargs)
Apply a NOT (or Pauli X) gate with multiple target qubits, which has the same effect as (but is much ...
Definition: QuEST.c:536
void mixTwoQubitKrausMap(Qureg qureg, int target1, int target2, ComplexMatrix4 *ops, int numOps)
Apply a general two-qubit Kraus map to a density matrix, as specified by at most sixteen Kraus operat...
Definition: QuEST.c:1324
qreal ** real
Definition: QuEST.h:189
void initDebugState(Qureg qureg)
Initialises qureg to be in the un-normalised, non-physical state with with -th complex amplitude give...
Definition: QuEST.c:1578
QASMLogger * qasmLog
Storage for generated QASM output.
Definition: QuEST.h:351
qreal * secondLevelReduction
Definition: QuEST.h:348
void startRecordingQASM(Qureg qureg)
Enable QASM recording.
Definition: QuEST.c:87
void applyPauliSum(Qureg inQureg, enum pauliOpType *allPauliCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)
Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...
Definition: QuEST.c:1048
void applyMatrixN(Qureg qureg, int *targs, int numTargs, ComplexMatrixN u)
Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits.
Definition: QuEST.c:1103
unsigned long int * seeds
Definition: QuEST.h:366
void applyMultiVarPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg)
Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...
Definition: QuEST.c:761
void compactUnitary(Qureg qureg, int targetQubit, Complex alpha, Complex beta)
Apply a single-qubit unitary parameterised by two given complex scalars.
Definition: QuEST.c:404
void initClassicalState(Qureg qureg, long long int stateInd)
Initialise qureg into the classical state (also known as a "computational basis state") with index st...
Definition: QuEST.c:134
void pauliY(Qureg qureg, int targetQubit)
Apply the single-qubit Pauli-Y (also known as the Y or sigma-Y) gate.
Definition: QuEST.c:443
@ INVERSE_NORM
Definition: QuEST.h:232
Represents a system of qubits.
Definition: QuEST.h:322
void controlledPhaseShift(Qureg qureg, int idQubit1, int idQubit2, qreal angle)
Introduce a phase factor on state of qubits idQubit1 and idQubit2.
Definition: QuEST.c:498
void mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal prob)
Mixes a density matrix qureg to induce two-qubit dephasing noise.
Definition: QuEST.c:1260
void controlledUnitary(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u)
Apply a general controlled unitary (single control, single target), which can include a global phase ...
Definition: QuEST.c:360
qreal ** imag
Definition: QuEST.h:190
void initDiagonalOp(DiagonalOp op, qreal *real, qreal *imag)
Overwrites the entire DiagonalOp op with the given real and imag complex elements.
Definition: QuEST.c:1537
void phaseShift(Qureg qureg, int targetQubit, qreal angle)
Shift the phase between and of a single qubit by a given angle.
Definition: QuEST.c:487
@ PRODUCT
Definition: QuEST.h:233
ComplexArray stateVec
Computational state amplitudes - a subset thereof in the MPI version.
Definition: QuEST.h:341
void controlledNot(Qureg qureg, int controlQubit, int targetQubit)
Apply the controlled not (single control, single target) gate, also known as the c-X,...
Definition: QuEST.c:524
qreal real[2][2]
Definition: QuEST.h:139
long long int getNumAmps(Qureg qureg)
Returns the number of complex amplitudes in a state-vector qureg.
Definition: QuEST.c:912
void 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)
Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...
Definition: QuEST.c:778
long long int numElemsPerChunk
The number of the 2^numQubits amplitudes stored on each distributed node.
Definition: QuEST.h:302
void initDiagonalOpFromPauliHamil(DiagonalOp op, PauliHamil hamil)
Populates the diagonal operator op to be equivalent to the given Pauli Hamiltonian hamil,...
Definition: QuEST.c:1550
int isDensityMatrix
Whether this instance is a density-state representation.
Definition: QuEST.h:325
void reportQuESTEnv(QuESTEnv env)
Report information about the QuEST environment.
int numQubits
Definition: QuEST.h:188
void pauliX(Qureg qureg, int targetQubit)
Apply the single-qubit Pauli-X (also known as the X, sigma-X, NOT or bit-flip) gate.
Definition: QuEST.c:432
Qureg createCloneQureg(Qureg qureg, QuESTEnv env)
Create a new Qureg which is an exact clone of the passed qureg, which can be either a state-vector or...
Definition: QuEST.c:64
qreal calcExpecPauliSum(Qureg qureg, enum pauliOpType *allPauliCodes, qreal *termCoeffs, int numSumTerms, Qureg workspace)
Computes the expected value of a sum of products of Pauli operators.
Definition: QuEST.c:1210
void controlledTwoQubitUnitary(Qureg qureg, int controlQubit, int targetQubit1, int targetQubit2, ComplexMatrix4 u)
Apply a general controlled two-qubit unitary (including a global phase factor).
Definition: QuEST.c:269
void applyFullQFT(Qureg qureg)
Applies the quantum Fourier transform (QFT) to the entirety of qureg.
Definition: QuEST.c:876
int numQubits
The number of qubits informing the Hilbert dimension of the Hamiltonian.
Definition: QuEST.h:287
int numQubitsRepresented
The number of qubits represented in either the state-vector or density matrix.
Definition: QuEST.h:327
long long int numAmpsTotal
Total number of amplitudes, which are possibly distributed among machines.
Definition: QuEST.h:334
@ SCALED_DISTANCE
Definition: QuEST.h:234
int syncQuESTSuccess(int successCode)
Performs a logical AND on all successCodes held by all processes.
qreal * real
The real values of the 2^numQubits complex elements.
Definition: QuEST.h:308
qreal real
Definition: QuEST.h:105
void mixDensityMatrix(Qureg combineQureg, qreal prob, Qureg otherQureg)
Modifies combineQureg to become (1-prob)combineProb + prob otherQureg.
Definition: QuEST.c:1012
Qureg createQureg(int numQubits, QuESTEnv env)
Creates a state-vector Qureg object representing a set of qubits which will remain in a pure state.
Definition: QuEST.c:36
void destroyPauliHamil(PauliHamil hamil)
Destroy a PauliHamil instance, created with either createPauliHamil() or createPauliHamilFromFile().
Definition: QuEST.c:1414
void tGate(Qureg qureg, int targetQubit)
Apply the single-qubit T gate.
Definition: QuEST.c:476
void multiRotateZ(Qureg qureg, int *qubits, int numQubits, qreal angle)
Apply a multi-qubit Z rotation, also known as a phase gadget, on a selected number of qubits.
Definition: QuEST.c:652
qreal imag
Definition: QuEST.h:106
void applyParamNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams)
Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...
Definition: QuEST.c:831
@ SCALED_INVERSE_SHIFTED_DISTANCE
Definition: QuEST.h:234
void seedQuEST(QuESTEnv *env, unsigned long int *seedArray, int numSeeds)
Seeds the random number generator with a custom array of key(s), overriding the default keys.
void mixPauli(Qureg qureg, int targetQubit, qreal probX, qreal probY, qreal probZ)
Mixes a density matrix qureg to induce general single-qubit Pauli noise.
Definition: QuEST.c:1303
void hadamard(Qureg qureg, int targetQubit)
Apply the single-qubit Hadamard gate.
Definition: QuEST.c:176
Represents one complex number.
Definition: QuEST.h:103
void applyMatrix2(Qureg qureg, int targetQubit, ComplexMatrix2 u)
Apply a general 2-by-2 matrix, which may be non-unitary.
Definition: QuEST.c:1084
QuESTEnv createQuESTEnv(void)
Create the QuEST execution environment.
void rotateZ(Qureg qureg, int rotQubit, qreal angle)
Rotate a single qubit by a given angle around the Z-axis of the Bloch-sphere (also known as a phase s...
Definition: QuEST.c:209
@ SCALED_NORM
Definition: QuEST.h:232
@ SCALED_INVERSE_PRODUCT
Definition: QuEST.h:233
void multiControlledUnitary(Qureg qureg, int *controlQubits, int numControlQubits, int targetQubit, ComplexMatrix2 u)
Apply a general multiple-control single-target unitary, which can include a global phase factor.
Definition: QuEST.c:373
void initZeroState(Qureg qureg)
Initialise qureg into the zero state.
Definition: QuEST.c:113
qreal calcDensityInnerProduct(Qureg rho1, Qureg rho2)
Computes the Hilbert-Schmidt scalar product (which is equivalent to the Frobenius inner product of ma...
Definition: QuEST.c:1158
Qureg createDensityQureg(int numQubits, QuESTEnv env)
Creates a density matrix Qureg object representing a set of qubits which can enter noisy and mixed st...
Definition: QuEST.c:50
qreal * firstLevelReduction
Storage for reduction of probabilities on GPU.
Definition: QuEST.h:348
void applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)
Applies a trotterisation of unitary evolution to qureg.
Definition: QuEST.c:1070
PauliHamil createPauliHamil(int numQubits, int numSumTerms)
Dynamically allocates a Hamiltonian expressed as a real-weighted sum of products of Pauli operators.
Definition: QuEST.c:1398
void initPlusState(Qureg qureg)
Initialise qureg into the plus state.
Definition: QuEST.c:125
qreal calcExpecPauliProd(Qureg qureg, int *targetQubits, enum pauliOpType *pauliCodes, int numTargets, Qureg workspace)
Computes the expected value of a product of Pauli operators.
Definition: QuEST.c:1201
void controlledCompactUnitary(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta)
Apply a controlled unitary (single control, single target) parameterised by two given complex scalars...
Definition: QuEST.c:417
void multiStateControlledUnitary(Qureg qureg, int *controlQubits, int *controlState, int numControlQubits, int targetQubit, ComplexMatrix2 u)
Apply a general single-qubit unitary with multiple control qubits, conditioned upon a specific bit se...
Definition: QuEST.c:388
void sqrtSwapGate(Qureg qureg, int qb1, int qb2)
Performs a sqrt SWAP gate between qubit1 and qubit2.
Definition: QuEST.c:639
bitEncoding
Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...
Definition: QuEST.h:269
void mixMultiQubitKrausMap(Qureg qureg, int *targets, int numTargets, ComplexMatrixN *ops, int numOps)
Apply a general N-qubit Kraus map to a density matrix, as specified by at most (2N)^2 Kraus operators...
Definition: QuEST.c:1334
void printRecordedQASM(Qureg qureg)
Print recorded QASM to stdout.
Definition: QuEST.c:99
void 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.c:1594
DiagonalOp createDiagonalOp(int numQubits, QuESTEnv env)
Creates a DiagonalOp representing a diagonal operator on the full Hilbert space of a Qureg.
Definition: QuEST.c:1518
Represents a 2x2 matrix of complex numbers.
Definition: QuEST.h:137
void controlledRotateY(Qureg qureg, int controlQubit, int targetQubit, qreal angle)
Applies a controlled rotation by a given angle around the Y-axis of the Bloch-sphere.
Definition: QuEST.c:232
@ SCALED_INVERSE_NORM
Definition: QuEST.h:232