Exemplo n.º 1
0
 def test__get_mon_P2(self):
     out = SERing.get_mon_P2(2, 'x0,x1,x2')
     chk = '[x0^2, x0*x1, x0*x2, x1^2, x1*x2, x2^2]'
     print(out)
     x0, x1, x2 = ring('x0,x1,x2')
     for p in out:
         assert p.degree() == 2
     assert str(out) == chk
Exemplo n.º 2
0
 def test__get_matrix_P2(self):
     mat = '[(8, -1, 0, 1/17, 2, 0, 1, 4/15, 2, 0), (1, 1/6, -1, 1, -5/7, -3/2, -5, -78, -1, 0), (-1, 0, -3/2, -9/2, -1, -1, 1, -1, 0, -35), (-11/4, 0, 0, 0, -1, 1, 0, 1/2, -5/4, -1/2), (1/7, -7/11, -2/13, 1, -3, 1/2, -1, 1/2, 0, 1/2), (4, -1, -1, 4, 0, 7/4, 3/5, 0, 1, -35), (-1/5, 0, -2, -55/2, -1/3, 2, -2, -2/11, -1, -1/2), (-1/6, -1/2, 2, 0, 2, 2, 0, -1, -1, 8), (-1, -2/3, 5/33, 2, 0, -1/48, -1, -1/15, 1/2, 1), (0, 3/2, 0, -2, 1/5, -4/7, 1/2, 1/4, 1, 0)]'
     mat = sage_matrix(sage_QQ, ring(mat))
     mon_lst = SERing.get_mon_P2(3)
     pol_lst = list(mat * sage_vector(mon_lst))
     out = SERing.get_matrix_P2(pol_lst)
     print(mat)
     print(mon_lst)
     print(pol_lst)
     print(out)
     assert mat == out
Exemplo n.º 3
0
    def test__get_degree(self):
        d = 4
        mon_lst = SERing.get_mon_P2(d)
        print(mon_lst)
        out = SERing.get_degree(mon_lst)
        print(out)
        assert out == d

        mat = SERing.random_matrix_QQ(4, len(mon_lst))
        pol_lst = list(mat * sage_vector(mon_lst))
        print(pol_lst)
        out = SERing.get_degree(pol_lst)
        print(out)
        assert out == d
Exemplo n.º 4
0
def usecase_B1():
    '''
    We compute the automorphisms of a Roman surface from a set of 
    compatible reparametrizations.        
    If the domain the projective plane, then a parametrization of a 
    Roman surface is basepoint free. 
    The compatible reparametrizations are in this case linear 
    automorphisms of the projective plane.
    '''
    y = ring('y0,y1,y2,y3')
    x = ring('x0,x1,x2')
    c = ring('c0,c1,c2,c3,c4,c5,c6,c7,c8')

    # parametrizations f and g of Roman surface
    f = ring('[x0^2+x1^2+x2^2,x0*x1,x0*x2,x1*x2]')
    g = f

    # compatible reparametrizations are linear and indexed by c
    r = {
        x[0]: c[0] * y[0] + c[1] * y[1] + c[2] * y[2],
        x[1]: c[3] * y[0] + c[4] * y[1] + c[5] * y[2],
        x[2]: c[6] * y[0] + c[7] * y[1] + c[8] * y[2]
    }

    # compute kernel and coefficient matrix of f
    Mf = SERing.get_matrix_P2(f)
    Kf = Mf.right_kernel_matrix().T
    assert (Mf * Kf).is_zero()

    # compute the coefficient matrix of g composed with r
    gr = [comp.subs(r) for comp in g]
    assert sage_gcd(gr) == 1
    assert SERing.get_degree(gr, 'y0,y1,y2') == SERing.get_degree(f)
    Mgr = SERing.get_matrix_P2(gr, 'y0,y1,y2')

    # output to screen
    SETools.p('f       =', f)
    SETools.p('g       =', g)
    SETools.p('r       =', r)
    SETools.p('Mf      =', Mf.dimensions(), list(Mf), SERing.get_mon_P2(2))
    SETools.p('Kf.T    =', Kf.T.dimensions(), list(Kf.T))
    SETools.p('Mgr     =', Mgr.dimensions(), list(Mgr), '\n' + str(Mgr))

    # compute c such that Mgr*Kf==0
    ec_lst = (Mgr * Kf).list() + [
        sage_matrix(SERing.R, 3, 3, c).det() * ring('t') - 1
    ]
    pc_lst = sage_ideal(ec_lst).elimination_ideal(
        ring('t')).primary_decomposition()
    SETools.p('sol_lst = ')
    sol_lst = []
    for pc in pc_lst:
        s_lst = list(reversed(sorted(pc.gens())))
        s_dct = ring(
            sage_solve([sage_SR(comp) for comp in s_lst],
                       [sage_SR(comp) for comp in c],
                       solution_dict=True)[0])
        sol_lst += [s_dct]
        SETools.p('\t\t', s_lst, '-->', s_dct)

    # compute implicit equation for image Y of g
    eqg = sage_ideal([y[i] - g[i]
                      for i in range(4)]).elimination_ideal(x).gens()
    SETools.p('eqg =', eqg)
    SETools.p(
        '    =',
        str(eqg.subs({y[0]: 1})).replace('y1',
                                         'x').replace('y2',
                                                      'y').replace('y3', 'z'))

    # computing U and test each sol in sol_lst
    SETools.p('Testing each sol in sol_lst...')
    for sol in sol_lst:
        # compute the projective isomorphism in terms of parametrized matrix U
        Ef = sage_matrix(sage_QQ, list(Mf) + list(Kf.T))
        Egr = sage_matrix(list(Mgr.subs(sol)) + list(Kf.T))
        UpI = Egr * ~Ef
        assert (UpI.submatrix(4, 4) - sage_identity_matrix(2)).is_zero()
        U = UpI.submatrix(0, 0, 4, 4)
        U = U / sage_gcd(U.list())
        assert U.dimensions() == (4, 4)

        # verify whether U*f is a parametrization for Y for all (c0,...,c7)
        Uf = list(U * sage_vector(f))
        eqg_sub = [eq.subs({y[i]: Uf[i] for i in range(4)}) for eq in eqg]
        assert eqg_sub == [0]

        # output U with corresponding solution
        SETools.p('\t U =', list(U), ', sol =', sol)