예제 #1
0
def usecase_orb_product_implicit_circle(num=10):
    '''
    Outputs "num" random surfaces in the projective n-sphere S^n, 
    that are obtained by rotating or translating an implicit circle.
    The circle is obtained as a random hyperplane section.
    
    The hyperplane section is obtained by applying 
    a random matrix in PGL(8+1) to the hyperplane 
    section { x | x3=..=x8=0=-x0^2+x1^2+...+x8^2=0 }.  
    Since the random matrix is not orthogonal
    we cannot use the matrix to compute parametric 
    presentations for these examples.  
    
    Notice that we can recover the OrbInput object 
    from the short string output 
    (see "usecase_orb_product_investigate_example()")
    
    Parameters
    ----------
    num : int
        Number of times a random surface should be computed.   
    '''

    for idx in range(num):
        try:

            # compute random input
            ch_str = ''.join([
                OrbRing.random_elt(['r', 's', 'p', 'm', 'a']) for i in range(4)
            ])
            pmat = list(sage_MatrixSpace(sage_ZZ, 9, 9).random_element())
            p_tup = ('P1', 'I', 'I')
            o_tup = ('I', 'O' + ch_str, 'I')
            v_tup = ('M' + str(pmat), 'I', 'I')
            input = OrbInput().set(p_tup, o_tup, v_tup)

            # compute only few attributes
            for key in input.do.keys():
                input.do[key] = False
            input.do['imp'] = True
            input.do['dde'] = True

            o = orb_product(input)

            OrbTools.p('(deg, emb, dim ) =',
                       (o.deg, o.emb, o.dim), ' short string =',
                       o.get_short_str())  # output  orbital product

        except BaseException as e:

            # continue with loop regardless of exceptions
            OrbTools.p('Exception occurred: ', e)
            OrbTools.p(input)
            OrbTools.p(o)
예제 #2
0
def usecase_orb_product(num=10):
    '''
    Outputs "num" random surfaces in the projective n-sphere S^n, 
    that are obtained by rotating or translating a parametrized 
    circle.
    
    Notice that we can recover the OrbInput object 
    from the short string output 
    (see "usecase_orb_product_investigate_example()")
    
    Parameters
    ----------
    num : int
        Number of times a random surface should be computed.
    '''

    for idx in range(num):
        try:

            input = OrbInput().random(3, False)  # random input

            # only compute dimension and degree
            for key in input.do.keys():
                input.do[key] = False
            input.do['imp'] = True
            input.do['dde'] = True

            o = orb_product(input)

            OrbTools.p('(deg, emb, dim ) =',
                       (o.deg, o.emb, o.dim), ' short string =',
                       o.get_short_str())  # output  orbital product

        except BaseException as e:

            # continue with loop regardless of exceptions
            OrbTools.p('Exception occurred: ', e)
            OrbTools.p(input)
            OrbTools.p(o)
예제 #3
0
    def test__random(self):
        coef_bnd = 3
        in1 = OrbInput().random(3, False)
        print(in1)

        print(in1.info_dct['vmat'][0])
        print(in1.info_dct['vmat'][2])

        s = ''
        s += in1.info_dct['vmat'][0][1:]
        if in1.info_dct['vmat'][2] != 'I':
            s += '+'
            s += in1.info_dct['vmat'][2][1:]

        for elt in sage__eval(s):
            assert elt >= -coef_bnd and elt <= coef_bnd

        in2 = OrbInput().set(in1.info_dct['pmat'], in1.info_dct['omat'],
                             in1.info_dct['vmat'])

        assert in1.pmat == in2.pmat
        assert in1.omat == in2.omat
        assert in1.vmat == in2.vmat
예제 #4
0
    def test__get_pmz_verify__perseus( self ):

        o = OrbOutput( OrbInput() )

        o.input.do['pmz'] = True
        o.input.do['imp'] = True

        o.prj_pmz_lst = '[-2*s1 + 3, 4/5*c0*c1 - 3/5*s0*c1 + 7/5*c0*s1 + 6/5*s0*s1 - 12/5*c0 - 11/5*s0 - 2*s1 + 3, 3/5*c0*c1 + 4/5*s0*c1 - 6/5*c0*s1 + 7/5*s0*s1 + 11/5*c0 - 12/5*s0, -2*s1 + 2]'
        o.prj_pmz_lst = OrbRing.coerce( o.prj_pmz_lst )

        o.prj_pol = '25*x0^4 + 100*x0^3*x1 + 50*x0^2*x1^2 - 100*x0*x1^3 + 25*x1^4 - 50*x0^2*x2^2 - 100*x0*x1*x2^2 + 50*x1^2*x2^2 + 25*x2^4 - 24*x0^3*x3 - 40*x0^2*x1*x3 + 20*x0*x1^2*x3 + 20*x0*x2^2*x3 - 41*x0^2*x3^2 - 100*x0*x1*x3^2 + 50*x1^2*x3^2 + 50*x2^2*x3^2 + 20*x0*x3^3 + 25*x3^4'
        o.prj_pol = OrbRing.coerce( o.prj_pol )

        o.gen = 1

        print( o )
        tst = get_pmz_verify( o )
        print( tst )
        assert tst == True
예제 #5
0
def usecase_orb_product_investigate_example():
    '''
    Here we investigate an example obtained 
    by "usecase_orb_product"
    '''

    s = "['@(4,3)=(deg,emb)', {'pmat': ('P0', 'I', 'I'), 'omat': ('T[1, 0, 0, 0, 0, 0, 0]', 'Orppp', 'T[-1, 0, 0, 0, 0, 0, 0]'), 'vmat': ('T[0, 1, 1, 0, 0, 0, 0]', 'Rrrrs[37, 0, 0, 0]', 'T[0, -1, -1, 0, 0, 0, 0]')}]"

    input = OrbInput().set_short_str(s)
    input.do['pmz'] = True
    input.do['bpt'] = False
    input.do['imp'] = True
    input.do['dde'] = True
    input.do['prj'] = True
    input.do['fct'] = True  # requires Maple
    input.do['gen'] = True  # requires Maple
    input.do['sng'] = True  # requires Magma
    input.do['tst'] = True

    o = orb_product(input)
    OrbTools.p(o)
예제 #6
0
    def test__orb_product__43_perseus( self ):

        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/maple/link/bin'
        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/magma/link'

        # perseus cyclide
        s = "['@(4,3)=(deg,emb)', {'pmat': ('P0', 'I', 'I'), 'omat': ('T[1, 0, 0, 0, 0, 0, 0]', 'Orppp', 'T[-1, 0, 0, 0, 0, 0, 0]'), 'vmat': ('T[0, 1, 1, 0, 0, 0, 0]', 'Rrrrs[37, 0, 0, 0]', 'T[0, -1, -1, 0, 0, 0, 0]')}]"

        input = OrbInput().set_short_str( s )
        input.do['pmz'] = True
        input.do['bpt'] = False
        input.do['imp'] = True
        input.do['dde'] = True
        input.do['prj'] = True
        input.do['fct'] = True
        input.do['gen'] = True
        input.do['sng'] = True
        input.do['tst'] = True

        print( input )

        o = orb_product( input )
        print( o )

        assert ( o.deg, o.emb, o.dim ) == ( 4, 3, 2 )
예제 #7
0
    def test__orb_product__65_sing( self ):

        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/maple/link/bin'
        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/magma/link'

        s = "['@(6,5)=(deg,emb)', {'pmat': ('P1', 'I', 'I'), 'omat': ('T[0, 0, 0, 1, 1, -1, -1]', 'Oprps', 'I'), 'vmat': ('T[0, -1, 0, -1, 0, 0, 0]', 'Rspps[148, 344, 284, 304]', 'T[0, 1, 0, 1, 0, 0, 0]')}]"

        input = OrbInput().set_short_str( s )
        input.do['pmz'] = True
        input.do['bpt'] = True
        input.do['imp'] = True
        input.do['dde'] = True
        input.do['prj'] = True
        input.do['fct'] = False
        input.do['gen'] = False
        input.do['sng'] = False
        input.do['tst'] = False

        print( input )

        o = orb_product( input )
        print( o )

        assert ( o.deg, o.emb, o.dim ) == ( 6, 5, 2 )

        assert 'chart=xv, depth=0, mult=1, sol=(a1, 0)' in str( o.bp_tree )
        assert 'chart=xv, depth=0, mult=1, sol=(-a1, 0)' in str( o.bp_tree )
예제 #8
0
    def test__orb_product__65_smooth( self ):

        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/maple/link/bin'
        os.environ['PATH'] += os.pathsep + '/home/niels/Desktop/n/app/magma/link'

        s = "['@(6,5)=(deg,emb)', {'pmat': ('P1', 'I', 'I'), 'omat': ('T[1, -1, 1, 1, -1, 0, 0]', 'Opsms', 'I'), 'vmat': ('T[1, 0, -1, 0, 0, 0, 0]', 'Rramr[340, 225, 264, 320]', 'T[-1, 0, 1, 0, 0, 0, 0]')}]"

        input = OrbInput().set_short_str( s )
        input.do['pmz'] = True
        input.do['bpt'] = False
        input.do['imp'] = True
        input.do['dde'] = True
        input.do['prj'] = True
        input.do['fct'] = False
        input.do['gen'] = False
        input.do['sng'] = False
        input.do['tst'] = False

        o = orb_product( input )
        print( o )

        assert ( o.deg, o.emb, o.dim ) == ( 6, 5, 2 )
예제 #9
0
def dp6_sing():
    '''
    Creates povray image of the projection of a sextic weak del Pezzo surface 
    wdP6 in S^5. This surface contains 2 families of conics. One of these 
    families has a base point at the isolated singularity of wdP6
    '''
    # init OrbInput
    #
    pmat = []
    pmat += [[1, 0, 0, 0] + [0, 0, 0, -1, -1]]
    pmat += [[0, 1, 0, 0] + [0, 0, 0, 0, 0]]
    pmat += [[0, 0, 1, 0] + [0, 0, 0, 0, 0]]
    pmat += [[0, 0, 0, 1] + [-1, 0, 0, 0, 0]]
    p_tup = ('M' + str(pmat), 'I', 'I')
    o_tup = ('I', 'Oprpr', 'I')
    v_tup = ('T[0, 1, 1, 0, 0, 0, 0]', 'Rrppr[37,0,0,90]',
             'T[0, -1, -1, 0, 0, 0, 0]')

    input = OrbInput().set(p_tup, o_tup, v_tup)
    input.do['pmz'] = True
    input.do['bpt'] = False
    input.do['imp'] = True
    input.do['dde'] = True
    input.do['prj'] = True
    input.do['fct'] = False
    input.do['gen'] = False
    input.do['sng'] = False
    input.do['tst'] = False

    # init OrbOutput.prj_pmz_lst
    #
    o = orb_product(input)
    pmz_AB_lst = o.prj_pmz_lst

    # init PovInput
    #
    pin = PovInput()

    pin.path = './' + get_time_str() + '_dp6_sing/'
    pin.fname = 'orb'
    pin.scale = 1
    pin.cam_dct['location'] = (0, 0, -3)
    pin.cam_dct['lookat'] = (0, 0, 0)
    pin.cam_dct['rotate'] = (250, 330, 0)
    pin.shadow = True
    pin.light_lst = [(0, 0, -5), (0, -5, 0), (-5, 0, 0), (0, 0, 5), (0, 5, 0),
                     (5, 0, 0)]
    pin.axes_dct['show'] = False
    pin.axes_dct['len'] = 1.2
    pin.height = 400
    pin.width = 800
    pin.quality = 11
    pin.ani_delay = 10
    pin.impl = None

    v0_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 5)]
    v1_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 10)]
    v1_F_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 2)]

    pin.pmz_dct['A'] = (pmz_AB_lst, 0)
    pin.pmz_dct['B'] = (pmz_AB_lst, 1)
    pin.pmz_dct['FA'] = (pmz_AB_lst, 0)
    pin.pmz_dct['FB'] = (pmz_AB_lst, 1)

    pin.curve_dct['A'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['B'] = {
        'step0': v0_lst,
        'step1': v1_lst,
        'prec': 10,
        'width': 0.05
    }
    pin.curve_dct['FA'] = {
        'step0': v0_lst,
        'step1': v1_F_lst,
        'prec': 10,
        'width': 0.01
    }
    pin.curve_dct['FB'] = {
        'step0': v0_lst,
        'step1': v1_F_lst,
        'prec': 10,
        'width': 0.01
    }

    col_A = (0.4, 0.0, 0.0, 0.0)
    col_B = (0.2, 0.3, 0.2, 0.0)
    colFF = (0.1, 0.1, 0.1, 0.0)

    pin.text_dct['A'] = [True, col_A, 'phong 0.2 phong_size 5']
    pin.text_dct['B'] = [True, col_B, 'phong 0.2 phong_size 5']
    pin.text_dct['FA'] = [True, colFF, 'phong 0.2 phong_size 5']
    pin.text_dct['FB'] = [True, colFF, 'phong 0.2 phong_size 5']

    if True:

        # raytrace image/animation
        #
        create_pov(pin, ['A', 'B'])
        create_pov(pin, ['A', 'B', 'FA', 'FB'])
        return

    else:

        # very low quality for fast debugging
        #
        pin.width = 100
        pin.height = 75
        pin.quality = 4
        v_lst = [(sage_QQ(i) / 180) * sage_pi for i in range(0, 360, 2 * 36)]

        pin.curve_dct['A'] = {
            'step0': v_lst,
            'step1': v_lst,
            'prec': 5,
            'width': 0.02
        }
        pin.curve_dct['B'] = {
            'step0': v_lst,
            'step1': v_lst,
            'prec': 5,
            'width': 0.02
        }

        create_pov(pin, ['A', 'B'])
        return