예제 #1
0
def generalDoubleTiltedRegion(D):
    A = np.linspace(0, 2, D)
    Phi = np.linspace(0, np.pi / 2, D)
    Plane = np.zeros((D, D))

    for i, phi in enumerate(Phi):
        print(f'{i+1}/{D}')
        for j, a in enumerate(A):
            B = GDT.functional(a, phi)
            accuracy = 0.001
            P, Qn = T.Best_point(B, accuracy)

            Qs = St.satoshiTest(P)
            if Qn:
                if Qs:
                    Plane[i][j] = 1
                else:
                    Plane[i][j] = 2
            else:
                if Qs:
                    Plane[i][j] = 3
                else:
                    Plane[i][j] = 0

    plt.imshow(Plane.T, extent=[0, np.pi / 2, 2, 0])
    plt.colorbar()
    plt.show()
예제 #2
0
def compareSatoshiAndNumeric(N):
    bothEx = 0
    bothNoEx = 0
    SatEx = 0
    NumEx = 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)

        isExtremal = St.satoshiTest(P)

        accuracy = 0.001
        isExtremal2 = T.is_exposed(theta, a0, a1, b0, b1, accuracy, limit=1)

        if isExtremal:
            if isExtremal2:
                bothEx += 1
            else:
                SatEx += 1
        else:
            if isExtremal2:
                NumEx += 1
            else:
                bothNoEx += 1
        print(bothNoEx, bothEx, SatEx, NumEx)
예제 #3
0
def optimalTheta(a0, a1, b0, b1):
    n = 100
    Theta = np.linspace(0, np.pi / 2, n)
    flag = 0

    for theta in Theta:
        P = T.find_P(theta, a0, a1, b0, b1)
        Q = St.satoshiTest(P)
        print(theta, Q)
예제 #4
0
    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)
예제 #5
0
def pointsWithTwoSolutions(N):
    for i in range(N):
        if i % 100 == 0:
            print(f'{i+1}/{N}')

        a = np.random.rand() * 0.25 - 0.125
        b = np.random.rand() * 2 - 1
        c = np.random.rand() * 2 - 1
        # a = 1/4
        # b = 1/8
        c = 1 / np.sqrt(2)
        P = [a, a, b, b, c, c, c, -c]
        isExtremal = St.satoshiTest(P)
        print(isExtremal)
예제 #6
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()
예제 #7
0
def generalWolfRegion(D):
    acc = 0.001
    D = 101
    T = np.linspace(-1, 1, D)
    R = np.linspace(0, 2, D)
    Plane = np.zeros((D, D))
    Plane2 = np.zeros((D, D))

    for i, t in enumerate(T):
        print(f'{i+1}/{D}')
        for j, r in enumerate(R):
            B = GW.functional(t, r)
            P = GW.quantumPoint(t, r)
            # print(P)
            Qs = St.satoshiTest(P)
            _, Qn = T.Best_point(B, acc)
            Plane[i][j] = Qs
            Plane2[i][j] = Qn
            if Qn and (not Qs):
                Qs = St.satoshiTestComment(P)
    plt.imshow(Plane, extent=[0, 2 * np.pi, 4, 0])
    plt.show()
    plt.imshow(Plane2, extent=[0, 2 * np.pi, 4, 0])
    plt.show()
예제 #8
0
def compareTests(N):
    St0we0 = 0
    St0we1 = 0
    St1we0 = 0
    St1we1 = 0

    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
        P = T.find_P(theta, a0, a1, b0, b1)
        Qs = St.satoshiTest(P)
        Qw = newTest(theta, a0, a1, b0, b1)

        if Qs:
            if Qw:
                St1we1 += 1
            else:
                St1we0 += 1
                print(theta, a0, a1, b0, b1)
                check(theta, a0, a1, b0, b1)
                break
        else:
            if Qw:
                St0we1 += 1
                print(theta, a0, a1, b0, b1)
                check(theta, a0, a1, b0, b1)
                break

            else:
                St0we0 += 1
        print(St1we1, St1we0, St0we1, St0we0)
예제 #9
0
    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
def checkCabelloPoint():
    alpha = np.random.rand() * np.pi
    beta = np.random.rand() * np.pi
    P = Pp.cabelloPoint(alpha, beta, 0, 0)
    print(St.satoshiTest(P))