from converter.qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister qr = QuantumRegister(3) cr = ClassicalRegister(3) qc = QuantumCircuit(qr, cr) qc.ccx(qr[0], qr[1], qr[2]) qc.x(qr[0]) qc.ccx(qr[0], qr[1], qr[2]) qc.x(qr[1]) qc.ccx(qr[0], qr[1], qr[2]) qc.ccx(qr[0], qr[1], qr[2]) qc.ccx(qr[0], qr[1], qr[2]) qc.x(qr[0]) qc.ccx(qr[0], qr[1], qr[2]) qc.measure(qr, cr)
from converter.qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister qr = QuantumRegister(1) cr = ClassicalRegister(1) qc = QuantumCircuit(qr, cr) qc.x(qr) qc.measure(qr, cr)
from converter.qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute qr1 = QuantumRegister(1) qr2 = QuantumRegister(1) cr1 = ClassicalRegister(1) cr2 = ClassicalRegister(1) qc = QuantumCircuit(qr1, qr2, cr1, cr2) qc.cx(qr1[0], qr2[0]) qc.x(qr2[0]) qc.measure(qr2, cr2) execute(qc)
cin1 = ClassicalRegister(1) qin2 = QuantumRegister(1) cin2 = ClassicalRegister(1) #output bit: function XORed onto this qz = QuantumRegister(1) cz = ClassicalRegister(1) #output bit: function XORed onto this tmp = QuantumRegister(1) #beginning of the circuit circuit = QuantumCircuit(qin1, qin2, qz, tmp, cin1, cin2, cz) #initialize example values circuit.x(qin1) circuit.x(qin2) #initialize temp circuit.x(tmp) circuit.cx(tmp, qz) circuit.ccx(qin1, tmp, qz) circuit.ccx(qin2, tmp, qz) #reversing tmp circuit.x(tmp) #circuit.measure(qin1, cin1) #circuit.measure(qin2, cin2) circuit.measure(qz, cz)
qin1 = QuantumRegister(1) cin1 = ClassicalRegister(1) qin2 = QuantumRegister(1) cin2 = ClassicalRegister(1) #output bit: function XORed onto this qz = QuantumRegister(1) cz = ClassicalRegister(1) #output bit: function XORed onto this tmp = QuantumRegister(1) #beginning of the circuit circuit = QuantumCircuit(qin1,qin2,qz,tmp,cin1,cin2,cz) #initialize temp circuit.x(tmp) circuit.cx(tmp, qz) circuit.ccx(qin1, tmp, qz) circuit.ccx(qin2, tmp, qz) #reversing tmp circuit.x(tmp) #circuit.measure(qin1, cin1) #circuit.measure(qin2, cin2) circuit.measure(qz, cz) execute(circuit)
qin1 = QuantumRegister(1) cin1 = ClassicalRegister(1) qin2 = QuantumRegister(1) cin2 = ClassicalRegister(1) #output bit: function XORed onto this qz = QuantumRegister(1) cz = ClassicalRegister(1) tmpq = QuantumRegister(1) tmpc = ClassicalRegister(1) #beginning of the circuit circuit = QuantumCircuit(qin1,qin2,qz,tmpq,cin1,cin2,cz,tmpc) #initialize example values circuit.x(qin1) circuit.x(qin2) #initialize temp circuit.x(tmpq) circuit.cx(tmpq, qz) circuit.ccx(qin1, tmpq, qz) circuit.ccx(qin2, tmpq, qz) #reversing tmp circuit.x(tmpq) #circuit.measure(qin1, cin1) #circuit.measure(qin2, cin2)
qin2 = QuantumRegister(n) cin2 = ClassicalRegister(n) #output bit: function XORed onto this qz = QuantumRegister(1) cz = ClassicalRegister(1) #output bit: function XORed onto this tmp = QuantumRegister(1) tmpc = ClassicalRegister(1) #beginning of the circuit circuit = QuantumCircuit(qin1, qin2, qz, tmp, cin1, cin2, cz, tmpc) #initialize example values circuit.x(qin1) circuit.x(qin2[1]) circuit.x(qin2[3]) #initialize temp circuit.x(tmp) #actually compare equal_nway(qin1, qin2, tmp, qz, n, circuit) #reversing tmp circuit.x(tmp) circuit.measure(qin1, cin1) circuit.measure(qin2, cin2)
#output bit: function XORed onto this qz = QuantumRegister(1) cz = ClassicalRegister(1) #output bit: function XORed onto this tmp = QuantumRegister(1) #beginning of the circuit circuit = QuantumCircuit(qin1,qin2,qz,tmp,cin1,cin2,cz) a = int(argv[1]) b = int(argv[2]) for i in range(100): if((a & 1) == 1): circuit.x(qin1[99 - i]) if((b & 1) == 1): circuit.x(qin2[99 - i]) a >>= 1 b >>= 1 #initialize temp circuit.x(tmp) equal_nway(qin1, qin2, tmp, qz, n, circuit) #reversing tmp circuit.x(tmp) circuit.measure(qin1, cin1) circuit.measure(qin2, cin2)
from converter.qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit qi = QuantumRegister(3) # a = qi[0]; b = qi[1]; ci = qi[2] qo = QuantumRegister(2) # so = qo[0]; co = qo[1] ci = ClassicalRegister(3) co = ClassicalRegister(2) circuit = QuantumCircuit(qi,qo,ci,co) ####### a = 1; b = 1; ci = 0 ####### circuit.x(qi[0]) circuit.x(qi[1]) #################################### for idx in range(3): circuit.cx(qi[idx], qo[0]) for idx in range(3): circuit.ccx(qi[idx], qi[(idx+1)%3], qo[1]) circuit.measure(qi, ci) circuit.measure(qo, co)
from converter.qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute qr1 = QuantumRegister(1) cr1 = ClassicalRegister(1) qc = QuantumCircuit(qr1, cr1) qc.x(qr1) qc.x(qr1) qc.x(qr1) qc.measure(qr1, cr1) execute(qc)