Open perak opened 5 years ago
Good example is teleportation circuit:
QASM:
OPENQASM 2.0; include "qelib1.inc"; qreg q[3]; creg c0[1]; creg c1[1]; rx (pi/4) q[0]; h q[1]; cx q[1], q[2]; cx q[0], q[1]; h q[0]; measure q[1] -> c1[0]; if(c1==1) x q[2]; measure q[0] -> c0[0]; if(c0==1) z q[2];
When exported to Cirq, code currently looks like this:
import cirq import numpy as np q = [cirq.NamedQubit('q' + str(i)) for i in range(3)] circuit = cirq.Circuit.from_ops( cirq.Rx(np.pi / 4)(q[0]), cirq.H(q[1]), cirq.CNOT(q[1], q[2]), cirq.CNOT(q[0], q[1]), cirq.H(q[0]), cirq.measure(q[1], key='c10'), # Export to cirq WARNING: classical control not implemented yet. cirq.X(q[2]), cirq.measure(q[0], key='c00'), # Export to cirq WARNING: classical control not implemented yet. cirq.Z(q[2]) ) simulator = cirq.Simulator() result = simulator.run(circuit) print(result)
Good example is teleportation circuit:
QASM:
When exported to Cirq, code currently looks like this: