Exemplo n.º 1
0
def render_Dirichletwebpage(modulus=None, number=None):
    if modulus == None:
        return render_DirichletNavigation()
    modulus = modulus.replace(' ','')
    if number == None and re.match('^[1-9][0-9]*\.[1-9][0-9]*$', modulus):
        return redirect(url_for(".render_Dirichletwebpage", label=modulus), 301)

    args={}
    args['type'] = 'Dirichlet'
    args['modulus'] = modulus
    args['number'] = number
    try:
        modulus = int(modulus)
    except ValueError:
        modulus = 0
    if modulus <= 0:
        flash_error ("%s is not a valid modulus for a Dirichlet character.  It should be a positive integer.", args['modulus'])
        return redirect(url_for(".render_Dirichletwebpage"))
    if modulus > 10**20:
        flash_error ("specified modulus %s is too large, it should be less than $10^{20}$.", modulus)
        return redirect(url_for(".render_Dirichletwebpage"))
        
    
    if number == None:
        if modulus < 100000:
            info = WebDirichletGroup(**args).to_dict()
        else:
            info = WebSmallDirichletGroup(**args).to_dict()
        info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                         ('Dirichlet', url_for(".render_Dirichletwebpage")),
                         ('%d'%modulus, url_for(".render_Dirichletwebpage", modulus=modulus))]
        info['learnmore'] = learn()
        info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
        info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
        if 'gens' in info:
            info['generators'] = ', '.join([r'<a href="%s">$\chi_{%s}(%s,\cdot)$'%(url_for(".render_Dirichletwebpage",modulus=modulus,number=g),modulus,g) for g in info['gens']])
        return render_template('CharGroup.html', **info)

    try:
        number = int(number)
    except ValueError:
        number = 0;
    if number <= 0 or gcd(modulus,number) != 1 or number > modulus:
        flash_error("the value %s is invalid.  It should be a positive integer coprime to and no greater than the modulus %s.", args['number'],args['modulus'])
        return redirect(url_for(".render_Dirichletwebpage"))
    if modulus < 100000:
        webchar = WebDirichletCharacter(**args)
        info = webchar.to_dict()
    else:
        info = WebSmallDirichletCharacter(**args).to_dict()
    info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                     ('Dirichlet', url_for(".render_Dirichletwebpage")),
                     ('%s'%modulus, url_for(".render_Dirichletwebpage", modulus=modulus)),
                     ('%s'%number, url_for(".render_Dirichletwebpage", modulus=modulus, number=number)) ]
    info['learnmore'] = learn()
    info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
    info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
    return render_template('Character.html', **info)
Exemplo n.º 2
0
Arquivo: main.py Projeto: koffie/lmfdb
def dc_calc(calc, modulus, number):
    val = request.args.get("val", [])
    args = {'type':'Dirichlet', 'modulus':modulus, 'number':number}
    if not val:
        return flask.abort(404)
    try:
        if calc == 'value':
            return WebDirichletCharacter(**args).value(val)
        if calc == 'gauss':
            return WebDirichletCharacter(**args).gauss_sum(val)
        elif calc == 'jacobi':
            return WebDirichletCharacter(**args).jacobi_sum(val)
        elif calc == 'kloosterman':
            return WebDirichletCharacter(**args).kloosterman_sum(val)
        else:
            return flask.abort(404)
    except Warning, e:
        return "<span style='color:gray;'>%s</span>" % e
Exemplo n.º 3
0
 def line(n):
     l = []
     count = 0
     q = n
     while count < limit:
         if modn_exponent(q) % n == 0:
             G = DirichletGroup_conrey(q)
             for chi in G:
                 j = chi.number()
                 c = WebDirichletCharacter(modulus=q, number=j)
                 if chi.multiplicative_order() == n:
                     l.append((q, j, chi.is_primitive(),
                               chi.multiplicative_order(), c.symbol))
                     count += 1
                     if count == limit:
                         break
         q += 1
     return l
Exemplo n.º 4
0
 def line(N):
     l = []
     if N % 4 == 2:
         return l
     count = 0
     q = N
     while count < limit:
         if q % N == 0:
             G = DirichletGroup_conrey(q)
             for chi in G:
                 j = chi.number()
                 c = WebDirichletCharacter(modulus=q, number=j)
                 if chi.conductor() == q:
                     l.append((q, j, chi.is_primitive(),
                               chi.multiplicative_order(), c.symbol))
                     count += 1
                     if count == limit:
                         break
         q += N
     return l
Exemplo n.º 5
0
Arquivo: main.py Projeto: koffie/lmfdb
def galois_rep_from_path(p):
    if p[0] == 'EllipticCurve':
        # create the sage elliptic curve then create Galois rep object
        ainvs = db.ec_curves.lucky({'lmfdb_label': p[2] + "." + p[3] + p[4]},
                                   'ainvs')
        E = EllipticCurve(ainvs)
        return GaloisRepresentation(E)

    elif (p[0] == 'Character' and p[1] == 'Dirichlet'):
        dirichletArgs = {
            'type': 'Dirichlet',
            'modulus': int(p[2]),
            'number': int(p[3])
        }
        chi = WebDirichletCharacter(**dirichletArgs)
        return GaloisRepresentation(chi)

    elif (p[0] == 'ModularForm'):
        level = int(p[4])
        weight = int(p[5])
        conrey_label = p[6]  # this should be zero; TODO check this is the case
        hecke_orbit = p[7]  # this is a, b, c, etc.; chooses the galois orbit
        embedding = p[8]  # this is the embedding of that galois orbit
        label = convert_newformlabel_from_conrey(
            str(level) + "." + str(weight) + "." + str(conrey_label) + "." +
            hecke_orbit)
        form = WebNewform(label)
        return GaloisRepresentation([form, ZZ(embedding)])

    elif (p[0] == 'ArtinRepresentation'):
        dim = p[1]
        conductor = p[2]
        index = p[3]
        rho = ArtinRepresentation(dim, conductor, index)
        return GaloisRepresentation(rho)
    else:
        return
Exemplo n.º 6
0
def galois_rep_from_path(p):
    C = getDBConnection()
    if p[0] == 'EllipticCurve':
        # create the sage elliptic curve then create Galois rep object
        data = C.elliptic_curves.curves.find_one(
            {'lmfdb_label': p[2] + "." + p[3] + p[4]})
        ainvs = [int(a) for a in data['ainvs']]
        E = EllipticCurve(ainvs)
        return GaloisRepresentation(E)

    elif (p[0] == 'Character' and p[1] == 'Dirichlet'):
        dirichletArgs = {
            'type': 'Dirichlet',
            'modulus': int(p[2]),
            'number': int(p[3])
        }
        chi = WebDirichletCharacter(**dirichletArgs)
        return GaloisRepresentation(chi)

    elif (p[0] == 'ModularForm'):
        N = int(p[4])
        k = int(p[5])
        chi = p[6]  # this should be zero; TODO check this is the case
        label = p[7]  # this is a, b, c, etc.; chooses the galois orbit
        embedding = p[8]  # this is the embedding of that galois orbit
        form = WebNewForm(N, k, chi=chi, label=label)
        return GaloisRepresentation([form, ZZ(embedding)])

    elif (p[0] == 'ArtinRepresentation'):
        dim = p[1]
        conductor = p[2]
        index = p[3]
        rho = ArtinRepresentation(dim, conductor, index)
        return GaloisRepresentation(rho)
    else:
        return
Exemplo n.º 7
0
Arquivo: main.py Projeto: koffie/lmfdb
def render_Dirichletwebpage(modulus=None, number=None):

    if modulus == None:
        return render_DirichletNavigation()
    modulus = modulus.replace(' ','')
    if number == None and re.match('^[1-9][0-9]*\.[1-9][0-9]*$', modulus):
        return redirect(url_for(".render_Dirichletwebpage", label=modulus), 301)

    args={}
    args['type'] = 'Dirichlet'
    args['modulus'] = modulus
    args['number'] = number
    try:
        modulus = int(modulus)
    except ValueError:
        modulus = 0
    if modulus <= 0:
        flash_error ("%s is not a valid modulus for a Dirichlet character.  It should be a positive integer.", args['modulus'])
        return redirect(url_for(".render_Dirichletwebpage"))
    if modulus > 10**20:
        flash_error ("specified modulus %s is too large, it should be less than $10^{20}$.", modulus)
        return redirect(url_for(".render_Dirichletwebpage"))



    if number == None:
        if modulus < 10000:
            info = WebDBDirichletGroup(**args).to_dict()
            info['show_orbit_label'] = True
        elif modulus < 100000:
            info = WebDirichletGroup(**args).to_dict()
        else:
            info = WebSmallDirichletGroup(**args).to_dict()
        info['title'] = 'Group of Dirichlet Characters of Modulus ' + str(modulus)
        info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                         ('Dirichlet', url_for(".render_Dirichletwebpage")),
                         ('%d'%modulus, url_for(".render_Dirichletwebpage", modulus=modulus))]
        info['learnmore'] = learn()
        info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
        info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
        if 'gens' in info:
            info['generators'] = ', '.join([r'<a href="%s">$\chi_{%s}(%s,\cdot)$'%(url_for(".render_Dirichletwebpage",modulus=modulus,number=g),modulus,g) for g in info['gens']])
        return render_template('CharGroup.html', **info)

    try:
        number = int(number)
    except ValueError:
        number = 0;
    if number <= 0 or gcd(modulus,number) != 1 or number > modulus:
        flash_error("the value %s is invalid.  It should be a positive integer coprime to and no greater than the modulus %s.", args['number'],args['modulus'])
        return redirect(url_for(".render_Dirichletwebpage"))
    if modulus < 10000:
        webchar = WebDBDirichletCharacter(**args)
        info = webchar.to_dict()
    elif modulus < 100000:
        webchar = WebDirichletCharacter(**args)
        info = webchar.to_dict()
    else:
        info = WebSmallDirichletCharacter(**args).to_dict()
    info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                     ('Dirichlet', url_for(".render_Dirichletwebpage")),
                     ('%s'%modulus, url_for(".render_Dirichletwebpage", modulus=modulus)),
                     ('%s'%number, url_for(".render_Dirichletwebpage", modulus=modulus, number=number)) ]
    info['learnmore'] = learn()
    info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
    info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
    return render_template('Character.html', **info)