Created
September 28, 2020 15:46
-
-
Save HuangJunye/7b12d4cfee0880519bfb411aedca2431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sim_cir() | |
qc = QuantumCircuit() | |
qc.set_registers(3,3) | |
for slots = 1,8 do | |
for wires = 1,3 do | |
if (gates[wires][slots] == 2) then | |
qc.x(wires-1) | |
elseif (gates[wires][slots] == 3) then | |
qc.y(wires-1) | |
elseif (gates[wires][slots] == 4) then | |
qc.z(wires-1) | |
elseif (gates[wires][slots] == 5) then | |
qc.h(wires-1) | |
end | |
end | |
end | |
qc.measure(0,0) | |
qc.measure(1,1) | |
qc.measure(2,2) | |
result = simulate(qc,'expected_counts',1) | |
for key, value in pairs(result) do | |
print(key,value) | |
idx = tonum('0b'..key) + 1 | |
probs[idx]=value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment