Ejemplo n.º 1
0
def Unitary2Chi(U, B = None):
    """
    map unitary process U onto the according chi matrix
    option: provide an orthogonal basis B instead of the standard
    Pauli basis for the chi matrix
    """

    NumberOfQubits  = int(np.log2(U.shape[0]))
    chidim = 4**NumberOfQubits

    a = proctom.getopbase()

    A = a

    for k in xrange(NumberOfQubits-1):
        A = proctom.baseappend(A,a)

    lam = np.zeros(chidim, dtype=complex)
    for k in xrange(chidim):
        lam[k] = np.trace(np.dot(A[k].transpose().conjugate(),U))/2**NumberOfQubits

    chi = np.zeros((chidim,chidim), dtype=complex)
    for k in xrange(chidim):
        for l in xrange(chidim):
            chi[k,l]=lam[k]*lam[l].conjugate()
    return chi
Ejemplo n.º 2
0
def chirotinfidel(rot_vector, ideal_chi, my_chi,return_chi=False):
    "The infidelity function"
    NrOfQubits = int(len(rot_vector)/3)
    # rz = expm(-1j*pi/2 * rot_vector[0] * X)
    # ry = expm(-1j*pi/2 * rot_vector[1] * Y)
    # rx = expm(-1j*pi/2 * rot_vector[2] * X)
    R = lambda rot_vector: np.dot(expm(-1j*pi/2 * rot_vector[2] * X),np.dot(expm(-1j*pi/2 * rot_vector[1] * Y),expm(-1j*pi/2 * rot_vector[0] * X)))

    Rtot = 1
    AllPaulis = [1]
    for k in xrange(NrOfQubits):
        Rtot = npml.kron(Rtot, R(rot_vector[3*k:3*k+3]))
        AllPaulis = proctom.baseappend(AllPaulis, Paulis)

    k = 0
    l = 0
    res1 = np.zeros((4**NrOfQubits,4**NrOfQubits),dtype=np.complex)
    for p_matrix in AllPaulis:
        RA = np.dot(Rtot, p_matrix)
        for p_matrix2 in AllPaulis:
            res0 = np.dot(p_matrix2.conj().T, RA) / 2**NrOfQubits
            res1[k,l] = np.trace(res0)
            l += 1
        l = 0
        k += 1

    chirot = np.dot(res1.T,np.dot(my_chi, res1.conj()))
#    IF1 = np.real(1-np.trace(np.dot(ideal_chi,chirot)))
#    IF1 = np.real(1-np.sum(ideal_chi*chirot.transpose()))
#    IF = np.real(1-np.diag(np.dot(ideal_chi,chirot)))
    IF = np.real(1-np.sum(ideal_chi*chirot.transpose(),axis=1))
    if return_chi:
        return chirot
    else:
        return IF
Ejemplo n.º 3
0
def Unitary2Chi(U, B=None):
    """
    map unitary process U onto the according chi matrix
    option: provide an orthogonal basis B instead of the standard
    Pauli basis for the chi matrix
    """

    NumberOfQubits = int(np.log2(U.shape[0]))
    chidim = 4**NumberOfQubits

    a = proctom.getopbase()

    A = a

    for k in xrange(NumberOfQubits - 1):
        A = proctom.baseappend(A, a)

    lam = np.zeros(chidim, dtype=complex)
    for k in xrange(chidim):
        lam[k] = np.trace(np.dot(A[k].transpose().conjugate(),
                                 U)) / 2**NumberOfQubits

    chi = np.zeros((chidim, chidim), dtype=complex)
    for k in xrange(chidim):
        for l in xrange(chidim):
            chi[k, l] = lam[k] * lam[l].conjugate()
    return chi