0

With qutip, I'd like to simulate an error correcting code, so I'd like to manipulate qubit with specific gates.

Here is the part of my code :

def physicalToLogical():
    U=qt.cnot(N=5,control=0,target=1)
    V=qt.cnot(N=5,control=1,target=2)
    return U*V

e0=qt.basis(2,0)
e1=qt.basis(2,1)

m=(1/np.sqrt(2))*(e0+e1)
U=physicalToLogical()
QubitLogical=U*m

I'm not sure about how to use a gate properly.

Thanks for attention, please help if anyone knows the solution.

[EDIT]

Actually I just want to implement this type of circuit with qutip : circuit schema

I tried this :

def physicalToLogical():
        U=qt.cnot(N=5,control=0,target=1)
        V=qt.cnot(N=5,control=1,target=2)
        return U*V

    def mesuresyndrom():
        U=qt.cnot(N=5,control=0,target=3)
        V=qt.cnot(N=5,control=1,target=3)
        W=qt.cnot(N=5,control=0,target=4)
        X=qt.cnot(N=5,control=2,target=4)
        return U*V*W*X

    def errorcorrection(sdm,qL):
        if sdm[0]==state(0,1):
            if sdm[1]==state(0,1):
               U=qt.rx(phi,N=5,target=3)enter image description here
        else:
            if sdm[1]==state(1,0):
                U=qt.rx(pi,N=5,target=2)
        else:
            U=qt.rx(pi,N=5,target=1)
        return U

    q=[0 for i in range(32)]
    q[0]=1/np.sqrt(2)
    q[1]=1/np.sqrt(2)

I also tried this :

    def physicalToLogical(q):
    q1=[1,0]
    q2=[1,0]
    q1=np.dot(U,[q1,q])
    q2=np.dot(u,[q2,q])
    q2=q2[0][0]
    qL=[q,q1,q2]
    return q

def mesuresyndrom(qL):
    anc1= [1,0]
    anc2= [1,0]
    anc1=(qt.cnot())[q[0],anc1]
    print(q[0])
    anc1=np.dot(U,[q[1],anc1])
    anc2=np.dot(U,[q[0],anc1])
    anc2=np.dot(U,[q[2],anc1])
    return [anc1,anc2]

def errorcorrection(qL,sdm):
    if smd[0]==state(1,0):
        if smd[1]==state(0,1):
            qL[2]=sigmax(qL[2])
    else:
        if smd[1]==state(1,0):
            qL[1]=sigmax(qL[1])
        else:
            qL[0]=sigmax(qL[0])
    return qL
dedek
  • 7,981
  • 3
  • 38
  • 68
leila
  • 1
  • 3

0 Answers0