Exemple #1
0
def get_rho10(state, prob, niter, dim, pm):
    # to calculate rho10
    # just for mixed state

    N = np.int(niter / 2)  #we just meas. 2 bases {+,-} and {L,R}
    rho10 = np.zeros((dim, dim), dtype=complex)
    temp_rs = np.zeros((N, 4, dim, dim))

    for i in range(N):
        temp_rs[i, :, :, :] = get_bisection(state, prob, dim, pm)

    ave_rs = np.zeros((4, dim, dim))
    for i in range(4):
        for j in range(dim):
            for k in range(dim):
                ave_rs[i, j, k] = cdf(temp_rs[:, i, j, k])
    for x in range(dim):
        for p in range(dim):
            rho10[x,p] = 1/2.0*(ave_rs[0,x,p]-ave_rs[1,x,p]+\
                            1j*(ave_rs[2,x,p]-ave_rs[3,x,p]))
    return rho10
Exemple #2
0
def get_rho10_rho11(state, prob, niter, dim, pm):
    # to calculate rho10 and rho11
    # just for mixed state

    N = np.int(niter / 2)
    rho10 = np.zeros((dim, dim), dtype=complex)
    rho11 = np.zeros((dim, dim), dtype=complex)
    temp_rs = np.zeros((N, 5, dim, dim))

    for i in range(N):
        temp_rs[i, :, :, :] = get_bisection(state, prob, dim, pm)

    ave_rs = np.zeros((5, dim, dim))
    for i in range(5):
        for j in range(dim):
            for k in range(dim):
                ave_rs[i, j, k] = cdf(temp_rs[:, i, j, k])
    for x in range(dim):
        for p in range(dim):
            rho10[x,p] = 1/2.0*(ave_rs[0,x,p]-ave_rs[1,x,p]+\
                            1j*(ave_rs[2,x,p]-ave_rs[3,x,p]))
            rho11[x, p] = ave_rs[4, x, p]
    return rho10, rho11
Exemple #3
0
def get_pqurec(state, theta, niter, prob, dim, pm):
    # to get pure quantum state

    sin_tt = sin(pi * theta)
    rpsi = np.real(state)
    ipsi = np.imag(state)
    psit = sqrt(sum(rpsi)**2 + sum(ipsi)**2)
    p0 = (sum(rpsi)**2 + sum(ipsi)**2) / dim

    N = np.int(niter * p0 / 2)
    temp_rs = np.zeros((N, 5, dim))

    for i in range(N):
        temp_rs[i, :, :] = get_bisection(state, prob, dim, pm)

    ave_rs = np.zeros((5, dim))
    for i in range(5):
        for j in range(dim):
            ave_rs[i, j] = cdf(temp_rs[:, i, j])

    rtemp = np.zeros(dim)
    itemp = np.zeros(dim)
    rnorm = 0.0
    for i in range(dim):
        rtemp[i] = (ave_rs[0,i]-ave_rs[1,i]+2.0*tan(pi*theta/2.0)*\
               ave_rs[4,i])*dim/(2*psit*sin_tt)
        itemp[i] = (ave_rs[2, i] - ave_rs[3, i]) * dim / (2 * psit * sin_tt)
        rnorm += rtemp[i]**2 + itemp[i]**2
    rtemp /= sqrt(rnorm)
    itemp /= sqrt(rnorm)

    restate = np.zeros((dim, dim), dtype=complex)
    for i in range(dim):
        for j in range(dim):
            restate[i,j] = (rtemp[i]+1j*itemp[i])*\
                        (rtemp[j]-1j*itemp[j])
    return restate