コード例 #1
0
def qproc(bf):

    c.h[ga4]
    q.cccccx(c, bf, ga0, ga1, ga2, ga3, ga4)
    c.h[ga4]

    c.cx[bf, ga0].ry(-np.pi / 4)[ga0].cx[bf, ga0].ry(np.pi / 4)[ga0].cx[bf,
                                                                        ga0]
    c.cx[bf, ga1].ry(-np.pi / 4)[ga1].cx[bf, ga1].ry(np.pi / 4)[ga1].cx[bf,
                                                                        ga1]
    c.cx[bf, ga2].ry(-np.pi / 4)[ga2].cx[bf, ga2].ry(np.pi / 4)[ga2].cx[bf,
                                                                        ga2]
    c.cx[bf, ga3].ry(-np.pi / 4)[ga3].cx[bf, ga3].ry(np.pi / 4)[ga3].cx[bf,
                                                                        ga3]
    c.cx[bf, ga4].ry(-np.pi / 4)[ga4].cx[bf, ga4].ry(np.pi / 4)[ga4].cx[bf,
                                                                        ga4]
    c.cx[bf, ga0].cx[bf, ga1].cx[bf, ga2].cx[bf, ga3].cx[bf, ga4]

    c.h[ga4]
    q.cccccx(c, bf, ga0, ga1, ga2, ga3, ga4)
    c.h[ga4]

    c.cx[bf, ga0].cx[bf, ga1].cx[bf, ga2].cx[bf, ga3].cx[bf, ga4]
    c.cx[bf, ga4].ry(-np.pi / 4)[ga4].cx[bf, ga4].ry(np.pi / 4)[ga4].cx[bf,
                                                                        ga4]
    c.cx[bf, ga3].ry(-np.pi / 4)[ga3].cx[bf, ga3].ry(np.pi / 4)[ga3].cx[bf,
                                                                        ga3]
    c.cx[bf, ga2].ry(-np.pi / 4)[ga2].cx[bf, ga2].ry(np.pi / 4)[ga2].cx[bf,
                                                                        ga2]
    c.cx[bf, ga1].ry(-np.pi / 4)[ga1].cx[bf, ga1].ry(np.pi / 4)[ga1].cx[bf,
                                                                        ga1]
    c.cx[bf, ga0].ry(-np.pi / 4)[ga0].cx[bf, ga0].ry(np.pi / 4)[ga0].cx[bf,
                                                                        ga0]

    return
コード例 #2
0
ファイル: q-camgr.py プロジェクト: gigagulin/q-cams
def amp():

    c.h[:].x[:].h[N - 1]
    q.cccccx(c, 0, 1, 2, 3, 4, 5)
    c.h[N - 1].x[:].h[:]

    return
コード例 #3
0
ファイル: q-camgr.py プロジェクト: gigagulin/q-cams
def marking():  # marking |11111>

    c.h[N - 1]
    q.cccccx(c, 0, 1, 2, 3, 4, 5)
    c.h[N - 1]

    return
コード例 #4
0
def qproc():

    c.x[2, 3, 4].h[N - 1]  # qubit in x gate depends on vector you want to mark
    qmcn.cccccx(c, 0, 1, 2, 3, 4, 5)
    c.h[N - 1].x[2, 3, 4]  # qubit in x gate depends on vector you want to mark

    c.h[:].x[:].h[N - 1]  # amplifier
    qmcn.cccccx(c, 0, 1, 2, 3, 4, 5)
    c.h[N - 1].x[:].h[:]

    return
コード例 #5
0
ファイル: q-camgra.py プロジェクト: gigagulin/q-cams
def qproc():

    c.h[N - 1]
    qmcn.cccccx(c, 0, 1, 2, 3, 4, 5)  # marking |11111>
    c.h[N - 1]

    c.h[:].x[:].h[N - 1]  # amplifier
    qmcn.cccccx(c, 0, 1, 2, 3, 4, 5)
    c.h[N - 1].x[:].h[:]

    return
コード例 #6
0
ファイル: q-cambbr.py プロジェクト: gigagulin/q-cams
def qproc():

    for i in range(N):
        c.cx[R0[i], R1[i]]  # copy to R1

    c.x[XC0, XC1, XC2]  #  carrier flag sets when the carrier is empty, XCn=1

    for i in range(N):  # first round

        q.cccx(c, R0[i], R1[i], XC0,
               CA0)  # if R0=R1=1 and CA0(XC0=1) is empty, loading to CA0
        c.ccx[R1[i], CA0, XC0]  # if CA0 is loaded, XC0 turns

        q.ccccx(
            c, R0[i], R1[i], XC0, XC1, CA1
        )  # if R0=R1=1=1 and CA0 is occupied and CA1(XC1=1) is empty, loading to CA1
        c.ccx[R1[i], CA1, XC1].ccx[R1[i], CA1,
                                   XC0]  # if CA1 is loaded, XC1 turns

        q.cccccx(
            c, R0[i], R1[i], XC0, XC1, XC2, CA2
        )  # if R0=R1=1=1and CA0 and CA1 are occupied and CA2(XC2=1) is empty, loading to CA2
        c.ccx[R1[i], CA2, XC2]  # if CA2 is loaded, XC2 turns

        c.x[R0[i], CA2, XC2].ccx[
            R0[i], XC2,
            CA2]  # if R0 and R1 are empty and CA2(XC2=0) is occupied, unloding from CA2
        c.ccx[XC2, CA2, R0[i]].x[R0[i], R1[i]]  # if CA2 is changed, R0 turns
        q.cccx(
            c, R0[i], R1[i], CA2, XC2
        )  # if CA2 is changed, R0[i] are ocuippied and R1[i] is empty, XC2 turns
        c.x[R1[i], CA2, XC2]

        c.x[R0[i], CA1, XC1].ccx[
            R0[i], XC1,
            CA1]  # if R0 and R1 are empty and CA1(XC1=0) is occupied, unloding from CA1
        c.ccx[XC1, CA1, R0[i]].x[R0[i], R1[i]]  # if CA1 is changed, R0 turns
        q.cccx(
            c, R0[i], R1[i], CA1, XC1
        )  # if CA1 is changed, R0[i] are ocuippied and R1[i] is empty, XC1 turns
        c.x[R1[i], CA1, XC1]

        c.x[R0[i], CA0, XC0].ccx[
            R0[i], XC0,
            CA0]  # if R0 and R1 are empty and CA0(XC0=0) is occupied, unloding from CA0
        c.ccx[XC0, CA0, R0[i]].x[R0[i], R1[i]]  # if CA0 is changed, R0 turns
        q.cccx(
            c, R0[i], R1[i], CA0, XC0
        )  # if CA0 is changed, R0[i] are ocuippied and R1[i] is empty, XC0 turns
        c.x[R1[i], CA0, XC0]

    #for i in range(N):					# second round (unloading only)
    # to prevnet a contradiction of periodic boundary conditions
    for i in range(4):

        c.x[R0[i], R2[i], CA2, XC2]
        c.ccx[
            R0[i], XC2,
            CA2]  # if R0 is empty and CA2(XC2=0)is occupied, unloading from CA2
        c.ccx[CA2, XC2, R2[i]].x[R2[i]]  # if CA2 is chnaged, R2 turns
        c.ccx[R2[i], CA2, XC2].x[R0[i], CA2,
                                 XC2]  # if CA2 is chnaged, XC2 turns

        c.x[R0[i], R2[i], CA1, XC1]
        q.ccccx(
            c, R0[i], R2[i], XC2, XC1, CA1
        )  # if R0 is empty, CA1(XC1=0)is occupied and R2 and XC2 is unchanged, unloading from CA1
        c.ccx[CA1, XC1, R2[i]].x[R2[i]]  # if CA1 is chnaged, R2 turns
        c.ccx[R2[i], CA1, XC1].x[R0[i], CA1,
                                 XC1]  # if CA1 is chnaged, XC1 turns

        c.x[R0[i], R2[i], CA0, XC0]
        q.cccccx(
            c, R0[i], R2[i], XC2, XC1, XC0, CA0
        )  # if R0 is empty, CA0(XC0=0)is occupied and R2,XC2 and XC1 is unchanged, unloading from CA0
        c.ccx[CA0, XC0, R2[i]].x[R2[i]]  # if CA0 is chnaged, R2 turns
        c.ccx[R2[i], CA0, XC0].x[R0[i], CA0,
                                 XC0]  # if CA0 is chnaged, XC0 turns

    for i in range(N):
        c.cx[R1[i], R0[i]]
    #	c.cx[R2[i],R0[i]]

    for i in range(4):
        c.cx[R2[i], R0[i]]

    return