QuEST_qasm.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 
9 # ifndef QUEST_QASM_H
10 # define QUEST_QASM_H
11 
12 # include "QuEST.h"
13 # include "QuEST_precision.h"
14 
15 # ifdef __cplusplus
16 extern "C" {
17 # endif
18 
20 typedef enum {
35 } TargetGate;
36 
37 void qasm_setup(Qureg* qureg);
38 
39 void qasm_startRecording(Qureg qureg);
40 
41 void qasm_stopRecording(Qureg qureg);
42 
43 void qasm_recordGate(Qureg qureg, TargetGate gate, int targetQubit);
44 
45 void qasm_recordParamGate(Qureg qureg, TargetGate gate, int targetQubit, qreal param);
46 
47 void qasm_recordCompactUnitary(Qureg qureg, Complex alpha, Complex beta, int targetQubit);
48 
49 void qasm_recordUnitary(Qureg qureg, ComplexMatrix2 u, int targetQubit);
50 
51 void qasm_recordAxisRotation(Qureg qureg, qreal angle, Vector axis, int targetQubit);
52 
53 void qasm_recordControlledGate(Qureg qureg, TargetGate gate, int controlQubit, int targetQubit);
54 
55 void qasm_recordControlledParamGate(Qureg qureg, TargetGate gate, int controlQubit, int targetQubit, qreal param);
56 
57 void qasm_recordControlledCompactUnitary(Qureg qureg, Complex alpha, Complex beta, int controlQubit, int targetQubit);
58 
59 void qasm_recordControlledUnitary(Qureg qureg, ComplexMatrix2 u, int controlQubit, int targetQubit);
60 
61 void qasm_recordControlledAxisRotation(Qureg qureg, qreal angle, Vector axis, int controlQubit, int targetQubit);
62 
64 TargetGate gate, int* controlQubits, int numControlQubits, int targetQubit);
65 
66 void qasm_recordMultiControlledParamGate(Qureg qureg, TargetGate gate, int* controlQubits, int numControlQubits, int targetQubit, qreal param);
67 
68 void qasm_recordMultiControlledUnitary(Qureg qureg, ComplexMatrix2 u, int* controlQubits, int numControlQubits, int targetQubit);
69 
70 void qasm_recordMultiStateControlledUnitary(Qureg qureg, ComplexMatrix2 u, int* controlQubits, int* controlState, int numControlQubits, int targetQubit);
71 
72 void qasm_recordMultiControlledMultiQubitNot(Qureg qureg, int* ctrls, int numCtrls, int* targs, int numTargs);
73 
74 /* not actually used. D'oh!
75 void qasm_recordMultiControlledAxisRotation(Qureg qureg, qreal angle, Vector axis, int* controlQubits, int numControlQubits, int targetQubit);\
76 */
77 
78 void qasm_recordMeasurement(Qureg qureg, int measureQubit);
79 
80 void qasm_recordInitZero(Qureg qureg);
81 
82 void qasm_recordInitPlus(Qureg qureg);
83 
84 void qasm_recordInitClassical(Qureg qureg, long long int stateInd);
85 
86 void qasm_recordPhaseFunc(Qureg qureg, int* qubits, int numQubits, enum bitEncoding encoding, qreal* coeffs, qreal* exponents, int numTerms, long long int* overrideInds, qreal* overridePhases, int numOverrides);
87 
88 void qasm_recordMultiVarPhaseFunc(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);
89 
90 void qasm_recordNamedPhaseFunc(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);
91 
92 void qasm_recordComment(Qureg qureg, char* comment, ...);
93 
94 void qasm_clearRecorded(Qureg qureg);
95 
96 void qasm_printRecorded(Qureg qureg);
97 
98 int qasm_writeRecordedToFile(Qureg qureg, char* filename);
99 
100 void qasm_free(Qureg qureg);
101 
102 # ifdef __cplusplus
103 }
104 # endif
105 
106 # endif // QUEST_QASM_H
Represents a 3-vector of real numbers.
Definition: QuEST.h:198
void qasm_startRecording(Qureg qureg)
Definition: QuEST_qasm.c:85
void qasm_recordInitClassical(Qureg qureg, long long int stateInd)
Definition: QuEST_qasm.c:471
void qasm_setup(Qureg *qureg)
Definition: QuEST_qasm.c:61
@ GATE_T
Definition: QuEST_qasm.h:24
@ GATE_PHASE_SHIFT
Definition: QuEST_qasm.h:32
@ GATE_ROTATE_X
Definition: QuEST_qasm.h:27
void qasm_recordPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)
Definition: QuEST_qasm.c:490
@ GATE_ROTATE_Z
Definition: QuEST_qasm.h:29
void qasm_printRecorded(Qureg qureg)
Definition: QuEST_qasm.c:871
@ GATE_SIGMA_Z
Definition: QuEST_qasm.h:23
void qasm_stopRecording(Qureg qureg)
Definition: QuEST_qasm.c:89
@ GATE_HADAMARD
Definition: QuEST_qasm.h:26
void qasm_recordMultiVarPhaseFunc(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)
Definition: QuEST_qasm.c:666
void qasm_recordControlledParamGate(Qureg qureg, TargetGate gate, int controlQubit, int targetQubit, qreal param)
Definition: QuEST_qasm.c:248
#define qreal
void qasm_recordInitPlus(Qureg qureg)
Definition: QuEST_qasm.c:443
void qasm_recordMultiControlledParamGate(Qureg qureg, TargetGate gate, int *controlQubits, int numControlQubits, int targetQubit, qreal param)
Definition: QuEST_qasm.c:325
@ GATE_SQRT_SWAP
Definition: QuEST_qasm.h:34
phaseFunc
Flags for specifying named phase functions.
Definition: QuEST.h:231
void qasm_recordControlledUnitary(Qureg qureg, ComplexMatrix2 u, int controlQubit, int targetQubit)
additionally performs Rz on target to restore the global phase lost from u in QASM U(a,...
Definition: QuEST_qasm.c:279
@ GATE_SIGMA_X
Definition: QuEST_qasm.h:21
void qasm_recordParamGate(Qureg qureg, TargetGate gate, int targetQubit, qreal param)
Definition: QuEST_qasm.c:187
void qasm_recordMultiControlledGate(Qureg qureg, TargetGate gate, int *controlQubits, int numControlQubits, int targetQubit)
Definition: QuEST_qasm.c:317
@ GATE_UNITARY
Definition: QuEST_qasm.h:31
void qasm_recordCompactUnitary(Qureg qureg, Complex alpha, Complex beta, int targetQubit)
Definition: QuEST_qasm.c:196
Represents a system of qubits.
Definition: QuEST.h:322
void qasm_recordAxisRotation(Qureg qureg, qreal angle, Vector axis, int targetQubit)
Definition: QuEST_qasm.c:224
void qasm_recordGate(Qureg qureg, TargetGate gate, int targetQubit)
Definition: QuEST_qasm.c:179
void qasm_recordMeasurement(Qureg qureg, int measureQubit)
Definition: QuEST_qasm.c:411
void qasm_recordInitZero(Qureg qureg)
Definition: QuEST_qasm.c:428
int qasm_writeRecordedToFile(Qureg qureg, char *filename)
returns success of file write
Definition: QuEST_qasm.c:876
void qasm_recordMultiStateControlledUnitary(Qureg qureg, ComplexMatrix2 u, int *controlQubits, int *controlState, int numControlQubits, int targetQubit)
Definition: QuEST_qasm.c:363
void qasm_clearRecorded(Qureg qureg)
Definition: QuEST_qasm.c:864
@ GATE_S
Definition: QuEST_qasm.h:25
@ GATE_SWAP
Definition: QuEST_qasm.h:33
TargetGate
! Identifiers of single-target gates
Definition: QuEST_qasm.h:20
void qasm_recordNamedPhaseFunc(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)
Definition: QuEST_qasm.c:726
@ GATE_ROTATE_AROUND_AXIS
Definition: QuEST_qasm.h:30
@ GATE_SIGMA_Y
Definition: QuEST_qasm.h:22
void qasm_recordControlledGate(Qureg qureg, TargetGate gate, int controlQubit, int targetQubit)
Definition: QuEST_qasm.c:239
Represents one complex number.
Definition: QuEST.h:103
void qasm_recordMultiControlledUnitary(Qureg qureg, ComplexMatrix2 u, int *controlQubits, int numControlQubits, int targetQubit)
additionally performs Rz on target to restore the global phase lost from u in QASM U(a,...
Definition: QuEST_qasm.c:342
void qasm_free(Qureg qureg)
Definition: QuEST_qasm.c:887
void qasm_recordMultiControlledMultiQubitNot(Qureg qureg, int *ctrls, int numCtrls, int *targs, int numTargs)
Definition: QuEST_qasm.c:382
void qasm_recordUnitary(Qureg qureg, ComplexMatrix2 u, int targetQubit)
Definition: QuEST_qasm.c:208
@ GATE_ROTATE_Y
Definition: QuEST_qasm.h:28
void qasm_recordControlledAxisRotation(Qureg qureg, qreal angle, Vector axis, int controlQubit, int targetQubit)
Definition: QuEST_qasm.c:301
bitEncoding
Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...
Definition: QuEST.h:269
void qasm_recordControlledCompactUnitary(Qureg qureg, Complex alpha, Complex beta, int controlQubit, int targetQubit)
Definition: QuEST_qasm.c:265
Represents a 2x2 matrix of complex numbers.
Definition: QuEST.h:137
void qasm_recordComment(Qureg qureg, char *comment,...)
Definition: QuEST_qasm.c:121