Reputation: 21
First of all i apologyse for any error i have, english is not my native lenguage.
Ok so i must implement quantum teleportation in python without using any quantum library, just with linear algebra, i already implement a way to get Hadamard and PauliX, im struggling to get the CNOT gate between q1 and q2 and the CNOT gate between q0 and q1, also i need a way to measure the final result as in the image, i already know the CNOT gate is a 8*8 matrix, and in another post i could see what that matrix is, but i dont know the steps to get that matrix, also as a plus, i need to implement cz gate too.
Upvotes: 2
Views: 1175
Reputation: 529
I don't know if you are using Qiskit or not. I have never used Numpy to draw a Qauntum Circuit. Qiskit is a framework to do quantum programming in python. I use Qiskit for creating this type of circuits. Here is an example:
from qiskit import *
from qiskit.circuit import Gate
n = 3
qr = QuantumRegister(n, 'q')
an = QuantumRegister(1, 'ancilla')
cr = ClassicalRegister(1, 'c')
circuit = QuantumCircuit(an, qr, cr)
circuit.h(qr[2])
circuit.cx(qr[2], qr[1])
circuit.cx(qr[1], qr[0])
circuit.cz(qr[1], qr[2])
circuit.cy(qr[1], qr[2])
circuit.x(qr[1])
circuit.swap(qr[0], qr[1])
circuit.barrier(qr)
circuit.cu1("Pi", an[0], qr[1])
circuit.cu1("Pi/3", an[0], qr[0])
circuit.swap(qr[0], qr[1])
circuit.x(qr[1])
circuit.cx(qr[1], qr[0])
circuit.cx(qr[2], qr[1])
circuit.measure(qr[0], cr[0])
circuit.draw(output='mpl')
This code will generate the following circuit:
Here, I tried to cover all the most important gates and functionalities in Qiskit. I hope you will find this useful. If it is useful don't forget to hit the upvote button. Happy Quantum Computing. :)
Upvotes: 2