Skip to content

Instantly share code, notes, and snippets.

@HuangJunye
Created September 28, 2020 15:46
Show Gist options
  • Save HuangJunye/7b12d4cfee0880519bfb411aedca2431 to your computer and use it in GitHub Desktop.
Save HuangJunye/7b12d4cfee0880519bfb411aedca2431 to your computer and use it in GitHub Desktop.
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