コード例 #1
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def satoshiConditions(N):
    s0STLM0 = 0
    s1STLM0 = 0
    s0STLM1 = 0
    s1STLM1 = 0

    for i in range(N):
        if i % 100 == 0:
            print(f'{i+1}/{N}')
        theta = np.random.rand() * np.pi / 4
        a0 = np.random.rand() * 2 * np.pi
        a1 = np.random.rand() * 2 * np.pi
        b0 = np.random.rand() * 2 * np.pi
        b1 = np.random.rand() * 2 * np.pi

        P = T.find_P(theta, a0, a1, b0, b1)
        correct1, realisation, wholeSp = T.twoQubitRepresentation(P)
        theta = realisation[0]
        correct2 = St.STLM(P, theta)
        if not correct1:
            print("no 2-qubit realisation????")
        if correct2 and wholeSp:
            s1STLM1 += 1
        elif correct2 and (not wholeSp):
            s0STLM1 += 1
        elif (not correct2) and wholeSp:
            s1STLM0 += 1
        elif (not correct2) and (not wholeSp):
            s0STLM0 += 1
        print(s0STLM0, s0STLM1, s1STLM0, s1STLM1)
コード例 #2
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
    def research(theta, a0, a1, b0, b1):
        def maximum(S):
            m = 0
            for x in range(2):
                for y in range(2):
                    if S[x][y] > m:
                        m = S[x][y]
            return m

        def getThetaFromSinSquared(s):
            return np.arccos(np.sqrt(1 - s))

        P = T.find_P(theta, a0, a1, b0, b1)
        S_p, S_m = St.SPlusTemp(P)
        print(S_p)
        print(S_m)
        flag = False
        for x in range(2):
            for y in range(2):
                thetaNew = getThetaFromSinSquared(S_p[x][y])
                Pnew = T.find_P(thetaNew, a0, a1, b0, b1)
                stlm = St.STLM(Pnew, thetaNew)
                print(stlm, "STLM")
                Qs = St.satoshiTest(Pnew)
                print(Qs, thetaNew)
                if Qs:
                    flag = True

        for x in range(2):
            for y in range(2):
                thetaNew = getThetaFromSinSquared(S_m[x][y])
                Pnew = T.find_P(thetaNew, a0, a1, b0, b1)
                stlm = St.STLM(Pnew, thetaNew)
                print(stlm, "STLM")
                Qs = St.satoshiTest(Pnew)
                print(Qs, thetaNew)
                if Qs:
                    flag = True
        print("i co?", flag)
コード例 #3
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def testWagnerPoints(N):
    for theta in np.linspace(0, np.pi / 4, N):
        P = Pp.WagnerPoints(theta)
        b = Pp.getWagnerB(theta)
        _, a0, a1, b0, b1 = Pp.WagnerRealisation(theta)
        wholeSp, theta = St.SPlusCondition(P)
        stlm = St.STLM(P, theta)
        if wholeSp and stlm:
            Qs = 1
        else:
            Qs = 0

        accuracy = 0.001
        Qn = T.is_exposed(theta, a0, a1, b0, b1, accuracy, limit=1)
        print(Qn, Qs)
コード例 #4
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def notUniquePointsInvestigating(N):
    for i in range(N):
        P = np.round(T.notUniquePoints(), 6)
        correct, realisation, wholeSp = T.twoQubitRepresentationSpecial(P)
        if correct:
            print(P, "point")

            theta, a0, a1, b0, b1 = realisation
            # print(correct, theta, a0/np.pi, a1/np.pi, b0/np.pi, b1/np.pi, wholeSp, np.sin(theta)**2, "tu")
            # print(P[0]/np.cos(theta), P[1]/np.cos(theta), P[2]/np.cos(theta), P[3]/np.cos(theta), "cosinusy prawdziwe")
            print(St.STLM(P, theta), "stlm")
            Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1)

            print(T.find_P(theta, a0, a1, b0, b1), "Punkt zwrotny")
            print(T.is_nonlocalPoint(P), "is nonlocal?")
            print(T.TLM(Ptlm), "Tlm")
            print(T.is_exposed(theta, a0, a1, b0, b1, 0.001), "exposed")
コード例 #5
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def notUniquePoint():
    # P = [0.4445537842667646, 0.24544802147218514, 0.734354006208671, 0.734354006208671, 0.542908951128687, 0.542908951128687, 0.3966948365612542, 0.3966948365612542]
    P5 = [0.024973, 0.058992, 0.5, 0.5, 0.07546, 0.07546, 0.092469, 0.092469]
    P4 = [
        0.25, 0.125, -0.262176, -0.0930301, -0.731555, -0.689269, -0.698783,
        0.654382
    ]
    P2 = [
        0.5, 0.5, -np.sqrt(2 / 5), 0, -np.sqrt(5 / 2) / 2,
        -np.sqrt(5 / 2) / 2 + 1 / np.sqrt(10), -np.sqrt(5 / 2) / 2,
        np.sqrt(5 / 2) / 2 - 1 / np.sqrt(10)
    ]
    P3 = [
        1 / 4, 1 / 2, -np.sqrt(7 / 3) / 3, 1 / np.sqrt(21),
        -37 / (12 * np.sqrt(21)), -37 / (12 * np.sqrt(21)) + 1 / 4 *
        (np.sqrt(7 / 3) / 3 + 1 / np.sqrt(21)),
        -np.sqrt(7 / 3) / 12 - 37 / (12 * np.sqrt(21)),
        -np.sqrt(7 / 3) / 12 + 43 / (12 * np.sqrt(21))
    ]
    b = np.random.rand()
    a1 = np.random.rand()
    a0 = np.random.rand()
    b = 0.5
    a0 = 0.25
    a1 = 0.5
    A0B0 = (a0 + a1 + a0 * b**2 - a1 * b**2) / (2 * b)
    A0B1 = A0B0
    A1B0 = A0B0 - b * (a0 - a1)
    A1B1 = A0B0 - b * (a0 - a1)
    P = [a0, a1, b, b, A0B0, A0B1, A1B0, A1B1]
    # if A0B0 < 1:
    print(P, "punkt")
    correct, realisation, wholeSp = T.twoQubitRepresentation(P)
    theta, a0, a1, b0, b1 = realisation
    # print(correct, theta, a0/np.pi, a1/np.pi, b0/np.pi, b1/np.pi, wholeSp, np.sin(theta)**2, "tu")
    # print(P[0]/np.cos(theta), P[1]/np.cos(theta), P[2]/np.cos(theta), P[3]/np.cos(theta), "cosinusy prawdziwe")
    print(St.STLM(P, theta), "stlm")
    Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1)

    print(T.find_P(theta, a0, a1, b0, b1), "Punkt zwrotny")

    print(T.TLM(Ptlm), "Tlm")
    print(T.is_exposed(theta, a0, a1, b0, b1, 0.001), "exposed")
コード例 #6
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def tlmVSstlm(N):
    for i in range(N):
        if i % 100 == 0:
            print(f'{i+1}/{N}')
        a0 = np.random.rand() * 2 * np.pi
        a1 = np.random.rand() * 2 * np.pi
        b0 = np.random.rand() * 2 * np.pi
        b1 = np.random.rand() * 2 * np.pi
        theta = np.random.rand() * np.pi / 2
        P1 = T.find_P(np.pi / 2, a0, a1, b0, b1)
        P2 = T.find_P(theta, a0, a1, b0, b1)
        tlm = T.TLM(P1)
        stlm = St.STLM(P2, theta)
        wholeSp, theta = St.SPlusCondition(P2)
        # print(tlm, stlm)
        if stlm and (not tlm):
            print(tlm, stlm)
        if stlm and (not tlm) and wholeSp:
            print(tlm, stlm, wholeSp)
            print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
コード例 #7
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def nonnegativitySingularity(N):
    for i in range(1):
        a0 = 0
        a1 = np.random.rand() * 2 * np.pi
        b0 = 0
        b1 = np.random.rand() * 2 * np.pi

        P = T.find_P(np.pi / 2, a0, a1, b0, b1)
        # print(P)
        tlm = T.TLM(P)
        # Sp, Sm = St.SPlusTemp(P)
        # print(Sp)
        # print(Sm)
        # theta = np.random.rand()*np.pi/2
        # thetaB = np.arcsin(T.hypoTreshold(a0,a1,b0,b1))
        # print(thetaB)
        thetaGr = np.arcsin(T.hypoTresholdImproved(a0, a1, b0, b1))

        print(thetaGr)
        Theta = np.linspace(0, np.pi / 2, N)
        for theta in Theta:
            # print(theta)
            # if i%100 == 0:
            #     print(i)
            P = T.find_P(theta, a0, a1, b0, b1)
            stlm = St.STLM(P, theta)

            c1, thetan = St.SPlusCondition(P)
            if theta >= thetaGr:
                c2 = 1
            else:
                c2 = 0
            # sat = St.satoshiTest(P)
            # ex = T.is_exposed(theta,a0,a1,b0,b1, 0.001)
            if c1 and (not stlm):
                stlm2 = St.STLMComment(P, theta)
            print(tlm, stlm, c1, c2)
コード例 #8
0
def plotExposed(D):
    acc = 1e-4
    x0 = 0
    x_end = np.pi / 2
    y0 = 0
    y_end = 1
    Y = np.linspace(y0, y_end, D)
    X = np.linspace(x0, x_end, D)
    Map = np.zeros((D, D))
    for y, CosA in enumerate(Y):
        for x, theta in enumerate(X):

            a0 = 0
            b0 = 0
            a1 = np.arccos(CosA)
            b1 = -np.arccos(CosA) + 2 * np.pi
            P = T.find_P(theta, a0, a1, b0, b1)

            P2 = symmetricPoint2(theta, CosA)
            # print(np.round(P-P2,7))
            # exp1 = T.is_exposed(theta, a0, a1, b0, b1, acc)
            exp2 = T.is_exposed_hypo(theta, a0, a1, b0, b1)
            exp3 = St.satoshiTest(P)
            nonloc = T.is_nonlocalPoint(P)
            print(exp2)
            stlm = St.STLM(P, theta)
            Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1)
            tlm = T.TLM(Ptlm)
            print(stlm, tlm)
            Map[x][D - y - 1] = exp2
    plt.imshow(Map.T, extent=[x0, x_end, y0, y_end])
    plt.colorbar()
    plt.xlabel("theta")
    plt.ylabel("cos(a)")
    plt.savefig("symmetric.png")
    plt.show()
コード例 #9
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
    def research2(theta, a0, a1, b0, b1):
        def maximum(S):
            m = 0
            for x in range(2):
                for y in range(2):
                    if S[x][y] > m:
                        m = S[x][y]
            return m

        def getThetaFromSinSquared(s):
            return np.arccos(np.sqrt(1 - s))

        def largerTheta(theta):
            P = T.find_P(theta, a0, a1, b0, b1)
            S_p, S_m = St.SPlusTemp(P)
            # print(S_p)
            # print(S_m)
            thetaNew = getThetaFromSinSquared(maximum(S_p))
            return thetaNew

        print("Optimal theta start")
        optTheta = optimalTheta(a0, a1, b0, b1)
        print("Optimal theta end")
        flag = False
        while (theta < optTheta - acc) and (not flag):
            Pnew = T.find_P(theta, a0, a1, b0, b1)
            stlm = St.STLM(Pnew, theta)
            Qs = St.satoshiTest(Pnew)
            print(Qs, stlm, theta)
            thetaNew = largerTheta(theta)
            if Qs:
                flag = True
            if abs(thetaNew - theta) < acc:
                flag = True
            theta = thetaNew
        print("Next")
コード例 #10
0
ファイル: satoshiTests.py プロジェクト: anttek7/QINumeric
def hypothesis(N):
    def research(theta, a0, a1, b0, b1):
        def maximum(S):
            m = 0
            for x in range(2):
                for y in range(2):
                    if S[x][y] > m:
                        m = S[x][y]
            return m

        def getThetaFromSinSquared(s):
            return np.arccos(np.sqrt(1 - s))

        P = T.find_P(theta, a0, a1, b0, b1)
        S_p, S_m = St.SPlusTemp(P)
        print(S_p)
        print(S_m)
        flag = False
        for x in range(2):
            for y in range(2):
                thetaNew = getThetaFromSinSquared(S_p[x][y])
                Pnew = T.find_P(thetaNew, a0, a1, b0, b1)
                stlm = St.STLM(Pnew, thetaNew)
                print(stlm, "STLM")
                Qs = St.satoshiTest(Pnew)
                print(Qs, thetaNew)
                if Qs:
                    flag = True

        for x in range(2):
            for y in range(2):
                thetaNew = getThetaFromSinSquared(S_m[x][y])
                Pnew = T.find_P(thetaNew, a0, a1, b0, b1)
                stlm = St.STLM(Pnew, thetaNew)
                print(stlm, "STLM")
                Qs = St.satoshiTest(Pnew)
                print(Qs, thetaNew)
                if Qs:
                    flag = True
        print("i co?", flag)

    def research2(theta, a0, a1, b0, b1):
        def maximum(S):
            m = 0
            for x in range(2):
                for y in range(2):
                    if S[x][y] > m:
                        m = S[x][y]
            return m

        def getThetaFromSinSquared(s):
            return np.arccos(np.sqrt(1 - s))

        def largerTheta(theta):
            P = T.find_P(theta, a0, a1, b0, b1)
            S_p, S_m = St.SPlusTemp(P)
            # print(S_p)
            # print(S_m)
            thetaNew = getThetaFromSinSquared(maximum(S_p))
            return thetaNew

        print("Optimal theta start")
        optTheta = optimalTheta(a0, a1, b0, b1)
        print("Optimal theta end")
        flag = False
        while (theta < optTheta - acc) and (not flag):
            Pnew = T.find_P(theta, a0, a1, b0, b1)
            stlm = St.STLM(Pnew, theta)
            Qs = St.satoshiTest(Pnew)
            print(Qs, stlm, theta)
            thetaNew = largerTheta(theta)
            if Qs:
                flag = True
            if abs(thetaNew - theta) < acc:
                flag = True
            theta = thetaNew
        print("Next")

    s0STLM0 = 0
    s1STLM0 = 0
    s0STLM1 = 0
    s1STLM1 = 0

    for i in range(N):
        if i % 100 == 0:
            print(f'{i+1}/{N}')
        theta = np.random.rand() * np.pi / 4
        a0 = np.random.rand() * 2 * np.pi
        a1 = np.random.rand() * 2 * np.pi
        b0 = np.random.rand() * 2 * np.pi
        b1 = np.random.rand() * 2 * np.pi

        P = T.find_P(theta, a0, a1, b0, b1)
        correct1, realisation, wholeSp = T.twoQubitRepresentation(P)
        theta = realisation[0]
        correct2 = St.STLM(P, theta)
        if not correct1:
            print("no 2-qubit realisation????")
        if correct2 and wholeSp:
            s1STLM1 += 1
        elif correct2 and (not wholeSp):
            research2(theta, a0, a1, b0, b1)
            s0STLM1 += 1
        elif (not correct2) and wholeSp:
            s1STLM0 += 1
        elif (not correct2) and (not wholeSp):
            s0STLM0 += 1