-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircuit.qasm
More file actions
28 lines (28 loc) · 824 Bytes
/
circuit.qasm
File metadata and controls
28 lines (28 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
OPENQASM 2.0;
include "qelib1.inc";
// QPE: estimate eigenphase of T gate (phi = 1/8)
// q[0..2]: 3 counting qubits, q[3]: target eigenstate |1>
qreg q[4];
creg c[3];
// Prepare eigenstate |1> of T gate
x q[3];
// Superpose counting qubits
h q[0]; h q[1]; h q[2];
// Controlled-T^(2^k): T^1 = R_z(pi/4), T^2 = S = R_z(pi/2), T^4 = Z = R_z(pi)
// Controlled-T^4 from q[0] (MSB): cu1(pi)
cu1(3.141592653589793) q[0],q[3];
// Controlled-T^2 from q[1]: cu1(pi/2)
cu1(1.5707963267948966) q[1],q[3];
// Controlled-T^1 from q[2] (LSB): cu1(pi/4)
cu1(0.7853981633974483) q[2],q[3];
// Inverse QFT on counting register
swap q[0],q[2];
h q[0];
cu1(-1.5707963267948966) q[1],q[0];
h q[1];
cu1(-0.7853981633974483) q[2],q[0];
cu1(-1.5707963267948966) q[2],q[1];
h q[2];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];