def test__solve__empty_list(self):

        q = MARing.q()
        pol_lst = []
        var_lst = [q[i] for i in [0, 1, 2]]

        sol_dct = MARing.solve(pol_lst, var_lst)
        print(sol_dct)
        assert 'r0' in str(sol_dct)
Exemplo n.º 2
0
    def test__get_invariant_q_lst__SO2(self):
        h1, h2, a1, a2, a3, b1, b2, b3 = Veronese.get_c_lst_lst_dct()['SL3(C)']

        q_lst = Veronese.get_invariant_q_lst(h1)
        out = sorted(list(set(q_lst)))
        print('q_lst =', q_lst)
        print('out   =', out)

        q0, q1, q2, q3, q4, q5 = MARing.q()[:6]

        assert out == ring(
            '[-1/2*q5, 1/2*q5, -1/2*q4, 1/2*q4, -2*q3, q3, -q2, 2*q2]')
Exemplo n.º 3
0
    def test__qmat__qpol(self):
        x = MARing.x()
        q = MARing.q()

        g_lst = DSegre.get_ideal_lst()
        chk_qpol = 0
        for i in range(len(g_lst)):
            chk_qpol += q[i] * g_lst[i]

        qmat = DSegre.get_qmat()
        qpol = list(sage_vector(x).row() * qmat *
                    sage_vector(x).column())[0][0]
        assert qpol == chk_qpol
    def test__solve(self):

        q = MARing.q()
        pol_lst = [q[0] + 2 * q[1] + 3 * q[2] - 4]
        var_lst = [q[i] for i in [0, 1, 2]]

        sol_dct = MARing.solve(pol_lst, var_lst)
        print(sol_dct)
        assert 'r0' in str(sol_dct)

        # We call a second time so that sage internally
        # introduces new variable names. We undo this
        # in MARing.solve(), since we work in a
        # polynomial ring where we want to minimize
        # the number of variables.
        #
        sol_dct = MARing.solve(pol_lst, var_lst)
        print(sol_dct)
        assert 'r0' in str(sol_dct)
Exemplo n.º 5
0
    def get_qmat(exc_idx_lst=[]):
        '''        
        Parameters
        ----------
        exc_idx_lst : list<int>
            A list of integers in [0,8].      
              
        Returns
        -------
        sage_matrix<MARing.R>
            A symmetric 9x9 matrix with entries
            in the ring QQ[q0,...,q19] which is a subring 
            of "MARing.R". It represents the Gramm matrix 
            of a quadratic form in the ideal of the              
            double Segre surface or a projection of 
            the double Segre surface with ideal defined
            by "get_ideal_lst( exc_idx_lst )".
            
        Method
        ------
        We obtain generators of the ideal 
        of the (projection of) the double Segre surface
        with the method "get_ideal_lst( exc_idx_lst )".
        If the ideal is of a projection of the double Segre
        surface, then the returned matrix with parameters
        q0,...,q19 is not of full rank.                        
        '''
        x = MARing.x()
        q = MARing.q()

        g_lst = DSegre.get_ideal_lst(exc_idx_lst)
        qpol = 0
        for i in range(len(g_lst)):
            qpol += q[i] * g_lst[i]

        qmat = sage_invariant_theory.quadratic_form(
            qpol, x).as_QuadraticForm().matrix()
        qmat = sage_matrix(MARing.R, qmat)

        return qmat
Exemplo n.º 6
0
    def get_qmat():
        '''
        Returns
        -------
        sage_matrix
            A symmetric 5x5 matrix with entries in the 
            ring QQ[q0,...,q5] which is a subring 
            of "MARing.R". It represents the Gramm matrix 
            of a quadratic form in the ideal of the              
            Veronese with ideal defined by ".get_ideal_lst()".                        
        '''
        x = MARing.x()[:6]
        q = MARing.q()[:6]

        g_lst = Veronese.get_ideal_lst()
        qpol = 0
        for i in range(len(g_lst)):
            qpol += q[i] * g_lst[i]

        qmat = sage_invariant_theory.quadratic_form(
            qpol, x).as_QuadraticForm().matrix()
        qmat = sage_matrix(MARing.R, qmat)

        return qmat
Exemplo n.º 7
0
    def get_invariant_qf(c_lst_lst, exc_idx_lst=[]):
        '''
        Computes quadratic forms in the ideal of the
        double Segre surface that are invariant under
        a given subgroup of Aut(P^1xP^1). 
        
        Parameters
        ----------        
        c_lst_lst : list<list<MARing.FF>>  
            A list of "c_lst"-lists.
            A c_lst is a list of length 8 with elements 
            c0,...,c7 in QQ(k), 
            where QQ(k) is a subfield of "MARing.FF".
            If we substitute k:=0 in the entries of 
            "c_lst" then we should obtain the list:
                [1,0,0,1,1,0,0,1].                                                                      
            A c_lst represents a pair of two matrices:                                
                ( [ c0 c1 ]   [ c4 c5 ] ) 
                ( [ c2 c3 ] , [ c6 c7 ] )                                   
            with the property that 
                c0*c3-c1*c2!=0 and c4*c7-c5*c6!=0.
            If the two matrices are not normalized
            to have determinant 1 then the method should be 
            taken with care (it should be checked that the
            tangent vectors at the identity generate the 
            correct Lie algebra).                                             
        
        exc_idx_lst : list<int>
            A list of integers in [0,8].                                     
        
        Returns
        -------
        A list of quadratic forms in the ideal of (a projection of) 
        the double Segre surface S:
            ".get_ideal_lst( exc_idx_lst )"
        such that the quadratic forms are invariant 
        under the automorphisms of S as defined by "c_lst_lst"
        and such that the quadratic forms generate the module of  
        all invariant quadratic forms. Note that Aut(S)=Aut(P^1xP^1).   
        '''

        # for verbose output
        #
        mt = MATools()
        sage_set_verbose(-1)

        # initialize vectors for indeterminates of "MARing.R"
        #
        x = MARing.x()
        q = MARing.q()
        r = MARing.r()

        # obtain algebraic conditions on q0,...,q19
        # so that the associated quadratic form is invariant
        # wrt. the automorphism defined by input "c_lst_lst"
        #
        iq_lst = []
        for c_lst in c_lst_lst:
            iq_lst += DSegre.get_invariant_q_lst(c_lst, exc_idx_lst)
        iq_lst = list(MARing.R.ideal(iq_lst).groebner_basis())

        # solve the ideal defined by "iq_lst"
        #
        sol_dct = MARing.solve(iq_lst, q)

        # substitute the solution in the quadratic form
        # associated to the symmetric matrix qmat.
        #
        qmat = DSegre.get_qmat(exc_idx_lst)
        qpol = list(sage_vector(x).row() * qmat *
                    sage_vector(x).column())[0][0]
        sqpol = qpol.subs(sol_dct)
        mt.p('sqpol   =', sqpol)
        mt.p('r       =', r)
        assert sqpol.subs({ri: 0 for ri in r}) == 0
        iqf_lst = []  # iqf=invariant quadratic form
        for i in range(len(r)):
            coef = sqpol.coefficient(r[i])
            if coef != 0:
                iqf_lst += [coef]
        mt.p('iqf_lst =', iqf_lst)

        return iqf_lst
Exemplo n.º 8
0
    def get_invariant_qf(c_lst_lst):
        '''
        Parameters
        ----------    
        c_lst_lst : list 
            A list of "c_lst"-lists.
            A c_lst is a list of length 9 with elements 
            c0,...,c8 in the subring in QQ(k)  of "MARing.FF". 
            The matrix                         
                [ c0 c1 c2 ]
            M = [ c3 c4 c5 ]
                [ c6 c7 c8 ]                                                         
            represents---for each value of k---an 
            automorphism of P^2. If we set k:=0 then 
            "c_lst" must correspond to the identity matrix: 
            [ 1,0,0, 0,1,0, 0,0,1 ]. If M is not normalized
            to have determinant 1 then the method should be 
            taken with care (see doc. ".get_c_lst_lst_dct").         
        
        Returns
        -------
        list<MARing.R>
            A list of quadratic forms in the ideal of the Veronese surface V
            (see ".get_ideal_lst()"), such that the quadratic forms are 
            invariant under the automorphisms of V as defined by "c_lst_lst"
            and such that the quadratic forms generate the module of  
            all invariant quadratic forms. Note that Aut(V)=Aut(P^2).   
        '''

        # for verbose output
        #
        mt = MATools()

        # initialize vectors for indeterminates of "MARing.R"
        #
        x = MARing.x()[:6]
        q = MARing.q()[:6]
        r = MARing.r()[:6]

        # obtain algebraic conditions on q0,...,q19
        # so that the associated quadratic form is invariant
        # wrt. the automorphism defined by input "c_lst_lst"
        #
        iq_lst = []
        for c_lst in c_lst_lst:
            iq_lst += Veronese.get_invariant_q_lst(c_lst)
        iq_lst = list(MARing.R.ideal(iq_lst).groebner_basis())

        # solve the ideal defined by "iq_lst"
        #
        sol_dct = MARing.solve(iq_lst, q)

        # substitute the solution in the quadratic form
        # associated to the symmetric matrix qmat.
        #
        qmat = Veronese.get_qmat()
        qpol = list(sage_vector(x).row() * qmat *
                    sage_vector(x).column())[0][0]
        sqpol = qpol.subs(sol_dct)
        mt.p('sqpol   =', sqpol)
        mt.p('r       =', r)
        assert sqpol.subs({ri: 0 for ri in r}) == 0
        iqf_lst = []  # iqf=invariant quadratic form
        for i in range(len(r)):
            coef = sqpol.coefficient(r[i])
            if coef != 0:
                iqf_lst += [coef]
        mt.p('iqf_lst =', iqf_lst)

        return iqf_lst
Exemplo n.º 9
0
    def test__get_aut_P8__rotation_matrix(self):
        '''
        OUTPUT:
            - We verify that for the 1-parameter subgroup of rotations 
              with matrix
              
                  [ cos(k) -sin(k) ]
                  [ sin(k)  cos(k) ]
            
              it is for our Lie algebra methods sufficient to consider 
              1-parameter subgroups that have the same tangent vector
              at the identity. Note that for k=0 we need to get the identity
              and the determinant should be 1.   
        '''
        k = ring('k')
        I = ring('I')
        a, b, c, d, e, f, g, h = ring('a, b, c, d, e, f, g, h')
        x = MARing.x()
        q = MARing.q()
        r = MARing.r()

        #
        # We consider the representation of the
        # following matrix into P^8
        #
        #   (  [ 1 -k ] ,  [ 1 0 ] )
        #   (  [ k  1 ]    [ 0 1 ] )
        #
        # We define A to be the tangent vector at the
        # identity of this representation
        #
        N = DSegre.get_aut_P8([1, -k, k, 1] + [1, 0, 0, 1])
        A = MARing.diff_mat(N, k).subs({k: 0})

        #
        # We consider the representation of the
        # following matrix into P^8
        #
        #   (  [ cos(k) -sin(k) ] ,  [ 1 0 ] )
        #   (  [ sin(k)  cos(k) ]    [ 0 1 ] )
        #
        # We define B to be the tangent vector at the
        # identity of this representation
        #
        M = DSegre.get_aut_P8([a, b, c, d] + [e, f, g, h])

        a, b, c, d, e, f, g, h = sage_var('a, b, c, d, e, f, g, h')
        k = sage_var('k')
        M = sage__eval(str(list(M)), {
            'a': a,
            'b': b,
            'c': c,
            'd': d,
            'e': e,
            'f': f,
            'g': g,
            'h': h,
            'k': k
        })
        M = sage_matrix(M)
        M = M.subs({
            a: sage_cos(k),
            b: -sage_sin(k),
            c: sage_sin(k),
            d: sage_cos(k),
            e: 1,
            f: 0,
            g: 0,
            h: 1
        })

        # differentiate the entries of M wrt. k
        dmat = []
        for row in M:
            drow = []
            for col in row:
                drow += [sage_diff(col, k)]
            dmat += [drow]
        M = sage_matrix(dmat)
        B = M.subs({k: 0})

        assert str(A) == str(B)