Open GiggleLiu opened 5 years ago
using Yao CRk(i::Int, j::Int, k::Int) = control([i, ], j=>shift(2π/(1<<k))) CRot(n::Int, i::Int) = chain(n, i==j ? kron(i=>H) : CRk(j, i, j-i+1) for j = i:n) QFTCircuit(n::Int) = chain(n, CRot(n, i) for i = 1:n)
OPENQASM 2.0; qreg q[4]; creg c[4]; h q[0]; cphase(π/2) q[1], q[0]; cphase(π/4) q[2], q[0]; cphase(π/8) q[3], q[0]; h q[1]; cphase(π/2) q[2], q[1]; cphase(π/4) q[3], q[1]; h q[2]; cphase(π/2) q[3], q[2]; h q[3]; measure q -> c;
H 0 CPHASE(1.5707963267948966) 1 0 CPHASE(0.7853981633974483) 2 0 CPHASE(0.39269908169872414) 3 0 H 1 CPHASE(1.5707963267948966) 2 1 CPHASE(0.7853981633974483) 3 1 H 2 CPHASE(1.5707963267948966) 3 2 H 3 MEASURE 0 1 2 3
Yao
open qasm
pyquil