def test_symplectic(self):
        # the symmetric transformation matrix should be symplectic
        Pa = self.atrott
        Pb = self.btrott
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)
        g,g = Pa.dimensions()
        J = zero_matrix(ZZ,2*g,2*g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g,g:] = Ig
        J[g:,:g] = -Ig
        self.assertEqual(Gamma.T*J*Gamma,J)

        Pa = self.aklein
        Pb = self.bklein
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-3)
        g,g = Pa.dimensions()
        J = zero_matrix(ZZ,2*g,2*g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g,g:] = Ig
        J[g:,:g] = -Ig
        self.assertEqual(Gamma.T*J*Gamma,J)

        Pa = self.afermat
        Pb = self.bfermat
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-3)
        g,g = Pa.dimensions()
        J = zero_matrix(ZZ,2*g,2*g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g,g:] = Ig
        J[g:,:g] = -Ig
        self.assertEqual(Gamma.T*J*Gamma,J)

        Pa = self.a6
        Pb = self.b6
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)
        g,g = Pa.dimensions()
        J = zero_matrix(ZZ,2*g,2*g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g,g:] = Ig
        J[g:,:g] = -Ig
        self.assertEqual(Gamma.T*J*Gamma,J)
Esempio n. 2
0
    def test_symplectic(self):
        # the symmetric transformation matrix should be symplectic
        Pa = self.atrott
        Pb = self.btrott
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)
        g, g = Pa.dimensions()
        J = zero_matrix(ZZ, 2 * g, 2 * g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g, g:] = Ig
        J[g:, :g] = -Ig
        self.assertEqual(Gamma.T * J * Gamma, J)

        Pa = self.aklein
        Pb = self.bklein
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-3)
        g, g = Pa.dimensions()
        J = zero_matrix(ZZ, 2 * g, 2 * g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g, g:] = Ig
        J[g:, :g] = -Ig
        self.assertEqual(Gamma.T * J * Gamma, J)

        Pa = self.afermat
        Pb = self.bfermat
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-3)
        g, g = Pa.dimensions()
        J = zero_matrix(ZZ, 2 * g, 2 * g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g, g:] = Ig
        J[g:, :g] = -Ig
        self.assertEqual(Gamma.T * J * Gamma, J)

        Pa = self.a6
        Pb = self.b6
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)
        g, g = Pa.dimensions()
        J = zero_matrix(ZZ, 2 * g, 2 * g)
        Ig = identity_matrix(ZZ, g, g)
        J[:g, g:] = Ig
        J[g:, :g] = -Ig
        self.assertEqual(Gamma.T * J * Gamma, J)
Esempio n. 3
0
    def test_equivalence(self):
        # by definition: N1 = Q*H*Q.T (mod 2)
        N1 = self.N1klein
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)

        N1 = self.N1fermat4
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)

        N1 = self.N1fermat5
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)

        N1 = self.N1f2a
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)

        N1 = self.N16
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)

        N1 = self.N1problem
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q * H * Q.T)
Esempio n. 4
0
    def test_symmetric_H(self):
        # H should be symmetric
        N1 = self.N1klein
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1fermat4
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1fermat5
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1f2a
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N16
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1problem
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)
Esempio n. 5
0
    def test_rank_equivalence(self):
        # the ranks of N1 and H should match
        N1 = self.N1klein
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1fermat4
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1fermat5
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1f2a
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N16
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1problem
        H, Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())
    def test_equivalence(self):
        # by definition: N1 = Q*H*Q.T (mod 2)
        N1 = self.N1klein
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)

        N1 = self.N1fermat4
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)

        N1 = self.N1fermat5
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)

        N1 = self.N1f2a
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)

        N1 = self.N16
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)

        N1 = self.N1problem
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1, Q*H*Q.T)
    def test_symmetric_H(self):
        # H should be symmetric
        N1 = self.N1klein
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1fermat4
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1fermat5
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1f2a
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N16
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)

        N1 = self.N1problem
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(H, H.T)
    def test_rank_equivalence(self):
        # the ranks of N1 and H should match
        N1 = self.N1klein
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1fermat4
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1fermat5
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1f2a
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N16
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())

        N1 = self.N1problem
        H,Q = symmetric_block_diagonalize(N1)
        self.assertEqual(N1.rank(), H.rank())
Esempio n. 9
0
    def test_recover_action(self):
        # see equation (28) of Kalla,Klein
        def compute_R(Gamma, H):
            H = H.change_ring(ZZ)
            g, g = H.dimensions()
            A = Gamma[:g, :g]
            B = Gamma[:g, g:]
            C = Gamma[g:, :g]
            D = Gamma[g:, g:]
            Ig = identity_matrix(ZZ, g)

            R = zero_matrix(ZZ, 2 * g, 2 * g)
            R[:g, :g] = (2 * C.T * B - A.T * H * B + Ig).T
            R[:g, g:] = 2 * D.T * B - B.T * H * B
            R[g:, :g] = -2 * C.T * A + A.T * H * A
            R[g:, g:] = -(2 * C.T * B - A.T * H * B + Ig)
            return R

        # trott curve
        Pa = self.atrott
        Pb = self.btrott
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # klein curve
        Pa = self.aklein
        Pb = self.bklein
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S, tol=1e-3)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # fermat curve
        Pa = self.afermat
        Pb = self.bfermat
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S, tol=1e-3)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # genus 6 curve
        Pa = self.a6
        Pb = self.b6
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H, Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)
Esempio n. 10
0
    def test_recover_action(self):
        # see equation (28) of Kalla,Klein
        def compute_R(Gamma, H):
            H = H.change_ring(ZZ)
            g,g = H.dimensions()
            A = Gamma[:g,:g]
            B = Gamma[:g,g:]
            C = Gamma[g:,:g]
            D = Gamma[g:,g:]
            Ig = identity_matrix(ZZ,g)

            R = zero_matrix(ZZ,2*g,2*g)
            R[:g,:g] = (2*C.T*B - A.T*H*B + Ig).T
            R[:g,g:] = 2*D.T*B - B.T*H*B
            R[g:,:g] = -2*C.T*A + A.T*H*A
            R[g:,g:] = -(2*C.T*B - A.T*H*B + Ig)
            return R

        # trott curve
        Pa = self.atrott
        Pb = self.btrott
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # klein curve
        Pa = self.aklein
        Pb = self.bklein
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S, tol=1e-3)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # fermat curve
        Pa = self.afermat
        Pb = self.bfermat
        R = involution_matrix(Pa, Pb, tol=1e-3)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S, tol=1e-3)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)

        # genus 6 curve
        Pa = self.a6
        Pb = self.b6
        R = involution_matrix(Pa, Pb)
        S = integer_kernel_basis(R)
        N1 = N1_matrix(Pa, Pb, S)
        H,Q = symmetric_block_diagonalize(N1)
        Gamma = symmetric_transformation_matrix(Pa, Pb, S, H, Q, tol=1e-4)

        Ralt = compute_R(Gamma, H)
        self.assertEqual(R, Ralt)