Exemplo n.º 1
0
def download_web_modform(info):
    emf_logger.debug("IN GET_WEB_MODFORM!!! info={0}".format(info))
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    if label != '':
        if format == 'sage':
            if character != 0:
                D = DirichletGroup(level)
                x = D[character]
                X = Newforms(x, weight, names='a')
            else:
                X = Newforms(level, weight, names='a')
        else:  # format=='web_new':
            X = WebNewForm(N=level, k=weight, chi=character, label=label)
    s = dumps(X)
    name = "{0}-{1}-{2}-{3}-web_newform.sobj".format(weight, level, character, label)
    emf_logger.debug("name={0}".format(name))
    info['filename'] = name
    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    try:
        return send_file(strIO,
                         attachment_filename=info["filename"],
                         as_attachment=True)
    except IOError:
        info['error'] = "Could not send file!"
Exemplo n.º 2
0
def get_coefficients(info):
    r"""
    Return a file with the Fourier coefficients in desired format.
    """
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    s = print_list_of_coefficients(info)
    print "s=",s
    if info['format']=="sage":
        ending = "sobj"
    else:
        ending = "txt"
    info['filename'] = str(weight) + '-' + str(
        level) + '-' + str(character) + '-' + label + 'coefficients-0to' + info['number'] + "."+ending
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])
    
    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True)
Exemplo n.º 3
0
def get_coefficients(info):
    r"""
    Return a file with the Fourier coefficients in desired format.
    """
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    s = print_list_of_coefficients(info)
    print "s=", s
    if info['format'] == "sage":
        ending = "sobj"
    else:
        ending = "txt"
    info['filename'] = str(weight) + '-' + str(level) + '-' + str(
        character
    ) + '-' + label + 'coefficients-0to' + info['number'] + "." + ending
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])

    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True)
Exemplo n.º 4
0
def download_web_modform(info):
    emf_logger.debug("IN GET_WEB_MODFORM!!! info={0}".format(info))
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    if label != '':
        if format == 'sage':
            if character != 0:
                D = DirichletGroup(level)
                x = D[character]
                X = Newforms(x, weight, names='a')
            else:
                X = Newforms(level, weight, names='a')
        else:  # format=='web_new':
            X = WebNewForm(N=level, k=weight, chi=character, label=label)
    s = dumps(X)
    name = "{0}-{1}-{2}-{3}-web_newform.sobj".format(weight, level, character,
                                                     label)
    emf_logger.debug("name={0}".format(name))
    info['filename'] = name
    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    try:
        return send_file(strIO,
                         attachment_filename=info["filename"],
                         as_attachment=True)
    except IOError:
        info['error'] = "Could not send file!"
Exemplo n.º 5
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    prec = my_get(info, 'prec', 12, int)  # number of digits
    bitprec = my_get(info, 'bitprec', 12, int)  # number of digits
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    fmt = info.get("format", "q_expansion")
    if character == '':
        character = '1'
    label = info.get('label', '')
    if character.isalnum():
        character = int(character)
    else:
        return "The character '{0}' is not well-defined!".format(character)
    print "--------------"
    if label == '' or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    number = int(info['number']) + 1 if 'number' in info else 20
    emf_logger.debug("number = {}".format(number))
    F = WebNewForm(level=level,
                   weight=weight,
                   character=character,
                   label=label,
                   prec=number)
    if not F.has_updated():
        return ""
    if not 'number' in info:
        F.prec = number = max(F.parent.sturm_bound + 1, 20)
        F.update_from_db()
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(
        F.parent.group) + "\)"
    s = ""
    if ((character is not None) and (character > 0)):
        shead = shead + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    if fmt == "sage":
        res = []
    if number > F.max_available_prec():
        raise IndexError, "The database does not contain this many ({0}) coefficients for this modular form! We only have {1}".format(
            number, F.max_available_prec())
    if fmt == "sage":
        qe = F.coefficients(range(number))
        res.append(qe)
    else:
        coefs += print_coefficients_for_one_form(F,
                                                 number,
                                                 info['format'],
                                                 bitprec=bitprec)
    if not fmt == "sage":
        return s + "\n" + coefs
    else:
        if len(res) == 1:
            res = res[0]
        #print "res=",res
        return dumps(res)
Exemplo n.º 6
0
def get_coefficients(info):
    r"""
    Return a file with the Fourier coefficients in desired format.
    """
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', int)  # int(info.get('weight',0))
    number = my_get(info, 'number', 100, int)
    label = my_get(info, 'label', '', str)
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 1
    label = info.get('label', '')
    if info['format'] == "sage":
        ending = "sage"
        f = WebNewForm(level, weight, character, label, prec=number)
        s = f.download_to_sage(number)
    elif info['format'] == "sobj":
        ending = "sobj"
        f = WebNewForm(level, weight, character, label, prec=number)
        s = f.dump_coefficients(number)
    else:
        # we only want one form or one embedding
        try:
            s = print_list_of_coefficients(info)
        except IndexError as e:
            info['error'] = str(e)
            flask.flash(str(e))
            return redirect(url_for("emf.render_elliptic_modular_forms",
                                    level=level,
                                    weight=weight,
                                    character=character,
                                    label=label),
                            code=301)
        ending = "txt"
    if info['format'] == 'q_expansion':
        fmt = '-qexp'
    elif info['format'] == "coefficients" or info['format'] == "sobj":
        fmt = '-coef'
    elif info['format'] == "embeddings":
        fmt = '-emb'
    else:
        fmt = ''
    info['filename'] = "{0}-{1}-{2}-{3}-coefficients-0-to-{4}{5}.{6}".format(
        level, weight, character, label, number, fmt, ending)
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'], add_etags=False)

    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True,
                     add_etags=False)
Exemplo n.º 7
0
def get_coefficients(info):
    r"""
    Return a file with the Fourier coefficients in desired format.
    """
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, "level", -1, int)
    weight = my_get(info, "weight", -1, int)
    character = my_get(info, "character", "", int)  # int(info.get('weight',0))
    number = my_get(info, "number", 100, int)
    label = my_get(info, "label", "", str)
    emf_logger.debug("info={0}".format(info))
    if character == "":
        character = 1
    label = info.get("label", "")
    if info["format"] == "sage":
        ending = "sage"
        f = WebNewForm(level, weight, character, label, prec=number)
        s = f.download_to_sage(number)
    elif info["format"] == "sobj":
        ending = "sobj"
        f = WebNewForm(level, weight, character, label, prec=number)
        s = f.dump_coefficients(number)
    else:
        # we only want one form or one embedding
        try:
            s = print_list_of_coefficients(info)
        except IndexError as e:
            info["error"] = str(e)
            flask.flash(str(e))
            return redirect(
                url_for(
                    "emf.render_elliptic_modular_forms", level=level, weight=weight, character=character, label=label
                ),
                code=301,
            )
        ending = "txt"
    if info["format"] == "q_expansion":
        fmt = "-qexp"
    elif info["format"] == "coefficients" or info["format"] == "sobj":
        fmt = "-coef"
    elif info["format"] == "embeddings":
        fmt = "-emb"
    else:
        fmt = ""
    info["filename"] = "{0}-{1}-{2}-{3}-coefficients-0-to-{4}{5}.{6}".format(
        level, weight, character, label, number, fmt, ending
    )
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'], add_etags=False)

    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO, attachment_filename=info["filename"], as_attachment=True, add_etags=False)
Exemplo n.º 8
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, "level", -1, int)
    weight = my_get(info, "weight", -1, int)
    bitprec = my_get(info, "bitprec", 12, int)  # number of digits
    character = my_get(info, "character", "", str)  # int(info.get('weight',0))
    fmt = info.get("format", "q_expansion")
    if character == "":
        character = "1"
    label = info.get("label", "")
    if character.isalnum():
        character = int(character)
    else:
        return "The character '{0}' is not well-defined!".format(character)
    print "--------------"
    if label == "" or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    number = int(info["number"]) + 1 if "number" in info else 20
    emf_logger.debug("number = {}".format(number))
    F = WebNewForm(level=level, weight=weight, character=character, label=label, prec=number)
    if not F.has_updated():
        return ""
    if not "number" in info:
        F.prec = number = max(F.parent.sturm_bound + 1, 20)
        F.update_from_db()
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(F.parent.group) + "\)"
    s = ""
    if (character is not None) and (character > 0):
        shead = shead + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    if fmt == "sage":
        res = []
    if number > F.max_available_prec():
        raise IndexError, "The database does not contain this many ({0}) coefficients for this modular form! We only have {1}".format(
            number, F.max_available_prec()
        )
    if fmt == "sage":
        qe = F.coefficients(range(number))
        res.append(qe)
    else:
        coefs += print_coefficients_for_one_form(F, number, info["format"], bitprec=bitprec)
    if not fmt == "sage":
        return s + "\n" + coefs
    else:
        if len(res) == 1:
            res = res[0]
        # print "res=",res
        return dumps(res)
Exemplo n.º 9
0
def get_search_parameters(info):
    ret = dict()
    # if not info.has_key('search') or not info['search']:
    #    return ret
    level = my_get(info, 'level', 0)
    mwf_logger.debug("get_search param=%s" % info)
    mwf_logger.debug("level=%s" % level)
    if level > 0:
        ret['l1'] = int(level)
        ret['l2'] = int(level)
    else:
        level_range = my_get(info, 'level_range', '').split('..')
        if len(level_range) == 0:
            ret['l1'] = 0
            ret['l2'] = 0
        elif len(level_range) == 1:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[0]
        else:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[1]
    character = my_get(info, 'character', 1)
    mwf_logger.info("character: %s" % character)
    if character > 1:
        ret['ch1'] = int(character)
        ret['ch2'] = int(character)
    weight = my_get(info, 'weight', -1)
    if weight > -1:
        ret['wt1'] = float(weight)
        ret['wt2'] = float(weight)
    else:
        weight_range = my_get(info, 'weight_range', '').split('..')
        if len(weight_range) == 0:
            ret['wt1'] = 0
            ret['wt2'] = 0
        elif len(weight_range) == 1:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[0]
        else:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[1]

    ret['rec_start'] = my_get(info, 'rec_start', 1, int)
    ret['limit'] = my_get(info, 'limit', 2000, int)
    # ret['weight']=my_get(info,'weight',0,int)
    ev_range = my_get(info, 'ev_range', '').split('..')
    if len(ev_range) == 0:
        ret['r1'] = 0
        ret['r2'] = 0
    elif len(ev_range) == 1:
        mwf_logger.debug("ev_range=%s" % ev_range)
        # ev_range[0]=float(ev_range[0]); ev_range[1]=float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[0]
    else:
        ev_range[0] = float(ev_range[0])
        ev_range[1] = float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[1]
    return ret
Exemplo n.º 10
0
def get_search_parameters(info):
    ret = dict()
    # if not info.has_key('search') or not info['search']:
    #    return ret
    level = my_get(info, 'level', 0)
    mwf_logger.debug("get_search param=%s" % info)
    mwf_logger.debug("level=%s" % level)
    if level > 0:
        ret['l1'] = int(level)
        ret['l2'] = int(level)
    else:
        level_range = my_get(info, 'level_range', '').split('..')
        if len(level_range) == 0:
            ret['l1'] = 0
            ret['l2'] = 0
        elif len(level_range) == 1:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[0]
        else:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[1]
    character = my_get(info, 'character', 1)
    mwf_logger.info("character: %s" % character)
    if character > 1:
        ret['ch1'] = int(character)
        ret['ch2'] = int(character)
    weight = my_get(info, 'weight', -1)
    if weight > -1:
        ret['wt1'] = float(weight)
        ret['wt2'] = float(weight)
    else:
        weight_range = my_get(info, 'weight_range', '').split('..')
        if len(weight_range) == 0:
            ret['wt1'] = 0
            ret['wt2'] = 0
        elif len(weight_range) == 1:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[0]
        else:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[1]

    ret['rec_start'] = my_get(info, 'rec_start', 1, int)
    ret['limit'] = my_get(info, 'limit', 2000, int)
    # ret['weight']=my_get(info,'weight',0,int)
    ev_range = my_get(info, 'ev_range', '').split('..')
    if len(ev_range) == 0:
        ret['r1'] = 0
        ret['r2'] = 0
    elif len(ev_range) == 1:
        mwf_logger.debug("ev_range=%s" % ev_range)
        # ev_range[0]=float(ev_range[0]); ev_range[1]=float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[0]
    else:
        ev_range[0] = float(ev_range[0])
        ev_range[1] = float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[1]
    return ret
Exemplo n.º 11
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    prec = my_get(info, 'prec', 12, int)  # number of digits
    bitprec = my_get(info, 'bitprec', 12, int)  # number of digits
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    if character == '':
        character = 0
    label = info.get('label', '')
    print "--------------"
    if label == '' or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    WMFS = WebModFormSpace(N=level, k=weight, chi=character)
    if not WMFS:
        return ""
    if ('number' in info):
        number = int(info['number'])
    else:
        number = max(WMFS.sturm_bound() + 1, 20)
    FS = list()
    if (label is not None):
        FS.append(WMFS.f(label))
    else:
        for a in WMFS.labels():
            FS.append(WMFS.f(a))
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(
        WMFS.group()) + "\)"
    s = ""
    if ((character is not None) and (character > 0)):
        s = s + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    for F in FS:
        if len(FS) > 1:
            if info['format'] == 'html':
                coefs += F.label()
            else:
                coefs += F.label()
        coefs += print_coefficients_for_one_form(F,
                                                 number,
                                                 info['format'],
                                                 bitprec=bitprec)
    ss = coefs
    return ss
Exemplo n.º 12
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    prec = my_get(info, 'prec', 12, int)  # number of digits
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    if character == '':
        character = 0
    label = info.get('label', '')
    print "--------------"
    if label == '' or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    WMFS = WebModFormSpace(N = level, k = weight, chi = character)
    if not WMFS:
        return ""
    if('number' in info):
        number = int(info['number'])
    else:
        number = max(WMFS.sturm_bound() + 1, 20)
    if('prec' in info):
        bprec = int(ceil(prec * 3.4))
    else:
        bprec = 53
    FS = list()
    if(label is not None):
        FS.append(WMFS.f(label))
    else:
        for a in WMFS.labels():
            FS.append(WMFS.f(a))
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(WMFS.group()) + "\)"
    s = ""
    if((character is not None) and (character > 0)):
        s = s + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    for F in FS:
        if len(FS) > 1:
            if info['format'] == 'html':
                coefs += F.label()
            else:
                coefs += F.label()
        coefs += print_coefficients_for_one_form(F, number, info['format'])
    ss = coefs
    return ss
Exemplo n.º 13
0
def get_args(request, level=0, weight=0, character=-1, label='', keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Exemplo n.º 14
0
def get_args(request, level=0, weight=0, character=-1, label='', keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Exemplo n.º 15
0
def render_elliptic_modular_forms(level=0,
                                  weight=0,
                                  character=None,
                                  label='',
                                  **kwds):
    r"""
    Default input of same type as required. Note that for holomorphic modular forms: level=0 or weight=0 are non-existent.
    """
    if character is None and level == 0 and weight == 0:
        character = 0
    elif character is None:
        character = -1
    emf_logger.debug(
        "In render: level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label))
    emf_logger.debug("args={0}".format(request.args))
    emf_logger.debug("args={0}".format(request.form))
    emf_logger.debug("met={0}".format(request.method))
    keys = ['download', 'jump_to']
    info = get_args(request, level, weight, character, label, keys=keys)
    level = info['level']
    weight = info['weight']
    character = info['character']
    label = info['label']
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if 'download' in info:
        return get_downloads(**info)
    emf_logger.debug("info=%s" % info)
    ## Consistency of arguments>
    # if level<=0:  level=None
    # if weight<=0:  weight=None
    if 'jump_to' in info:  # try to find out which form we want to jump
        s = my_get(info, 'jump_to', '', str)
        emf_logger.info("info.keys1={0}".format(info.keys()))
        info.pop('jump_to')
        emf_logger.info("info.keys2={0}".format(info.keys()))
        args = extract_data_from_jump_to(s)
        emf_logger.debug("args=%s" % args)
        return redirect(url_for("emf.render_elliptic_modular_forms", **args),
                        code=301)
        # return render_elliptic_modular_forms(**args)
    if level > 0 and weight > 0 and character > -1 and label != '':
        emf_logger.debug("info=%s" % info)
        return render_one_elliptic_modular_form(**info)
    if level > 0 and weight > 0 and character > -1:
        return render_elliptic_modular_form_space(**info)
    if level > 0 and weight > 0:
        return browse_elliptic_modular_forms(**info)
    if (level > 0 and weight == 0) or (weight > 0 and level == 0):
        emf_logger.debug("Have level or weight only!")
        return browse_elliptic_modular_forms(**info)
        # return render_elliptic_modular_form_navigation_wp(**info)
    # Otherwise we go to the main navigation page
    return render_elliptic_modular_form_navigation_wp(**info)
Exemplo n.º 16
0
def get_coefficients(info):
    r"""
    Return a file with the Fourier coefficients in desired format.
    """
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    number=my_get(info,'number',0,int) + 1
    label=my_get(info,'label','',str)
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    try:
        s = print_list_of_coefficients(info)
    except IndexError as e:
        info['error']=str(e)
        flask.flash(str(e))
        return redirect(url_for("emf.render_elliptic_modular_forms", level=level,weight=weight,character=character,label=label), code=301)
    if info['format']=="sage":
        ending = "sobj"
    else:
        ending = "txt"
    if info['format'] == 'q_expansion':
        fmt = '-qexp'
    elif info['format'] == "coefficients":
        fmt = '-coef'
    elif info['format'] == "embeddings":
        fmt = '-emb'
    else:
        fmt=''
    info['filename'] = "{0}-{1}-{2}-{3}-coefficients-0-to-{4}{5}.{6}".format(level,weight,character,label,number,fmt,ending)
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])

    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True)
Exemplo n.º 17
0
def get_coefficients(info):
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    s = print_list_of_coefficients(info)
    info['filename'] = str(weight) + '-' + str(level) + '-' + str(
        character) + '-' + label + 'coefficients-0to' + info['number'] + '.txt'
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])
    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True)
Exemplo n.º 18
0
def get_coefficients(info):
    emf_logger.debug("IN GET_COEFFICIENTS!!!")
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    emf_logger.debug("info={0}".format(info))
    if character == '':
        character = 0
    label = info.get('label', '')
    # we only want one form or one embedding
    s = print_list_of_coefficients(info)
    info['filename'] = str(weight) + '-' + str(
        level) + '-' + str(character) + '-' + label + 'coefficients-0to' + info['number'] + '.txt'
    # return send_file(info['tempfile'], as_attachment=True, attachment_filename=info['filename'])
    strIO = StringIO.StringIO()
    strIO.write(s)
    strIO.seek(0)
    return send_file(strIO,
                     attachment_filename=info["filename"],
                     as_attachment=True)
Exemplo n.º 19
0
def get_args(request,
             level=0,
             weight=0,
             character=-1,
             group=2,
             label='',
             keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    emf_logger.debug("REQUEST:{0}".format(dd))
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    emf_logger.debug("group={0}".format(group))
    info['group'] = my_get(dd, 'group', group, int)
    emf_logger.debug("info[group]={0}".format(info['group']))
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Exemplo n.º 20
0
def render_elliptic_modular_forms(level=0, weight=0, character=None, label='', **kwds):
    r"""
    Default input of same type as required. Note that for holomorphic modular forms: level=0 or weight=0 are non-existent.
    """
    if character is None and level == 0 and weight == 0:
        character = 0
    elif character is None:
        character = -1
    emf_logger.debug(
        "In render: level={0},weight={1},character={2},label={3}".format(level, weight, character, label))
    emf_logger.debug("args={0}".format(request.args))
    emf_logger.debug("args={0}".format(request.form))
    emf_logger.debug("met={0}".format(request.method))
    keys = ['download', 'jump_to']
    info = get_args(request, level, weight, character, label, keys=keys)
    level = info['level']
    weight = info['weight']
    character = info['character']
    label = info['label']
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if 'download' in info:
        return get_downloads(**info)
    emf_logger.debug("info=%s" % info)
    ## Consistency of arguments>
    # if level<=0:  level=None
    # if weight<=0:  weight=None
    if 'jump_to' in info:  # try to find out which form we want to jump
        s = my_get(info, 'jump_to', '', str)
        emf_logger.info("info.keys1={0}".format(info.keys()))
        info.pop('jump_to')
        emf_logger.info("info.keys2={0}".format(info.keys()))
        args = extract_data_from_jump_to(s)
        emf_logger.debug("args=%s" % args)
        return redirect(url_for("emf.render_elliptic_modular_forms", **args), code=301)
        # return render_elliptic_modular_forms(**args)
    if level > 0 and weight > 0 and character > -1 and label != '':
        emf_logger.debug("info=%s" % info)
        return render_one_elliptic_modular_form(**info)
    if level > 0 and weight > 0 and character > -1:
        return render_elliptic_modular_form_space(**info)
    if level > 0 and weight > 0:
        return browse_elliptic_modular_forms(**info)
    if (level > 0 and weight == 0) or (weight > 0 and level == 0):
        emf_logger.debug("Have level or weight only!")
        return browse_elliptic_modular_forms(**info)
        # return render_elliptic_modular_form_navigation_wp(**info)
    # Otherwise we go to the main navigation page
    return render_elliptic_modular_form_navigation_wp(**info)
Exemplo n.º 21
0
def get_qexp(level, weight, character, label, **kwds):
    emf_logger.debug(
        "get_qexp for: level={0},weight={1},character={2},label={3}".format(level, weight, character, label))
    prec = my_get(request.args, "prec", default_prec, int)
    if not arg:
        return flask.abort(404)
    try:
        WNF = WebNewForm(weight, level, chi=character, label=label, prec=prec, verbose=2)
        nc = max(prec, 5)
        c = WNF.print_q_expansion(nc)
        return c
    except Exception, e:
        return "<span style='color:red;'>ERROR: %s</span>" % e
Exemplo n.º 22
0
def get_qexp(level, weight, character, label, **kwds):
    emf_logger.debug(
        "get_qexp for: level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label))
    prec = my_get(request.args, "prec", default_prec, int)
    if not arg:
        return flask.abort(404)
    try:
        WNF = WebNewForm(level,
                         weight,
                         chi=character,
                         label=label,
                         prec=prec,
                         verbose=2)
        nc = max(prec, 5)
        c = WNF.print_q_expansion(nc)
        return c
    except Exception as e:
        return "<span style='color:red;'>ERROR: %s</span>" % e.message
Exemplo n.º 23
0
def get_args(request, level=0, weight=0, character=-1, group=2, label='', keys=[]):
    r"""
    Use default input of the same type as desired output.
    """
    if request.method == 'GET':
        dd = to_dict(request.args)
    else:
        dd = to_dict(request.form)
    emf_logger.debug("REQUEST:{0}".format(dd))
    info = dict()
    info['level'] = my_get(dd, 'level', level, int)
    info['weight'] = my_get(dd, 'weight', weight, int)
    info['character'] = my_get(dd, 'character', character, int)
    emf_logger.debug("group={0}".format(group))
    info['group'] = my_get(dd, 'group', group, int)
    emf_logger.debug("info[group]={0}".format(info['group']))
    info['label'] = my_get(dd, 'label', label, str)
    for key in keys:
        if key in dd:
            info[key] = my_get(dd, key, '', str)
    return info
Exemplo n.º 24
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    prec = my_get(info, 'prec', 12, int)  # number of digits
    bitprec = my_get(info, 'bitprec', 12, int)  # number of digits
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    fmt = info.get("format", "q_expansion")
    if character == '':
        character = '1'
    label = info.get('label', '')
    if character.isalnum():
        character = int(character)
    else:
        return "The character '{0}' is not well-defined!".format(character)
    print "--------------"
    if label == '' or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    WMFS = WebModFormSpace(level=level,
                           weight=weight,
                           cuspidal=True,
                           character=character)
    if not WMFS:
        return ""
    if ('number' in info):
        number = int(info['number']) + 1
    else:
        number = max(WMFS.sturm_bound + 1, 20)
    FS = list()
    f = WMFS.hecke_orbits.get(label)
    if f is not None:
        FS.append(f)
    else:
        for label in WMFS.hecke_orbits:
            FS.append(WMFS.f(label))
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(
        WMFS.group) + "\)"
    s = ""
    if ((character is not None) and (character > 0)):
        shead = shead + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    if fmt == "sage":
        res = []
    for F in FS:
        if number > F.max_cn():
            raise IndexError, "The database does not contain this many ({0}) coefficients for this modular form! We only have {1}".format(
                number, F.max_cn())
        if len(FS) > 1:
            if info['format'] == 'html':
                coefs += F.label()
            else:
                coefs += F.label()
        if fmt == "sage":
            qe = F.coefficients(range(number))
            res.append(qe)
        else:
            coefs += print_coefficients_for_one_form(F,
                                                     number,
                                                     info['format'],
                                                     bitprec=bitprec)
    if not fmt == "sage":
        return s + "\n" + coefs
    else:
        if len(res) == 1:
            res = res[0]
        #print "res=",res
        return dumps(res)
Exemplo n.º 25
0
def render_elliptic_modular_form_navigation_wp1(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    group = my_get(info, 'group', 1, int)
    if group == int(0):
        pass
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight, int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
        weight = None
        info.pop('weight', None)
    if isinstance(level, int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level', None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page')),
             (title, url_for('.render_elliptic_modular_forms'))]

    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(
            limits_level[0], limits_weight[0])
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12)  # default values
    if is_set['level']:
        limits_level = (level, level)
    elif limits_level is None:
        limits_level = (1, 24)  # default values
    try:
        group = info.get('group', 0)  # default group is gamma_0
        group = int(group)
    except ValueError:
        group = 0
    if group not in [0, 1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    emf_logger.debug("level:{0},level_range={1}".format(level, limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(
        weight, limits_weight))

    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
                                level=limits_level[0],
                                weight=limits_weight[0],
                                group=group),
                        code=301)
    info['show_switch'] = True
    db = getDBConnection()['modularforms2']['webmodformspace_dimension']
    table = {}
    q = db.find_one({'group': 'gamma{0}'.format(group)})
    if q:
        table = q.get('data', {})
    if table != {}:
        table = json.loads(table)
    info['table'] = {}
    level_range = range(limits_level[0], limits_level[1] + 1)
    # we don't have weight 1 in database
    if limits_weight[0] == 1:
        limits_weight = (2, limits_weight[1])
    weight_range = range(limits_weight[0], limits_weight[1] + 1)
    #print "levels=",level_range
    #print "weights=",weight_range
    if len(weight_range) > 1:
        info['weight_range'] = "{0}-{1}".format(limits_weight[0],
                                                limits_weight[1])
    if len(level_range) > 1:
        info['level_range'] = "{0}-{1}".format(limits_level[0],
                                               limits_level[1])
    if group == 0:
        weight_range = filter(is_even, weight_range)
        for n in level_range:
            info['table'][n] = {}
            sn = unicode(n)
            for k in weight_range:
                info['table'][n][k] = {}
                sk = unicode(k)
                if table.has_key(sn):
                    if table[sn].has_key(sk):
                        info['table'][n][k] = table[sn][
                            sk]  #.get(str(n),{}).get(str(k),"n/a")
    else:
        emf_logger.debug("Set table for Gamma1")
        for n in level_range:
            info['table'][n] = {}
            for k in weight_range:
                info['table'][n][k] = table.get(str(n),
                                                {}).get(str(k), {}).get(
                                                    str(-1), "n/a")
    #print "table=\n",table
    #print "info=\n",info
    #info['table']=table
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html",
                           info=info,
                           title=title,
                           bread=bread)
Exemplo n.º 26
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    from lmfdb.modular_forms.elliptic_modular_forms import WebModFormSpace
    dimension_table_name = WebModFormSpace._dimension_table_name

    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', None, int)
    weight = my_get(info, 'weight', None, int)
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight, int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
        weight = None
        info.pop('weight', None)
    if isinstance(level, int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level', None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    bread.append((EMF_TOP, url_for('.render_elliptic_modular_forms')))
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12)  # default values
    if is_set['level']:
        limits_level = (level, level)
    elif limits_level is None:
        limits_level = (1, 24)  # default values
    try:
        group = info.get('group', 0)  # default group is gamma_0
        group = int(group)
    except ValueError:
        group = 0
    if group not in [0, 1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    emf_logger.debug("level:{0},level_range={1}".format(level, limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(
        weight, limits_weight))
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
                                level=limits_level[0],
                                weight=limits_weight[0],
                                group=group),
                        code=301)
    info['show_switch'] = True
    emf_logger.debug("dimension table name={0}".format(dimension_table_name))
    db_dim = getDBConnection()['modularforms2'][dimension_table_name]
    s = {
        'level': {
            "$lt": int(limits_level[1] + 1),
            "$gt": int(limits_level[0] - 1)
        },
        'weight': {
            "$lt": int(limits_weight[1] + 1),
            "$gt": int(limits_weight[0] - 1)
        }
    }
    if group == 0:
        s['cchi'] = int(1)
    else:
        s['gamma1_label'] = {"$exists": True}
    g = db_dim.find(s).sort([('level', int(1)), ('weight', int(1))])
    table = {}
    info['table'] = {}
    level_range = range(limits_level[0], limits_level[1] + 1)
    # we don't have weight 1 in database
    if limits_weight[0] == 1:
        limits_weight = (2, limits_weight[1])
    weight_range = range(limits_weight[0], limits_weight[1] + 1)
    if group == 0:
        weight_range = filter(is_even, weight_range)
    if len(weight_range) > 1:
        info['weight_range'] = "{0}-{1}".format(limits_weight[0],
                                                limits_weight[1])
    if len(level_range) > 1:
        info['level_range'] = "{0}-{1}".format(limits_level[0],
                                               limits_level[1])
    for n in level_range:
        info['table'][n] = {}
        for k in weight_range:
            info['table'][n][k] = {'dim_new': int(0), 'in_db': -1}
    for r in db_dim.find(s):
        N = r['level']
        k = r['weight']
        if group != 0 or k % 2 == 0:
            #emf_logger.debug("Found:k={0},N={1}".format(k,N))
            dim = r['d_newf']  # dimension of newforms
            info['table'][N][k]['dim_new'] = dim
            if group == 0:
                indb = r['in_wdb']  # 1 if it is in the webmodforms db else 0
            else:
                indb = r.get('one_in_wdb',
                             0)  # 1 if it is in the webmodforms db else 0
                if dim == 0:
                    indb = 1
            info['table'][N][k]['in_db'] = indb
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html",
                           info=info,
                           title=title,
                           bread=bread)
Exemplo n.º 27
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    from lmfdb.modular_forms.elliptic_modular_forms import WebModFormSpace
    dimension_table_name = WebModFormSpace._dimension_table_name
  
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', None, int)
    weight = my_get(info, 'weight', None, int)
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight,int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
       weight = None
       info.pop('weight',None)
    if isinstance(level,int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level',None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    bread.append((EMF_TOP, url_for('.render_elliptic_modular_forms')))
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12) # default values
    if is_set['level']:
        limits_level = (level, level) 
    elif limits_level is None:
        limits_level = (1, 24) # default values
    try:
        group = info.get('group',0) # default group is gamma_0
        group = int(group)
    except ValueError: 
        group = 0
    if group not in [0,1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0; info['groupother'] = 1
    else:
        info['grouptype'] = 1; info['groupother'] = 0
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    emf_logger.debug("level:{0},level_range={1}".format(level,limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(weight,limits_weight))    
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
          level=limits_level[0],weight=limits_weight[0],group=group), code=301)
    info['show_switch'] = True
    emf_logger.debug("dimension table name={0}".format(dimension_table_name))
    db_dim = getDBConnection()['modularforms2'][dimension_table_name]
    s = {'level':{"$lt":int(limits_level[1]+1),"$gt":int(limits_level[0]-1)},
         'weight' : {"$lt":int(limits_weight[1]+1),"$gt":int(limits_weight[0]-1)}}
    if group == 0:
        s['cchi']=int(1)
    else:
        s['gamma1_label']={"$exists":True}
    g = db_dim.find(s).sort([('level',int(1)),('weight',int(1))])
    table = {}
    info['table'] = {}
    level_range = range(limits_level[0],limits_level[1]+1)
    # we don't have weight 1 in database
    if limits_weight[0]==1:
        limits_weight=(2,limits_weight[1])
    weight_range = range(limits_weight[0],limits_weight[1]+1)
    if group == 0:
        weight_range = filter(is_even,weight_range)
    if len(weight_range)>1:
        info['weight_range']="{0}-{1}".format(limits_weight[0],limits_weight[1])
    elif len(weight_range)==1:
        info['weight_range']="{0}".format(limits_weight[0])
    if len(level_range)>1:
        info['level_range']="{0}-{1}".format(limits_level[0],limits_level[1])
    if len(level_range)==1:
        info['level_range']="{0}".format(limits_level[0])        
    for n in level_range:
        info['table'][n]={}
        for k in weight_range:
            info['table'][n][k]={'dim_new':int(0), 'in_db':-1}
    for r in db_dim.find(s):
        N = r['level']
        k = r['weight']
        if group != 0 or k%2==0:
            #emf_logger.debug("Found:k={0},N={1}".format(k,N))
            dim = r['d_newf'] # dimension of newforms
            info['table'][N][k]['dim_new'] = dim
            if group == 0:
                indb = r['in_wdb'] # 1 if it is in the webmodforms db else 0
            else:
                indb = r.get('one_in_wdb',0) # 1 if it is in the webmodforms db else 0
                if dim == 0:
                    indb = 1
            info['table'][N][k]['in_db'] = indb
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html", info=info, title=title, bread=bread)
Exemplo n.º 28
0
def set_info_for_web_newform(level=None,
                             weight=None,
                             character=None,
                             label=None,
                             **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))
    try:
        WNF = WebNewForm_cached(level=level,
                                weight=weight,
                                character=character,
                                label=label)
        if not WNF.has_updated():
            raise IndexError(
                "Unfortunately, we do not have this newform in the database.")
        info['character_order'] = WNF.character.order
        info['code'] = WNF.code
        emf_logger.debug("defined webnewform for rendering!")
    except IndexError as e:
        info['error'] = e.message
    url0 = url_for("mf.modular_form_main_page")
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight,
                   character=character)
    bread = [(MF_TOP, url0), (EMF_TOP, url1)]
    bread.append(("Level %s" % level, url2))
    bread.append(("Weight %s" % weight, url3))
    bread.append(("Character \( %s \)" % (WNF.character.latex_name), url4))
    bread.append(
        ("Newform %d.%d.%d.%s" % (level, weight, int(character), label), ''))
    info['bread'] = bread

    properties2 = list()
    friends = list()
    space_url = url_for('emf.render_elliptic_modular_forms',
                        level=level,
                        weight=weight,
                        character=character)
    friends.append(
        ('\( S_{%s}(%s, %s)\)' %
         (WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if hasattr(WNF.base_ring, "lmfdb_url") and WNF.base_ring.lmfdb_url:
        friends.append(('Number field ' + WNF.base_ring.lmfdb_pretty,
                        WNF.base_ring.lmfdb_url))
    if hasattr(WNF.coefficient_field,
               "lmfdb_url") and WNF.coefficient_field.lmfdb_label:
        friends.append(('Number field ' + WNF.coefficient_field.lmfdb_pretty,
                        WNF.coefficient_field.lmfdb_url))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)",
                    WNF.character.url()))

    if WNF.dimension == 0 and not info.has_key('error'):
        info['error'] = "This space is empty!"
    info['title'] = 'Newform ' + WNF.hecke_orbit_label
    info['learnmore'] = [('History of modular forms',
                          url_for('.holomorphic_mf_history'))]
    if 'error' in info:
        return info
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    ## Example to illustrate the different cases
    ## base              = CyclotomicField(n) -- of degree phi(n)
    ## coefficient_field = NumberField( p(x)) for some p in base['x'] of degree m
    ##   we would then have cdeg = m*phi(n) and bdeg = phi(n)
    ##   and rdeg = m
    ## Unfortunately, for e.g. base = coefficient_field = CyclotomicField(6)
    ## we get coefficient_field.relative_degree() == 2 although it should be 1
    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if cdeg == 1:
        rdeg = 1
    else:
        ## just setting rdeg = WNF.coefficient_field.relative_degree() does not give correct result...
        ##
        rdeg = QQ(cdeg) / QQ(bdeg)
    cf_is_QQ = (cdeg == 1)
    br_is_QQ = (bdeg == 1)
    if cf_is_QQ:
        info['satake'] = WNF.satake
    if WNF.complexity_of_first_nonvanishing_coefficients(
    ) > default_max_height:
        info['qexp'] = ""
        info['qexp_display'] = ''
        info['hide_qexp'] = True
        n, c = WNF.first_nonvanishing_coefficient()
        info['trace_nv'] = latex(WNF.first_nonvanishing_coefficient_trace())
        info['norm_nv'] = '\\approx ' + latex(
            WNF.first_nonvanishing_coefficient_norm().n())
        info['index_nv'] = n
    else:
        if WNF.prec < prec:
            #get WNF record at larger prec
            WNF.prec = prec
            WNF.update_from_db()
        info['qexp'] = WNF.q_expansion_latex(prec=10, name='\\alpha ')
        info['qexp_display'] = url_for(".get_qexp_latex",
                                       level=level,
                                       weight=weight,
                                       character=character,
                                       label=label)
        info["hide_qexp"] = False
    info['max_cn_qexp'] = WNF.q_expansion.prec()
    ## All combinations should be tested...
    ## 13/4/4/a -> base ring = coefficient_field = QQ(zeta_6)
    ## 13/3/8/a ->  base_ring = QQ(zeta_4), coefficient_field has poly x^2+(2\zeta_4+2x-3\zeta_$ over base_ring
    ## 13/4/3/a ->  base_ring = coefficient_field = QQ(zeta_3)
    ## 13/4/1/a -> all rational
    ## 13/6/1/a/ -> base_ring = QQ, coefficient_field = Q(sqrt(17))
    ## These are variables which needs to be set properly below
    info['polvars'] = {'base_ring': 'x', 'coefficient_field': '\\alpha'}
    if not cf_is_QQ:
        if rdeg > 1:  # not WNF.coefficient_field == WNF.base_ring:
            ## Here WNF.base_ring should be some cyclotomic field and we have an extension over this.
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = web_latex_poly(p1,
                                       '\\alpha')  # make the variable \alpha
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            zeta = p1.base_ring().gens()[0]
            #           p2 = zeta.minpoly() #this is not used anymore
            #           b_pol_ltx = web_latex_poly(p2, latex(zeta)) #this is not used anymore
            z1 = zeta.multiplicative_order()
            info['coeff_field'] = [
                WNF.coefficient_field.absolute_polynomial_latex('x'),
                c_pol_ltx_x, z1
            ]
            if hasattr(WNF.coefficient_field,
                       "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [
                    WNF.coefficient_field.lmfdb_url,
                    WNF.coefficient_field.lmfdb_pretty,
                    WNF.coefficient_field.lmfdb_label
                ]
            if z1 == 4:
                info[
                    'polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\) and \(\zeta_4=i\).</div><br/>'.format(
                        c_pol_ltx)
                info['polvars']['base_ring'] = 'i'
            elif z1 <= 2:
                info[
                    'polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\).</div><br/>'.format(
                        c_pol_ltx)
            else:
                info[
                    'polynomial_st'] = '<div class="where">where</div> %s\(\mathstrut=0\) and \(\zeta_{%s}=e^{\\frac{2\\pi i}{%s}}\) ' % (
                        c_pol_ltx, z1, z1)
                info['polvars']['base_ring'] = '\zeta_{{ {0} }}'.format(z1)
                if z1 == 3:
                    info[
                        'polynomial_st'] += 'is a primitive cube root of unity.'
                else:
                    info[
                        'polynomial_st'] += 'is a primitive {0}-th root of unity.'.format(
                            z1)
        elif not br_is_QQ:
            ## Now we have base and coefficient field being equal, meaning that since the coefficient field is not QQ it is some cyclotomic field
            ## generated by some \zeta_n
            p1 = WNF.coefficient_field.absolute_polynomial()
            z1 = WNF.coefficient_field.gens()[0].multiplicative_order()
            c_pol_ltx = web_latex_poly(p1, '\\zeta_{{{0}}}'.format(z1))
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            info['coeff_field'] = [
                WNF.coefficient_field.absolute_polynomial_latex('x'),
                c_pol_ltx_x
            ]
            if hasattr(WNF.coefficient_field,
                       "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [
                    WNF.coefficient_field.lmfdb_url,
                    WNF.coefficient_field.lmfdb_pretty,
                    WNF.coefficient_field.lmfdb_label
                ]
            if z1 == 4:
                info[
                    'polynomial_st'] = '<div class="where">where \(\zeta_4=e^{{\\frac{{\\pi i}}{{ 2 }} }}=i \).</div>'.format(
                        c_pol_ltx)
                info['polvars']['coefficient_field'] = 'i'
            elif z1 <= 2:
                info['polynomial_st'] = ''
            else:
                info[
                    'polynomial_st'] = '<div class="where">where \(\zeta_{{{0}}}=e^{{\\frac{{2\\pi i}}{{ {0} }} }}\) '.format(
                        z1)
                info['polvars']['coefficient_field'] = '\zeta_{{{0}}}'.format(
                    z1)
                if z1 == 3:
                    info[
                        'polynomial_st'] += 'is a primitive cube root of unity.</div>'
                else:
                    info[
                        'polynomial_st'] += 'is a primitive {0}-th root of unity.</div>'.format(
                            z1)
    else:
        info['polynomial_st'] = ''
    if info["hide_qexp"]:
        info['polynomial_st'] = ''
    info['degree'] = int(cdeg)
    if cdeg == 1:
        info['is_rational'] = 1
        info['coeff_field_pretty'] = [
            WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty
        ]
    else:
        info['is_rational'] = 0
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF._embeddings[
        'values']  #q_expansion_embeddings(prec, bprec,format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = [('Level', str(level)), ('Weight', str(weight)),
                   ('Character', '$' + WNF.character.latex_name + '$'),
                   ('Label', WNF.hecke_orbit_label),
                   ('Dimension of Galois orbit', str(WNF.dimension))]
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.twist_info
        if isinstance(info['twist_info'],
                      list) and len(info['twist_info']) > 0:
            info['is_minimal'] = info['twist_info'][0]
            if (info['twist_info'][0]):
                s = 'Is minimal<br>'
            else:
                s = 'Is a twist of lower level<br>'
            properties2 += [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 += [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key('tau') and len(CM['tau']) != 0:
            info['CM_values'] = CM
    info['is_cm'] = WNF.is_cm
    if WNF.is_cm == 1:
        info['cm_field'] = "2.0.{0}.1".format(-WNF.cm_disc)
        info['cm_disc'] = WNF.cm_disc
        info['cm_field_knowl'] = nf_display_knowl(
            info['cm_field'], getDBConnection(),
            field_pretty(info['cm_field']))
        info['cm_field_url'] = url_for("number_fields.by_label",
                                       label=info["cm_field"])
    if WNF.is_cm is None or WNF.is_cm == -1:
        s = '- Unknown (insufficient data)<br>'
    elif WNF.is_cm == 1:
        s = 'Yes<br>'
    else:
        s = 'No<br>'
    properties2.append(('CM', s))
    alev = WNF.atkin_lehner_eigenvalues()
    info['atkinlehner'] = None
    if isinstance(alev, dict) and len(alev.keys()) > 0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if (level == 1):
        poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6', '')
        if poly != '':
            d, monom, coeffs = poly
            emf_logger.critical("poly={0}".format(poly))
            info['explicit_formulas'] = '\('
            for i in range(len(coeffs)):
                c = QQ(coeffs[i])
                s = ""
                if d > 1 and i > 0 and c > 0:
                    s = "+"
                if c < 0:
                    s = "-"
                if c.denominator() > 1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(
                        abs(c.numerator()), c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]
                b = monom[i][1]
                if a == 1:
                    a = ""
                if b == 1:
                    b = ""
                if a == 0 and b != 0:
                    s += "E_6^{{ {0} }}(z)".format(b)
                elif b == 0 and a != 0:
                    s += "E_4^{{ {0} }}(z)".format(a)
                else:
                    s += "E_4^{{ {0} }}(z) \cdot E_6^{{ {1} }}(z)".format(a, b)
                info['explicit_formulas'] += s
            info['explicit_formulas'] += " \)"
    # cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + '&label=' + str(label) # never used
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if (label_other != label):
                s = 'Modular form '
                if character:
                    s += newform_label(level, weight, character, label_other)
                else:
                    s += newform_label(level, weight, 1, label_other)

                url = url_for('emf.render_elliptic_modular_forms',
                              level=level,
                              weight=weight,
                              character=character,
                              label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s += newform_label(level, weight, character, label)
    else:
        s += newform_label(level, weight, 1, label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for('emf.render_elliptic_modular_forms',
                         level=level,
                         weight=weight,
                         character=character,
                         label=label)
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    info['properties2'] = properties2
    info['friends'] = friends
    info['max_cn'] = WNF.max_available_prec()
    return info
Exemplo n.º 29
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    emf_logger.debug("render_c_m_f_n_wp")
    info = to_dict(args)
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    character = my_get(info, 'character', 0, int)
    label = info.get('label', '')
    disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))

    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    if weight != 0:
        is_set['weight'] = True
    if level != 0:
        is_set['level'] = True
    if ('get_table' in info):  # we want a table
        info = set_table(info, is_set)
        page = "emf_table.html"
        title = "Table of spaces of elliptic modular forms"
        return render_template(page, info=info, title=title)
    ## This is the list of weights we initially put on the form
    weight = int(weight)
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    #  fun = dimension_new_cusp_forms
    #  title = 'Newforms'
    if is_set['weight']:
        wt_range = (weight, weight)
    else:
        if character == 0:
            wt_range = (2, 12)
        else:
            wt_range = (2, 12)
    if is_set['level']:
        level_range = (level, level)
    else:
        level_range = (1, 24)
    if character == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    info['show_switch'] = True
    disp.set_table_browsing(limit=[wt_range, level_range],
                            keys=['Weight', 'Level'],
                            character=character,
                            dimension_table=DimensionTable(info['grouptype']),
                            title='Browse Holomorphic Modular Forms',
                            check_db=True)
    info['browse_table'] = disp._table

    return render_template("emf_navigation.html",
                           info=info,
                           title=title,
                           bread=bread)
Exemplo n.º 30
0
def render_elliptic_modular_form_navigation_wp1(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    group = my_get(info, 'group', 1, int)
    if group == int(0):
      pass
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    if('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if isinstance(weight,int) and weight > 0:
        is_set['weight'] = True
        weight = int(weight)
    else:
       weight = None
       info.pop('weight',None)
    if isinstance(level,int) and level > 0:
        is_set['level'] = True
        level = int(level)
    else:
        level = None
        info.pop('level',None)
    ## This is the list of weights we initially put on the form
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page')),
             (title, url_for('.render_elliptic_modular_forms'))]

    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    # Special case: if the range reduces to a singleton for both level
    # and weight then we return a single page rather than a table:
    if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(limits_level[0], limits_weight[0])
    if is_set['weight']:
        limits_weight = (weight, weight)
    elif limits_weight is None:
        limits_weight = (2, 12) # default values
    if is_set['level']:
        limits_level = (level, level) 
    elif limits_level is None:
        limits_level = (1, 24) # default values
    try:
        group = info.get('group',0) # default group is gamma_0
        group = int(group)
    except ValueError: 
        group = 0
    if group not in [0,1]:
        group = 0
    if group == 0:
        info['grouptype'] = 0; info['groupother'] = 1
    else:
        info['grouptype'] = 1; info['groupother'] = 0
    emf_logger.debug("level:{0},level_range={1}".format(level,limits_level))
    emf_logger.debug("weight:{0},weight_range={1}".format(weight,limits_weight))

    if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]:
        return redirect(url_for("emf.render_elliptic_modular_forms",
          level=limits_level[0],weight=limits_weight[0],group=group), code=301)
    info['show_switch'] = True
    db = getDBConnection()['modularforms2']['webmodformspace_dimension']
    table = {}
    q = db.find_one({'group':'gamma{0}'.format(group)})
    if q:
        table = q.get('data',{})
    if table != {}:
        table = json.loads(table)
    info['table'] = {}
    level_range = range(limits_level[0],limits_level[1]+1)
    # we don't have weight 1 in database
    if limits_weight[0]==1:
        limits_weight=(2,limits_weight[1])
    weight_range = range(limits_weight[0],limits_weight[1]+1)
    #print "levels=",level_range
    #print "weights=",weight_range
    if len(weight_range)>1:
        info['weight_range']="{0}-{1}".format(limits_weight[0],limits_weight[1])
    if len(level_range)>1:
        info['level_range']="{0}-{1}".format(limits_level[0],limits_level[1])
    if group == 0:
        weight_range = filter(is_even,weight_range)
        for n in level_range:
            info['table'][n]={}
            sn = unicode(n)
            for k in weight_range:
                info['table'][n][k]={}
                sk = unicode(k)
                if table.has_key(sn):
                    if table[sn].has_key(sk):
                        info['table'][n][k] = table[sn][sk] #.get(str(n),{}).get(str(k),"n/a")
    else:
        emf_logger.debug("Set table for Gamma1")
        for n in level_range:
            info['table'][n]={}
            for k in weight_range:
                info['table'][n][k] = table.get(str(n),{}).get(str(k),{}).get(str(-1),"n/a")
    #print "table=\n",table
    #print "info=\n",info
    #info['table']=table
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html", info=info, title=title, bread=bread)
Exemplo n.º 31
0
def set_info_for_web_newform(level=None,
                             weight=None,
                             character=None,
                             label=None,
                             **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))
    try:
        WNF = WebNewForm_cached(level=level,
                                weight=weight,
                                character=character,
                                label=label)
        emf_logger.critical("defined webnewform for rendering!")
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError as e:
        WNF = None
        info['error'] = e.message
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms",
                   level=level,
                   weight=weight,
                   character=character)
    bread = [(EMF_TOP, url1)]
    bread.append(("of level %s" % level, url2))
    bread.append(("weight %s" % weight, url3))
    if int(character) == 0:
        bread.append(("trivial character", url4))
    else:
        bread.append(("\( %s \)" % (WNF.character.latex_name), url4))
    info['bread'] = bread

    properties2 = list()
    friends = list()
    space_url = url_for('emf.render_elliptic_modular_forms',
                        level=level,
                        weight=weight,
                        character=character)
    friends.append(
        ('\( S_{%s}(%s, %s)\)' %
         (WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if WNF.coefficient_field_label(check=True):
        friends.append(('Number field ' + WNF.coefficient_field_label(),
                        WNF.coefficient_field_url()))
    friends.append(
        ('Number field ' + WNF.base_field_label(), WNF.base_field_url()))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)",
                    WNF.character.url()))

    if WNF.dimension == 0:
        info['error'] = "This space is empty!"


#    emf_logger.debug("WNF={0}".format(WNF))

#info['name'] = name
    info['title'] = 'Modular Form ' + WNF.hecke_orbit_label

    if 'error' in info:
        return info
    # info['name']=WNF._name
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if WNF.coefficient_field.absolute_degree() == 1:
        rdeg = 1
    else:
        rdeg = WNF.coefficient_field.relative_degree()
    if cdeg == 1:
        info['satake'] = WNF.satake
    info['qexp'] = WNF.q_expansion_latex(prec=10, name='a')
    info['qexp_display'] = url_for(".get_qexp_latex",
                                   level=level,
                                   weight=weight,
                                   character=character,
                                   label=label)

    # info['qexp'] = WNF.q_expansion_latex(prec=prec)
    #c_pol_st = str(WNF.absolute_polynomial)
    #b_pol_st = str(WNF.polynomial(type='base_ring',format='str'))
    #b_pol_ltx = str(WNF.polynomial(type='base_ring',format='latex'))
    #print "c=",c_pol_ltx
    #print "b=",b_pol_ltx
    if cdeg > 1:  ## Field is QQ
        if bdeg > 1 and rdeg > 1:
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = latex(p1)
            lgc = p1.variables()[0]
            c_pol_ltx = c_pol_ltx.replace(lgc, 'a')
            z = p1.base_ring().gens()[0]
            p2 = z.minpoly()
            b_pol_ltx = latex(p2)
            b_pol_ltx = b_pol_ltx.replace(latex(p2.variables()[0]), latex(z))
            info['polynomial_st'] = 'where \({0}=0\) and \({1}=0\).'.format(
                c_pol_ltx, b_pol_ltx)
        else:
            c_pol_ltx = latex(WNF.coefficient_field.relative_polynomial())
            lgc = str(
                latex(WNF.coefficient_field.relative_polynomial().variables()
                      [0]))
            c_pol_ltx = c_pol_ltx.replace(lgc, 'a')
            info['polynomial_st'] = 'where \({0}=0\)'.format(c_pol_ltx)
    else:
        info['polynomial_st'] = ''
    info['degree'] = int(cdeg)
    if cdeg == 1:
        info['is_rational'] = 1
    else:
        info['is_rational'] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF._embeddings[
        'values']  #q_expansion_embeddings(prec, bprec,format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.twist_info
        if isinstance(info['twist_info'],
                      list) and len(info['twist_info']) > 0:
            info['is_minimal'] = info['twist_info'][0]
            if (info['twist_info'][0]):
                s = '- Is minimal<br>'
            else:
                s = '- Is a twist of lower level<br>'
            properties2 = [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 = [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key('tau') and len(CM['tau']) != 0:
            info['CM_values'] = CM
    info['is_cm'] = WNF.is_cm
    if WNF.is_cm is None:
        s = '- Unknown (insufficient data)<br>'
    elif WNF.is_cm is True:
        s = '- Is a CM-form<br>'
    else:
        s = '- Is not a CM-form<br>'
    properties2.append(('CM info', s))
    alev = WNF.atkin_lehner_eigenvalues()
    info['atkinlehner'] = None
    if isinstance(alev, dict) and len(alev.keys()) > 0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if (level == 1):
        poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6', '')
        if poly <> '':
            d, monom, coeffs = poly
            emf_logger.critical("poly={0}".format(poly))

            info['explicit_formulas'] = '\('
            for i in range(d):
                c = QQ(coeffs[i])
                s = ""
                if d > 1 and i > 0 and c > 0:
                    s = "+"
                if c < 0:
                    s = "-"
                if c.denominator() > 1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(
                        abs(c.numerator()), c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]
                b = monom[i][1]
                if a == 0 and b <> 0:
                    s += "E_6^{{ {0} }}".format(b)
                elif b == 0 and a <> 0:
                    s += "E_4^{{ {0} }}".format(a)
                else:
                    s += "E_4^{{ {0} }}E_6^{{ {1} }}".format(a, b)
                info['explicit_formulas'] += s
            info['explicit_formulas'] += " \)"
    cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \
        '&label=' + str(label)
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if (label_other != label):
                s = 'Modular form '
                if character:
                    s = s + str(level) + '.' + str(weight) + '.' + str(
                        character) + str(label_other)
                else:
                    s = s + str(level) + '.' + str(weight) + str(label_other)
                url = url_for('emf.render_elliptic_modular_forms',
                              level=level,
                              weight=weight,
                              character=character,
                              label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(
            label)
    else:
        s = s + str(level) + '.' + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for('emf.render_elliptic_modular_forms',
                         level=level,
                         weight=weight,
                         character=character,
                         label=label)
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    info['properties2'] = properties2
    info['friends'] = friends
    info['max_cn'] = WNF.max_cn()
    return info
Exemplo n.º 32
0
def render_elliptic_modular_forms(level=None, weight=None, character=None, label=None,group=None, **kwds):
    r"""
    Default input of same type as required. Note that for holomorphic modular forms: level=0 or weight=0 are non-existent.
    """
    emf_logger.debug(
        "In render: level={0},weight={1},character={2},group={3},label={4}".format(level, weight, character, group, label))
    emf_logger.debug("args={0}".format(request.args))
    emf_logger.debug("args={0}".format(request.form))
    emf_logger.debug("met={0}".format(request.method))
    keys = ['download', 'jump_to']
    info = get_args(request, level, weight, character, group, label, keys=keys)
    valid = validate_parameters(level,weight,character,label,info)
    if isinstance(valid,basestring):
        return redirect(valid,code=301)
    level = info['level']; weight = info['weight']; character = info['character']
    #if info.has_key('error'):
    #    return render_elliptic_modular_form_navigation_wp(error=info['error'])
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    group = info.get('group',None)
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    if group == 0:
        info['character'] = character = 1 # only trivial character for Gamma_0(N)
    try:
        if 'download' in info:
            return get_downloads(**info)
        emf_logger.debug("info=%s" % info)
        ## Consistency of arguments>
        # if level<=0:  level=None
        # if weight<=0:  weight=None
        if 'jump_to' in info:  # try to find out which form we want to jump
            s = my_get(info, 'jump_to', '', str)
            emf_logger.info("info.keys1={0}".format(info.keys()))
            info.pop('jump_to')
            emf_logger.info("info.keys2={0}".format(info.keys()))
            args = extract_data_from_jump_to(s)
            emf_logger.debug("args=%s" % args)
            return redirect(url_for("emf.render_elliptic_modular_forms", **args), code=301)
            # return render_elliptic_modular_forms(**args)
        emf_logger.debug("HERE! weight={0} level={1} char={2}".format(weight,level,character))
        if level > 0 and weight > 0 and character > 0:
            if label != '' and not label is None:
                return render_web_newform(**info)
            else:
                return render_web_modform_space(**info)
        if level > 0 and weight > 0 and (group != 0 or character == None):
            return render_web_modform_space_gamma1(**info)
        return render_elliptic_modular_form_navigation_wp(**info)
        # Otherwise we go to the main navigation page
    except IndexError as e: # catch everything here except KeyError below...
        emf_logger.debug("catching exceptions. info={0}".format(info))
        errst = str(e)
        ## Try to customise some of the error messages:
        if 'Character' and 'not exist' in errst:
            errst += " Please choose a character from the table below!"
            flash(errst,'error')
            return render_elliptic_modular_form_navigation_wp(**info)
        if 'WebNewForm_computing' in errst:
            errst = "The space {0}.{1}.{2} is not in the database!".format(level,weight,character)
            flash(errst)
        return render_elliptic_modular_form_navigation_wp()
    except KeyError as e:
        emf_logger.debug("catching exceptions. info={0}".format(info))
        errst = "The space {0}.{1}.{2} is not in the database!".format(level,weight,character)
        flash(errst)
        return render_elliptic_modular_form_navigation_wp()
Exemplo n.º 33
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    if weight != 0:
        is_set['weight'] = True
    if level != 0:
        is_set['level'] = True
    ## This is the list of weights we initially put on the form
    weight = int(weight)
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page')),
             (title, url_for('emf.render_elliptic_modular_forms'))]

    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if limits_weight[0] == limits_weight[1] and limits_level[0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(limits_level[0], limits_weight[0])
    if is_set['weight']:
        limits_weight = (weight, weight)
    else:
        if character == 1:
            limits_weight = (2, 12)
        else:
            limits_weight = (2, 12)
    if is_set['level']:
        limits_level = (level, level)
    else:
        limits_level = (1, 24)
    if character == 1:
        info['grouptype'] = 0; info['groupother'] = 1
    else:
        info['grouptype'] = 1; info['groupother'] = 0
    info['show_switch'] = True
    db = getDBConnection()['modularforms2']['webmodformspace_dimension']
    table = {}
    if character == 1:
        q = db.find_one({'group':'gamma0'})
        if q:
            table = q.get('data',{})
    else:
        q = db.find_one({'group':'gamma1'})
        if q:
            table = q.get('data',{})
    if table != {}:
        table = json.loads(table)
    info['table'] = {}
    
    level_range = range(limits_level[0],limits_level[1]+1)
    weight_range = range(limits_weight[0],limits_weight[1]+1)
    #print "levels=",level_range
    #print "weights=",weight_range
    if character == 1:
        weight_range = filter(is_even,weight_range)
        for n in level_range:
            info['table'][n]={}
            sn = unicode(n)
            for k in weight_range:
                info['table'][n][k]={}
                sk = unicode(k)
                if table.has_key(sn):
                    if table[sn].has_key(sk):
                        info['table'][n][k] = table[sn][sk] #.get(str(n),{}).get(str(k),"n/a")
    else:
        for n in level_range:
            info['table'][n]={}
            for k in weight_range:
                info['table'][n][k] = table.get(str(n),{}).get(str(k),"{}").get(str(character),"n/a")
    #print "table=\n",table
    #print "info=\n",info
    #info['table']=table
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html", info=info, title=title, bread=bread)
Exemplo n.º 34
0
def print_list_of_coefficients(info):
    r"""
    Print a table of Fourier coefficients in the requested format
    """
    level = my_get(info, 'level', -1, int)
    weight = my_get(info, 'weight', -1, int)
    prec = my_get(info, 'prec', 12, int)  # number of digits
    bitprec = my_get(info, 'bitprec', 12, int)  # number of digits                
    character = my_get(info, 'character', '', str)  # int(info.get('weight',0))
    fmt = info.get("format","q_expansion")
    if character == '':
        character = '1'
    label = info.get('label', '')
    if character.isalnum():
        character = int(character)
    else:
        return "The character '{0}' is not well-defined!".format(character)
    print "--------------"
    if label == '' or level == -1 or weight == -1:
        return "Need to specify a modular form completely!!"

    WMFS = WebModFormSpace(level= level, weight = weight, cuspidal=True,character = character)
    if not WMFS:
        return ""
    if('number' in info):
        number = int(info['number']) + 1
    else:
        number = max(WMFS.sturm_bound + 1, 20)
    FS = list()
    f  = WMFS.hecke_orbits.get(label)
    if f is not None:
        FS.append(f)
    else:
        for label in WMFS.hecke_orbits:
            FS.append(WMFS.f(label))
    shead = "Cusp forms of weight " + str(weight) + "on \(" + latex(WMFS.group) + "\)"
    s = ""
    if((character is not None) and (character > 0)):
        shead = shead + " and character \( \chi_{" + str(character) + "}\)"
        # s="<table><tr><td>"
    coefs = ""
    if fmt == "sage":
        res = []
    for F in FS:
        if number > F.max_cn():
            raise IndexError,"The database does not contain this many ({0}) coefficients for this modular form! We only have {1}".format(number,F.max_cn())
        if len(FS) > 1:
            if info['format'] == 'html':
                coefs += F.label()
            else:
                coefs += F.label()
        if fmt == "sage":
            qe = F.coefficients(range(number))
            res.append(qe)
        else:
            coefs += print_coefficients_for_one_form(F, number, info['format'],bitprec=bitprec)
    if not fmt == "sage":
        return s+"\n"+coefs
    else:
        if len(res)==1:
            res = res[0]
        #print "res=",res
        return dumps(res)
Exemplo n.º 35
0
def set_info_for_web_newform(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))    
    try:
        WNF = WebNewForm_cached(level=level, weight=weight, character=character, label=label)
        emf_logger.critical("defined webnewform for rendering!")
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError as e:
        WNF = None
        info['error'] = e.message
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight, character=character)
    bread = [(EMF_TOP, url1)]
    bread.append(("of level %s" % level, url2))
    bread.append(("weight %s" % weight, url3))
    if int(character) == 0:
        bread.append(("trivial character", url4))
    else:
        bread.append(("\( %s \)" % (WNF.character.latex_name), url4))
    info['bread'] = bread
    
    properties2 = list()
    friends = list()
    space_url = url_for('emf.render_elliptic_modular_forms',level=level, weight=weight, character=character)
    friends.append(('\( S_{%s}(%s, %s)\)'%(WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if hasattr(WNF.base_ring, "lmfdb_url") and WNF.base_ring.lmfdb_url:
        friends.append(('Number field ' + WNF.base_ring.lmfdb_pretty, WNF.base_ring.lmfdb_url))
    if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_label:
        friends.append(('Number field ' + WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_url))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)", WNF.character.url()))
    
    if WNF.dimension==0:
        info['error'] = "This space is empty!"

#    emf_logger.debug("WNF={0}".format(WNF))    

    #info['name'] = name
    info['title'] = 'Modular Form ' + WNF.hecke_orbit_label
    
    if 'error' in info:
        return info
    # info['name']=WNF._name
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if cdeg == 1:
        rdeg = 1
    else:
        rdeg = WNF.coefficient_field.relative_degree()
    cf_is_QQ = (cdeg == 1)
    br_is_QQ = (bdeg == 1)
    if cf_is_QQ:
        info['satake'] = WNF.satake
    info['qexp'] = WNF.q_expansion_latex(prec=10, name='\\alpha ')
    info['qexp_display'] = url_for(".get_qexp_latex", level=level, weight=weight, character=character, label=label)
    info['max_cn_qexp'] = WNF.q_expansion.prec()

    if not cf_is_QQ:
        if not br_is_QQ and rdeg>1: # not WNF.coefficient_field == WNF.base_ring:
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = web_latex_poly(p1, '\\alpha')  # make the variable \alpha
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            zeta = p1.base_ring().gens()[0]
#           p2 = zeta.minpoly() #this is not used anymore
#           b_pol_ltx = web_latex_poly(p2, latex(zeta)) #this is not used anymore
            z1 = zeta.multiplicative_order() 
            info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'),c_pol_ltx_x, z1]
            if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label]
            if z1==4:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\) and \(\zeta_4=i\).</div><br/>'.format(c_pol_ltx)
            elif z1<=2:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\).</div><br/>'.format(c_pol_ltx)
            else:
                info['polynomial_st'] = '<div class="where">where</div> %s\(\mathstrut=0\) and \(\zeta_{%s}=e^{\\frac{2\\pi i}{%s}}\).'%(c_pol_ltx, z1,z1)
        else:
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = web_latex_poly(p1, '\\alpha')
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            z1 = p1.base_ring().gens()[0].multiplicative_order()
            info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'), c_pol_ltx_x, z1]
            if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label]
            if z1==4:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\) and \(\zeta_4=i\).'.format(c_pol_ltx)
            elif z1<=2:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\).</div><br/>'.format(c_pol_ltx)
            else:
                info['polynomial_st'] = '<div class="where">where</div> %s\(\mathstrut=0\) and \(\zeta_{%s}=e^{\\frac{2\\pi i}{%s}}\).'%(c_pol_ltx, z1,z1)
    else:
        info['polynomial_st'] = ''
    info['degree'] = int(cdeg)
    if cdeg==1:
        info['is_rational'] = 1
        info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty ]
    else:
        info['is_rational'] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
        # bprec = 26
        # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
        # bprec = 26
        # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF._embeddings['values'] #q_expansion_embeddings(prec, bprec,format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.twist_info
        if isinstance(info['twist_info'], list) and len(info['twist_info'])>0:
            info['is_minimal'] = info['twist_info'][0]
            if(info['twist_info'][0]):
                s = 'Is minimal<br>'
            else:
                s = 'Is a twist of lower level<br>'
            properties2 = [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 = [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key('tau') and len(CM['tau']) != 0:
            info['CM_values'] = CM
    info['is_cm'] = WNF.is_cm
    if WNF.is_cm:
        info['cm_field'] = "2.0.{0}.1".format(-WNF.cm_disc)
        info['cm_disc'] = WNF.cm_disc
        info['cm_field_knowl'] = nf_display_knowl(info['cm_field'], getDBConnection(), field_pretty(info['cm_field']))
        info['cm_field_url'] = url_for("number_fields.by_label", label=info["cm_field"])
    if WNF.is_cm is None:
        s = '- Unknown (insufficient data)<br>'
    elif WNF.is_cm:
        s = 'Is a CM-form<br>'
    else:
        s = 'Is not a CM-form<br>'
    properties2.append(('CM info', s))
    alev = WNF.atkin_lehner_eigenvalues()
    info['atkinlehner'] = None
    if isinstance(alev,dict) and len(alev.keys())>0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps() 
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if(level == 1):
        poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6','')
        if poly != '':
            d,monom,coeffs = poly
            emf_logger.critical("poly={0}".format(poly))
            info['explicit_formulas'] = '\('
            for i in range(len(coeffs)):
                c = QQ(coeffs[i])
                s = ""
                if d>1 and i >0 and c>0:
                    s="+"
                if c<0:
                    s="-"
                if c.denominator()>1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(abs(c.numerator()),c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]; b = monom[i][1]
                if a == 0 and b != 0:
                    s+="E_6^{{ {0} }}".format(b)
                elif b ==0 and a != 0:
                    s+="E_4^{{ {0} }}".format(a)
                else:
                    s+="E_4^{{ {0} }}E_6^{{ {1} }}".format(a,b)
                info['explicit_formulas'] += s
            info['explicit_formulas'] += " \)"            
    cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \
        '&label=' + str(label)
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if(label_other != label):
                s = 'Modular form '
                if character:
                    s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(label_other)
                else:
                    s = s + str(level) + '.' + str(weight) + str(label_other)
                url = url_for('emf.render_elliptic_modular_forms', level=level,
                              weight=weight, character=character, label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(label)
    else:
        s = s + str(level) + '.' + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for(
        'emf.render_elliptic_modular_forms', level=level, weight=weight, character=character, label=label)
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    info['properties2'] = properties2
    info['friends'] = friends
    info['max_cn'] = WNF.max_cn()
    return info
Exemplo n.º 36
0
def set_info_for_web_newform(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info["level"] = level
    info["weight"] = weight
    info["character"] = character
    info["label"] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, "prec", default_prec, int)
    bprec = my_get(info, "bprec", default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))
    try:
        WNF = WebNewForm_cached(level=level, weight=weight, character=character, label=label)
        emf_logger.critical("defined webnewform for rendering!")
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError as e:
        WNF = None
        info["error"] = e.message
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight, character=character)
    bread = [(EMF_TOP, url1)]
    bread.append(("of level %s" % level, url2))
    bread.append(("weight %s" % weight, url3))
    if int(character) == 0:
        bread.append(("trivial character", url4))
    else:
        bread.append(("\( %s \)" % (WNF.character.latex_name), url4))
    info["bread"] = bread

    properties2 = list()
    friends = list()
    space_url = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight, character=character)
    friends.append(("\( S_{%s}(%s, %s)\)" % (WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if WNF.coefficient_field_label(check=True):
        friends.append(("Number field " + WNF.coefficient_field_label(), WNF.coefficient_field_url()))
    friends.append(("Number field " + WNF.base_field_label(), WNF.base_field_url()))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)", WNF.character.url()))

    if WNF.dimension == 0:
        info["error"] = "This space is empty!"

    #    emf_logger.debug("WNF={0}".format(WNF))

    # info['name'] = name
    info["title"] = "Modular Form " + WNF.hecke_orbit_label

    if "error" in info:
        return info
    # info['name']=WNF._name
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if WNF.coefficient_field.absolute_degree() == 1:
        rdeg = 1
    else:
        rdeg = WNF.coefficient_field.relative_degree()
    if cdeg == 1:
        info["satake"] = WNF.satake
    info["qexp"] = WNF.q_expansion_latex(prec=10, name="a")
    info["qexp_display"] = url_for(".get_qexp_latex", level=level, weight=weight, character=character, label=label)

    # info['qexp'] = WNF.q_expansion_latex(prec=prec)
    # c_pol_st = str(WNF.absolute_polynomial)
    # b_pol_st = str(WNF.polynomial(type='base_ring',format='str'))
    # b_pol_ltx = str(WNF.polynomial(type='base_ring',format='latex'))
    # print "c=",c_pol_ltx
    # print "b=",b_pol_ltx
    if cdeg > 1:  ## Field is QQ
        if bdeg > 1 and rdeg > 1:
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = latex(p1)
            lgc = p1.variables()[0]
            c_pol_ltx = c_pol_ltx.replace(lgc, "a")
            z = p1.base_ring().gens()[0]
            p2 = z.minpoly()
            b_pol_ltx = latex(p2)
            b_pol_ltx = b_pol_ltx.replace(latex(p2.variables()[0]), latex(z))
            info["polynomial_st"] = "where \({0}=0\) and \({1}=0\).".format(c_pol_ltx, b_pol_ltx)
        else:
            c_pol_ltx = latex(WNF.coefficient_field.relative_polynomial())
            lgc = str(latex(WNF.coefficient_field.relative_polynomial().variables()[0]))
            c_pol_ltx = c_pol_ltx.replace(lgc, "a")
            info["polynomial_st"] = "where \({0}=0\)".format(c_pol_ltx)
    else:
        info["polynomial_st"] = ""
    info["degree"] = int(cdeg)
    if cdeg == 1:
        info["is_rational"] = 1
    else:
        info["is_rational"] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    emf_logger.debug("PREC2: {0}".format(prec))
    info["embeddings"] = WNF._embeddings["values"]  # q_expansion_embeddings(prec, bprec,format='latex')
    info["embeddings_len"] = len(info["embeddings"])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info["twist_info"] = WNF.twist_info
        if isinstance(info["twist_info"], list) and len(info["twist_info"]) > 0:
            info["is_minimal"] = info["twist_info"][0]
            if info["twist_info"][0]:
                s = "- Is minimal<br>"
            else:
                s = "- Is a twist of lower level<br>"
            properties2 = [("Twist info", s)]
    else:
        info["twist_info"] = "Twist info currently not available."
        properties2 = [("Twist info", "not available")]
    args = list()
    for x in range(5, 200, 10):
        args.append({"digits": x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key("tau") and len(CM["tau"]) != 0:
            info["CM_values"] = CM
    info["is_cm"] = WNF.is_cm
    if WNF.is_cm is None:
        s = "- Unknown (insufficient data)<br>"
    elif WNF.is_cm is True:
        s = "- Is a CM-form<br>"
    else:
        s = "- Is not a CM-form<br>"
    properties2.append(("CM info", s))
    alev = WNF.atkin_lehner_eigenvalues()
    info["atkinlehner"] = None
    if isinstance(alev, dict) and len(alev.keys()) > 0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if level == 1:
        poly = WNF.explicit_formulas.get("as_polynomial_in_E4_and_E6", "")
        if poly != "":
            d, monom, coeffs = poly
            emf_logger.critical("poly={0}".format(poly))

            info["explicit_formulas"] = "\("
            for i in range(d):
                c = QQ(coeffs[i])
                s = ""
                if d > 1 and i > 0 and c > 0:
                    s = "+"
                if c < 0:
                    s = "-"
                if c.denominator() > 1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(abs(c.numerator()), c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]
                b = monom[i][1]
                if a == 0 and b != 0:
                    s += "E_6^{{ {0} }}".format(b)
                elif b == 0 and a != 0:
                    s += "E_4^{{ {0} }}".format(a)
                else:
                    s += "E_4^{{ {0} }}E_6^{{ {1} }}".format(a, b)
                info["explicit_formulas"] += s
            info["explicit_formulas"] += " \)"
    cur_url = (
        "?&level=" + str(level) + "&weight=" + str(weight) + "&character=" + str(character) + "&label=" + str(label)
    )
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if label_other != label:
                s = "Modular form "
                if character:
                    s = s + str(level) + "." + str(weight) + "." + str(character) + str(label_other)
                else:
                    s = s + str(level) + "." + str(weight) + str(label_other)
                url = url_for(
                    "emf.render_elliptic_modular_forms",
                    level=level,
                    weight=weight,
                    character=character,
                    label=label_other,
                )
                friends.append((s, url))

    s = "L-Function "
    if character:
        s = s + str(level) + "." + str(weight) + "." + str(character) + str(label)
    else:
        s = s + str(level) + "." + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = "/L" + url_for(
        "emf.render_elliptic_modular_forms", level=level, weight=weight, character=character, label=label
    )
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + "." + label
        s = "Elliptic curve isogeny class " + llabel
        url = "/EllipticCurve/Q/" + llabel
        friends.append((s, url))
    info["properties2"] = properties2
    info["friends"] = friends
    info["max_cn"] = WNF.max_cn()
    return info
Exemplo n.º 37
0
def set_info_for_one_modular_form(level=None,
                                  weight=None,
                                  character=None,
                                  label=None,
                                  **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(
            level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))
    try:
        WNF = WebNewForm(N=level,
                         k=weight,
                         chi=character,
                         label=label,
                         verbose=1)
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError as e:
        WNF = None
        info['error'] = e.message
    properties2 = list()
    parents = list()
    siblings = list()
    friends = list()
    if hasattr(WNF, "dimension") and WNF.dimension() == 0:
        info['error'] = "This space is empty!"

#    emf_logger.debug("WNF={0}".format(WNF))
    name = "Cuspidal newform %s of weight %s for " % (label, weight)
    if level == 1:
        name += "\(\mathrm{SL}_{2}(\mathbb{Z})\)"
    else:
        name += "\(\Gamma_0(%s)\)" % (level)
    if int(character) != 0 and hasattr(WNF, "conrey_character"):
        conrey_char = WNF.conrey_character()
        conrey_char_name = WNF.conrey_character_name()
        name += " with character \(%s\)" % (conrey_char_name)
    else:
        name += " with trivial character"
    info['name'] = name
    info['title'] = 'Modular Form ' + info['name']
    if 'error' in info:
        return info
    # info['name']=WNF._name
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....
    if WNF.degree() == 1:
        info['satake'] = WNF.satake_parameters(prec, bprec)

# br = 60
# info['qexp'] =
# ajax_more(WNF.print_q_expansion,{'prec':5,'br':br},{'prec':10,'br':br},{'prec':20,'br':br},{'prec':100,'br':br},{'prec':200,'br':br})
#K = WNF.base_ring()
#L = WNF.coefficient_field()
    info['qexp'] = WNF.print_q_expansion(prec=prec, br=120)
    # c = list(WNF.q_expansion(prec))
    # c = map(lambda x: str(x).replace("*",""), c)
    # info['c'] = map(lambda x: x.replace(, c)
    # emf_logger.debug("c={0}".format(info['c']))
    # info['maxc']=len(c)
    # emf_logger.debug("maxc={0}".format(info['maxc']))
    c_pol_st = str(WNF.polynomial(type='coefficient_field', format='str'))
    b_pol_st = str(WNF.polynomial(type='base_ring', format='str'))
    c_pol_ltx = str(WNF.polynomial(type='coefficient_field', format='latex'))
    b_pol_ltx = str(WNF.polynomial(type='base_ring', format='latex'))
    #print "c=",c_pol_ltx
    #print "b=",b_pol_ltx
    if c_pol_st <> 'x':  ## Field is QQ
        if b_pol_st <> 'x' and WNF.relative_degree() > 1:
            info['polynomial_st'] = 'where \({0}=0\) and \({1}=0\).'.format(
                c_pol_ltx, b_pol_ltx)
        else:
            info['polynomial_st'] = 'where \({0}=0\).'.format(c_pol_ltx)
    else:
        info['polynomial_st'] = ''
    info['degree'] = int(WNF.degree())
    if WNF.degree() == 1:
        info['is_rational'] = 1
    else:
        info['is_rational'] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
    # bprec = 26
    # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF.q_expansion_embeddings(prec,
                                                    bprec,
                                                    format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.print_twist_info()
        info['is_minimal'] = info['twist_info'][0]
        if (info['twist_info'][0]):
            s = '- Is minimal<br>'
        else:
            s = '- Is a twist of lower level<br>'
        properties2 = [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 = [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    digits = 7
    alev = None
    if level < N_max_extra_comp:
        info['is_cm'] = WNF.is_CM()
        info['CM'] = WNF.print_is_CM()
        info['CM_values'] = WNF.cm_values(digits=digits)
        if len(info['CM_values']['tau']) == 0:
            info.pop('CM_values')
        if (WNF.is_CM()[0]) == None:
            s = '- Unknown (insufficient data)<br>'
        elif (WNF.is_CM()[0]):
            s = '- Is a CM-form<br>'
        else:
            s = '- Is not a CM-form<br>'
        properties2.append(('CM info', s))
        alev = WNF.atkin_lehner_eigenvalues()
        if len(alev.keys()) > 0:
            s1 = " Atkin-Lehner eigenvalues "
            s2 = ""
            for Q in alev.keys():
                s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
            properties2.append((s1, s2))
        # properties.append(s)
        emf_logger.debug("properties={0}".format(properties2))
    else:
        properties2.append(("CM info", "not available"))
        if level != 1:
            properties2.append(("Atkin-Lehner eigenvalues", "not available"))
    info['atkinlehner'] = None
    if alev and level != 1:
        alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        info['atkinlehner'] = list()
        # info['atkin_lehner_cusps']=list()
        for c in alev.keys():
            if (c == Cusp(Infinity)):
                continue
            s = "\(" + latex(c) + "\)"
            Q = alev[c][0]
            ev = alev[c][1]
            info['atkinlehner'].append([Q, c, ev])
    if (level == 1):
        info['explicit_formulas'] = WNF.print_as_polynomial_in_E4_and_E6()
    cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \
        '&label=' + str(label)
    if (len(WNF.parent().galois_decomposition()) > 1):
        for label_other in WNF.parent()._galois_orbits_labels:
            if (label_other != label):
                s = 'Modular form '
                if character:
                    s = s + str(level) + '.' + str(weight) + '.' + str(
                        character) + str(label_other)
                else:
                    s = s + str(level) + '.' + str(weight) + str(label_other)
                url = url_for('emf.render_elliptic_modular_forms',
                              level=level,
                              weight=weight,
                              character=character,
                              label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(
            label)
    else:
        s = s + str(level) + '.' + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for('emf.render_elliptic_modular_forms',
                         level=level,
                         weight=weight,
                         character=character,
                         label=label)
    if WNF.degree() > 1:
        for h in range(WNF.degree()):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight() == 2 and WNF.degree() == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    space_url = '?&level=' + str(level) + '&weight=' + str(
        weight) + '&character=' + str(character)
    parents.append(
        ('\( S_{k} (\Gamma_0(' + str(level) + '),\chi )\)', space_url))
    info['properties2'] = properties2
    info['parents'] = parents
    info['siblings'] = siblings
    info['friends'] = friends
    info['max_cn'] = WNF.max_cn()
    return info
Exemplo n.º 38
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    emf_logger.debug("render_c_m_f_n_wp")
    info = to_dict(args)
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    character = my_get(info, 'character', 0, int)
    label = info.get('label', '')
    disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))

    if('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    if weight != 0:
        is_set['weight'] = True
    if level != 0:
        is_set['level'] = True
    if('get_table' in info):  # we want a table
        info = set_table(info, is_set)
        page = "emf_table.html"
        title = "Table of spaces of elliptic modular forms"
        return render_template(page, info=info, title=title)
    ## This is the list of weights we initially put on the form
    weight = int(weight)
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    #  fun = dimension_new_cusp_forms
    #  title = 'Newforms'
    if is_set['weight']:
        wt_range = (weight, weight)
    else:
        if character == 0:
            wt_range = (2, 12)
        else:
            wt_range = (2, 12)
    if is_set['level']:
        level_range = (level, level)
    else:
        level_range = (1, 24)
    if character == 0:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    info['show_switch'] = True
    disp.set_table_browsing(limit=[wt_range, level_range],
                            keys=['Weight', 'Level'], character=character,
                            dimension_table=DimensionTable(info['grouptype']), title='Browse Holomorphic Modular Forms', check_db=True)
    info['browse_table'] = disp._table

    return render_template("emf_navigation.html", info=info, title=title, bread=bread)
Exemplo n.º 39
0
def render_elliptic_modular_form_navigation_wp(**args):
    r"""
    Renders the webpage for the navigational page.

    """
    from sage.all import is_even
    info = to_dict(args)
    args = to_dict(request.args)
    info.update(args)
    form = to_dict(request.form)
    info.update(form)
    emf_logger.debug("render_c_m_f_n_wp info={0}".format(info))
    level = my_get(info, 'level', 0, int)
    weight = my_get(info, 'weight', 0, int)
    character = my_get(info, 'character', 1, int)
    label = info.get('label', '')
    #disp = ClassicalMFDisplay('modularforms2')
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    emf_logger.debug("character=%s, %s" % (character, type(character)))
    if ('plot' in info and level is not None):
        return render_fd_plot(level, info)
    is_set = dict()
    is_set['weight'] = False
    is_set['level'] = False
    if weight != 0:
        is_set['weight'] = True
    if level != 0:
        is_set['level'] = True
    ## This is the list of weights we initially put on the form
    weight = int(weight)
    title = "Holomorphic Cusp Forms"
    bread = [(MF_TOP, url_for('mf.modular_form_main_page'))]
    limits_weight = extract_limits_as_tuple(info, 'weight')
    limits_level = extract_limits_as_tuple(info, 'level')
    if limits_weight[0] == limits_weight[1] and limits_level[
            0] == limits_level[1]:
        return render_elliptic_modular_form_space_list_chars(
            limits_level[0], limits_weight[0])
    if is_set['weight']:
        limits_weight = (weight, weight)
    else:
        if character == 1:
            limits_weight = (2, 12)
        else:
            limits_weight = (2, 12)
    if is_set['level']:
        limits_level = (level, level)
    else:
        limits_level = (1, 24)
    if character == 1:
        info['grouptype'] = 0
        info['groupother'] = 1
    else:
        info['grouptype'] = 1
        info['groupother'] = 0
    info['show_switch'] = True
    db = getDBConnection()['modularforms2']['webmodformspace_dimension']
    table = {}
    if character == 1:
        q = db.find_one({'group': 'gamma0'})
        if q:
            table = q.get('data', {})
    else:
        q = db.find_one({'group': 'gamma1'})
        if q:
            table = q.get('data', {})
    if table <> {}:
        table = json.loads(table)
    info['table'] = {}

    level_range = range(limits_level[0], limits_level[1] + 1)
    weight_range = range(limits_weight[0], limits_weight[1] + 1)
    #print "levels=",level_range
    #print "weights=",weight_range
    if character == 1:
        weight_range = filter(is_even, weight_range)
        for n in level_range:
            info['table'][n] = {}
            sn = unicode(n)
            for k in weight_range:
                info['table'][n][k] = {}
                sk = unicode(k)
                if table.has_key(sn):
                    if table[sn].has_key(sk):
                        info['table'][n][k] = table[sn][
                            sk]  #.get(str(n),{}).get(str(k),"n/a")
    else:
        for n in level_range:
            info['table'][n] = {}
            for k in weight_range:
                info['table'][n][k] = table.get(str(n),
                                                {}).get(str(k), "{}").get(
                                                    str(character), "n/a")
    #print "table=\n",table
    #print "info=\n",info
    #info['table']=table
    info['col_heads'] = level_range
    info['row_heads'] = weight_range
    return render_template("emf_browse_spaces.html",
                           info=info,
                           title=title,
                           bread=bread)
Exemplo n.º 40
0
def render_elliptic_modular_forms(level=None,
                                  weight=None,
                                  character=None,
                                  label=None,
                                  group=None,
                                  **kwds):
    r"""
    Default input of same type as required. Note that for holomorphic modular forms: level=0 or weight=0 are non-existent.
    """
    emf_logger.debug(
        "In render: level={0},weight={1},character={2},group={3},label={4}".
        format(level, weight, character, group, label))
    emf_logger.debug("args={0}".format(request.args))
    emf_logger.debug("args={0}".format(request.form))
    emf_logger.debug("met={0}".format(request.method))
    keys = ['download', 'jump_to']
    info = get_args(request, level, weight, character, group, label, keys=keys)
    valid = validate_parameters(level, weight, character, label, info)
    if isinstance(valid, basestring):
        return redirect(valid, code=301)
    level = info['level']
    weight = info['weight']
    character = info['character']
    #if info.has_key('error'):
    #    return render_elliptic_modular_form_navigation_wp(error=info['error'])
    emf_logger.debug("info={0}".format(info))
    emf_logger.debug("level=%s, %s" % (level, type(level)))
    emf_logger.debug("label=%s, %s" % (label, type(label)))
    emf_logger.debug("wt=%s, %s" % (weight, type(weight)))
    group = info.get('group', None)
    emf_logger.debug("group=%s, %s" % (group, type(group)))
    if group == 0:
        info[
            'character'] = character = 1  # only trivial character for Gamma_0(N)
    try:
        if 'download' in info:
            return get_downloads(**info)
        emf_logger.debug("info=%s" % info)
        ## Consistency of arguments>
        # if level<=0:  level=None
        # if weight<=0:  weight=None
        if 'jump_to' in info:  # try to find out which form we want to jump
            s = my_get(info, 'jump_to', '', str)
            emf_logger.info("info.keys1={0}".format(info.keys()))
            info.pop('jump_to')
            emf_logger.info("info.keys2={0}".format(info.keys()))
            args = extract_data_from_jump_to(s)
            emf_logger.debug("args=%s" % args)
            return redirect(url_for("emf.render_elliptic_modular_forms",
                                    **args),
                            code=301)
            # return render_elliptic_modular_forms(**args)
        emf_logger.debug("HERE! weight={0} level={1} char={2}".format(
            weight, level, character))
        if level > 0 and weight > 0 and character > 0:
            if label != '' and not label is None:
                return render_web_newform(**info)
            else:
                return render_web_modform_space(**info)
        if level > 0 and weight > 0 and (group != 0 or character == None):
            return render_web_modform_space_gamma1(**info)
        return render_elliptic_modular_form_navigation_wp(**info)
        # Otherwise we go to the main navigation page
    except IndexError as e:  # catch everything here except KeyError below...
        emf_logger.debug("catching exceptions. info={0} e={1}".format(info, e))
        errst = str(e)
        ## Try to customise some of the error messages:
        if 'Character' and 'not exist' in errst:
            errst += " Please choose a character from the table below!"
            flash(errst, 'error')
            return render_elliptic_modular_form_navigation_wp(**info)
        if 'WebNewForm_computing' in errst:
            errst = "The space {0}.{1}.{2} is not in the database!".format(
                level, weight, character)
            flash(errst)
        return render_elliptic_modular_form_navigation_wp()
    except KeyError as e:
        emf_logger.debug("catching exceptions. info={0} e={1}".format(info, e))
        errst = "The orbit {0} is not in the database!".format(
            newform_label(level, weight, character, label))
        flash(errst)
        return render_elliptic_modular_form_navigation_wp()
Exemplo n.º 41
0
def set_info_for_one_modular_form(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'prec', default_bprec, int)
    try:
        WNF = WebNewForm(weight, level, character, label, verbose=1)
        # if info.has_key('download') and info.has_key('tempfile'):
        #     WNF._save_to_file(info['tempfile'])
        #     info['filename']=str(weight)+'-'+str(level)+'-'+str(character)+'-'+label+'.sobj'
        #     return info
    except IndexError:
        WNF = None
        emf_logger.debug("Could not compute the desired function!")
        emf_logger.debug("{0},{1},{2}".format(level,weight,character))
        print level, weight, character, label
        info['error'] = "Could not compute the desired function!"
    properties2 = list()
    parents = list()
    siblings = list()
    friends = list()
    if WNF is None or WNF._f is None:
        info['error'] = "This space is empty!"
    emf_logger.debug("WNF={0}".format(WNF))    
    name = "Cuspidal newform %s of weight %s for " % (label, weight)
    if level == 1:
        name += "\(\mathrm{SL}_{2}(\mathbb{Z})\)"
    else:
        name += "\(\Gamma_0(%s)\)" % (level)
    if int(character) != 0 and hasattr(WNF,"conrey_character"):
        conrey_char = WNF.conrey_character()
        conrey_char_name = WNF.conrey_character_name()
        name += " with character \(%s\)" % (conrey_char_name)
    else:
        name += " with trivial character"
    info['name'] = name
    info['title'] = 'Modular Form ' + info['name']
    if 'error' in info:
        return info
    # info['name']=WNF._name
    info['satake'] = WNF.satake_parameters(prec, bprec)
    
    # br = 60
    # info['qexp'] =
    # ajax_more(WNF.print_q_expansion,{'prec':5,'br':br},{'prec':10,'br':br},{'prec':20,'br':br},{'prec':100,'br':br},{'prec':200,'br':br})
    K = WNF.base_ring()
    info['qexp'] = WNF.print_q_expansion(prec, 120)
    # c = list(WNF.q_expansion(prec))
    # c = map(lambda x: str(x).replace("*",""), c)
    # info['c'] = map(lambda x: x.replace(, c)
    # emf_logger.debug("c={0}".format(info['c']))
    # info['maxc']=len(c)
    # emf_logger.debug("maxc={0}".format(info['maxc']))
    info['polynomial'] = str(WNF.polynomial()).replace('x', str(latex(K.gen())))
    if(K != QQ):
        info['polynomial_st'] = 'where ' + r'\(' + info['polynomial'] + r'=0\)'
    else:
        info['polynomial_st'] = ''

    info['degree'] = int(WNF.degree())
    if K == QQ:
        info['is_rational'] = 1
    else:
        info['is_rational'] = 0
    # info['q_exp_embeddings'] = WNF.print_q_expansion_embeddings()
    # if(int(info['degree'])>1 and WNF.dimension()>1):
    #    s = 'One can embed it into \( \mathbb{C} \) as:'
        # bprec = 26
        # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # elif(int(info['degree'])>1):
    #    s = 'There are '+str(info['degree'])+' embeddings into \( \mathbb{C} \):'
        # bprec = 26
        # print s
    #    info['embeddings'] =  ajax_more2(WNF.print_q_expansion_embeddings,{'prec':[5,10,25,50],'bprec':[26,53,106]},text=['more coeffs.','higher precision'])
    # else:
    #    info['embeddings'] = ''
    info['embeddings'] = WNF.q_expansion_embeddings(prec, bprec)
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = []
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.print_twist_info()
        info['is_minimal'] = info['twist_info'][0]
        if(info['twist_info'][0]):
            s = '- Is minimal<br>'
        else:
            s = '- Is a twist of lower level<br>'
        properties2 = [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 = [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    digits = 7
    alev = None
    if level < N_max_extra_comp:
        info['is_cm'] = WNF.is_CM()
        info['CM'] = WNF.print_is_CM()
        info['CM_values'] = WNF.cm_values(digits=digits)
        if(WNF.is_CM()[0]):
            s = '- Is a CM-form<br>'
        else:
            s = '- Is not a CM-form<br>'
        properties2.append(('CM info', s))
        alev = WNF.atkin_lehner_eigenvalues()
        if len(alev.keys()) > 0:
            s1 = " Atkin-Lehner eigenvalues "
            s2 = ""
            for Q in alev.keys():
                s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
            properties2.append((s1, s2))
        # properties.append(s)
        emf_logger.debug("properties={0}".format(properties2))
    else:
        properties2.append(("CM info", "not available"))
        if level != 1:
            properties2.append(("Atkin-Lehner eigenvalues", "not available"))
    info['atkinlehner'] = None
    if alev and level != 1:
        alev = WNF.atkin_lehner_eigenvalues_for_all_cusps()
        info['atkinlehner'] = list()
        # info['atkin_lehner_cusps']=list()
        for c in alev.keys():
            if(c == Cusp(Infinity)):
                continue
            s = "\(" + latex(c) + "\)"
            Q = alev[c][0]
            ev = alev[c][1]
            info['atkinlehner'].append([Q, c, ev])
    if(level == 1):
        info['explicit_formulas'] = WNF.print_as_polynomial_in_E4_and_E6()
    cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + \
        '&label=' + str(label)
    if(len(WNF.parent().galois_decomposition()) > 1):
        for label_other in WNF.parent()._galois_orbits_labels:
            if(label_other != label):
                s = 'Modular form '
                if character:
                    s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(label_other)
                else:
                    s = s + str(level) + '.' + str(weight) + str(label_other)
                url = url_for('emf.render_elliptic_modular_forms', level=level,
                              weight=weight, character=character, label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s = s + str(level) + '.' + str(weight) + '.' + str(character) + str(label)
    else:
        s = s + str(level) + '.' + str(weight) + str(label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for(
        'emf.render_elliptic_modular_forms', level=level, weight=weight, character=character, label=label)
    if WNF.degree() > 1:
        for h in range(WNF.degree()):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight() == 2 and WNF.degree() == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    space_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character)
    parents.append(('\( S_{k} (\Gamma_0(' + str(level) + '),\chi )\)', space_url))
    info['properties2'] = properties2
    info['parents'] = parents
    info['siblings'] = siblings
    info['friends'] = friends

    return info
Exemplo n.º 42
0
def set_info_for_web_newform(level=None, weight=None, character=None, label=None, **kwds):
    r"""
    Set the info for on modular form.

    """
    info = to_dict(kwds)
    info['level'] = level
    info['weight'] = weight
    info['character'] = character
    info['label'] = label
    if level is None or weight is None or character is None or label is None:
        s = "In set info for one form but do not have enough args!"
        s += "level={0},weight={1},character={2},label={3}".format(level, weight, character, label)
        emf_logger.critical(s)
    emf_logger.debug("In set_info_for_one_mf: info={0}".format(info))
    prec = my_get(info, 'prec', default_prec, int)
    bprec = my_get(info, 'bprec', default_display_bprec, int)
    emf_logger.debug("PREC: {0}".format(prec))
    emf_logger.debug("BITPREC: {0}".format(bprec))    
    try:
        WNF = WebNewForm_cached(level=level, weight=weight, character=character, label=label)
        if not WNF.has_updated():
            raise IndexError("Unfortunately, we do not have this newform in the database.")
        info['character_order'] = WNF.character.order
        info['code'] = WNF.code
        emf_logger.debug("defined webnewform for rendering!")
    except IndexError as e:
        info['error'] = e.message
    url0 = url_for("mf.modular_form_main_page")
    url1 = url_for("emf.render_elliptic_modular_forms")
    url2 = url_for("emf.render_elliptic_modular_forms", level=level)
    url3 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight)
    url4 = url_for("emf.render_elliptic_modular_forms", level=level, weight=weight, character=character)
    bread = [(MF_TOP, url0), (EMF_TOP, url1)]
    bread.append(("Level %s" % level, url2))
    bread.append(("Weight %s" % weight, url3))
    bread.append(("Character \( %s \)" % (WNF.character.latex_name), url4))
    bread.append(("Newform %d.%d.%d.%s" % (level, weight, int(character), label),''))
    info['bread'] = bread
    
    properties2 = list()
    friends = list()
    space_url = url_for('emf.render_elliptic_modular_forms',level=level, weight=weight, character=character)
    friends.append(('\( S_{%s}(%s, %s)\)'%(WNF.weight, WNF.level, WNF.character.latex_name), space_url))
    if hasattr(WNF.base_ring, "lmfdb_url") and WNF.base_ring.lmfdb_url:
        friends.append(('Number field ' + WNF.base_ring.lmfdb_pretty, WNF.base_ring.lmfdb_url))
    if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_label:
        friends.append(('Number field ' + WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_url))
    friends = uniq(friends)
    friends.append(("Dirichlet character \(" + WNF.character.latex_name + "\)", WNF.character.url()))
    
    if WNF.dimension==0 and not info.has_key('error'):
        info['error'] = "This space is empty!"
    info['title'] = 'Newform ' + WNF.hecke_orbit_label
    info['learnmore'] = [('History of modular forms', url_for('.holomorphic_mf_history'))]    
    if 'error' in info:
        return info
    ## Until we have figured out how to do the embeddings correctly we don't display the Satake
    ## parameters for non-trivial characters....

    ## Example to illustrate the different cases
    ## base              = CyclotomicField(n) -- of degree phi(n) 
    ## coefficient_field = NumberField( p(x)) for some p in base['x'] of degree m
    ##   we would then have cdeg = m*phi(n) and bdeg = phi(n)
    ##   and rdeg = m
    ## Unfortunately, for e.g. base = coefficient_field = CyclotomicField(6)
    ## we get coefficient_field.relative_degree() == 2 although it should be 1
    cdeg = WNF.coefficient_field.absolute_degree()
    bdeg = WNF.base_ring.absolute_degree()
    if cdeg == 1:
        rdeg = 1
    else:
        ## just setting rdeg = WNF.coefficient_field.relative_degree() does not give correct result...
        ## 
        rdeg = QQ(cdeg)/QQ(bdeg)
    cf_is_QQ = (cdeg == 1)
    br_is_QQ = (bdeg == 1)
    if cf_is_QQ:
        info['satake'] = WNF.satake
    if WNF.complexity_of_first_nonvanishing_coefficients() > default_max_height:
        info['qexp'] = ""
        info['qexp_display'] = ''
        info['hide_qexp'] = True
        n,c = WNF.first_nonvanishing_coefficient()
        info['trace_nv'] = latex(WNF.first_nonvanishing_coefficient_trace())
        info['norm_nv'] = '\\approx ' + latex(WNF.first_nonvanishing_coefficient_norm().n())
        info['index_nv'] = n
    else:
        if WNF.prec < prec:
            #get WNF record at larger prec
            WNF.prec = prec
            WNF.update_from_db()
        info['qexp'] = WNF.q_expansion_latex(prec=10, name='\\alpha ')
        info['qexp_display'] = url_for(".get_qexp_latex", level=level, weight=weight, character=character, label=label)
        info["hide_qexp"] = False
    info['max_cn_qexp'] = WNF.q_expansion.prec()
    ## All combinations should be tested...
    ## 13/4/4/a -> base ring = coefficient_field = QQ(zeta_6)
    ## 13/3/8/a ->  base_ring = QQ(zeta_4), coefficient_field has poly x^2+(2\zeta_4+2x-3\zeta_$ over base_ring
    ## 13/4/3/a ->  base_ring = coefficient_field = QQ(zeta_3) 
    ## 13/4/1/a -> all rational
    ## 13/6/1/a/ -> base_ring = QQ, coefficient_field = Q(sqrt(17))
    ## These are variables which needs to be set properly below
    info['polvars'] = {'base_ring':'x','coefficient_field':'\\alpha'}
    if not cf_is_QQ:
        if rdeg>1: # not WNF.coefficient_field == WNF.base_ring:
            ## Here WNF.base_ring should be some cyclotomic field and we have an extension over this.
            p1 = WNF.coefficient_field.relative_polynomial()
            c_pol_ltx = web_latex_poly(p1, '\\alpha')  # make the variable \alpha
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            zeta = p1.base_ring().gens()[0]
#           p2 = zeta.minpoly() #this is not used anymore
#           b_pol_ltx = web_latex_poly(p2, latex(zeta)) #this is not used anymore
            z1 = zeta.multiplicative_order() 
            info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'),c_pol_ltx_x, z1]
            if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label]
            if z1==4:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\) and \(\zeta_4=i\).</div><br/>'.format(c_pol_ltx)
                info['polvars']['base_ring']='i'
            elif z1<=2:
                info['polynomial_st'] = '<div class="where">where</div> {0}\(\mathstrut=0\).</div><br/>'.format(c_pol_ltx)
            else:
                info['polynomial_st'] = '<div class="where">where</div> %s\(\mathstrut=0\) and \(\zeta_{%s}=e^{\\frac{2\\pi i}{%s}}\) '%(c_pol_ltx, z1,z1)
                info['polvars']['base_ring']='\zeta_{{ {0} }}'.format(z1)
                if z1==3:
                    info['polynomial_st'] += 'is a primitive cube root of unity.'
                else:
                    info['polynomial_st'] += 'is a primitive {0}-th root of unity.'.format(z1)
        elif not br_is_QQ:
            ## Now we have base and coefficient field being equal, meaning that since the coefficient field is not QQ it is some cyclotomic field
            ## generated by some \zeta_n 
            p1 = WNF.coefficient_field.absolute_polynomial()
            z1 = WNF.coefficient_field.gens()[0].multiplicative_order()
            c_pol_ltx = web_latex_poly(p1, '\\zeta_{{{0}}}'.format(z1))
            c_pol_ltx_x = web_latex_poly(p1, 'x')
            info['coeff_field'] = [ WNF.coefficient_field.absolute_polynomial_latex('x'), c_pol_ltx_x]
            if hasattr(WNF.coefficient_field, "lmfdb_url") and WNF.coefficient_field.lmfdb_url:
                info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty, WNF.coefficient_field.lmfdb_label]
            if z1==4:
                info['polynomial_st'] = '<div class="where">where \(\zeta_4=e^{{\\frac{{\\pi i}}{{ 2 }} }}=i \).</div>'.format(c_pol_ltx)
                info['polvars']['coefficient_field']='i'
            elif z1<=2:
                info['polynomial_st'] = '' 
            else:
                info['polynomial_st'] = '<div class="where">where \(\zeta_{{{0}}}=e^{{\\frac{{2\\pi i}}{{ {0} }} }}\) '.format(z1)
                info['polvars']['coefficient_field']='\zeta_{{{0}}}'.format(z1)
                if z1==3:
                    info['polynomial_st'] += 'is a primitive cube root of unity.</div>'
                else:
                    info['polynomial_st'] += 'is a primitive {0}-th root of unity.</div>'.format(z1)
    else:
        info['polynomial_st'] = ''
    if info["hide_qexp"]:
        info['polynomial_st'] = ''
    info['degree'] = int(cdeg)
    if cdeg==1:
        info['is_rational'] = 1
        info['coeff_field_pretty'] = [ WNF.coefficient_field.lmfdb_url, WNF.coefficient_field.lmfdb_pretty ]
    else:
        info['is_rational'] = 0
    emf_logger.debug("PREC2: {0}".format(prec))
    info['embeddings'] = WNF._embeddings['values'] #q_expansion_embeddings(prec, bprec,format='latex')
    info['embeddings_len'] = len(info['embeddings'])
    properties2 = [('Level', str(level)),
                       ('Weight', str(weight)),
                       ('Character', '$' + WNF.character.latex_name + '$'),
                       ('Label', WNF.hecke_orbit_label),
                       ('Dimension of Galois orbit', str(WNF.dimension))]
    if (ZZ(level)).is_squarefree():
        info['twist_info'] = WNF.twist_info
        if isinstance(info['twist_info'], list) and len(info['twist_info'])>0:
            info['is_minimal'] = info['twist_info'][0]
            if(info['twist_info'][0]):
                s = 'Is minimal<br>'
            else:
                s = 'Is a twist of lower level<br>'
            properties2 += [('Twist info', s)]
    else:
        info['twist_info'] = 'Twist info currently not available.'
        properties2 += [('Twist info', 'not available')]
    args = list()
    for x in range(5, 200, 10):
        args.append({'digits': x})
    alev = None
    CM = WNF._cm_values
    if CM is not None:
        if CM.has_key('tau') and len(CM['tau']) != 0:
            info['CM_values'] = CM
    info['is_cm'] = WNF.is_cm
    if WNF.is_cm == 1:
        info['cm_field'] = "2.0.{0}.1".format(-WNF.cm_disc)
        info['cm_disc'] = WNF.cm_disc
        info['cm_field_knowl'] = nf_display_knowl(info['cm_field'], getDBConnection(), field_pretty(info['cm_field']))
        info['cm_field_url'] = url_for("number_fields.by_label", label=info["cm_field"])
    if WNF.is_cm is None or WNF.is_cm==-1:
        s = '- Unknown (insufficient data)<br>'
    elif WNF.is_cm == 1:
        s = 'Yes<br>'
    else:
        s = 'No<br>'
    properties2.append(('CM', s))
    alev = WNF.atkin_lehner_eigenvalues()
    info['atkinlehner'] = None
    if isinstance(alev,dict) and len(alev.keys())>0 and level != 1:
        s1 = " Atkin-Lehner eigenvalues "
        s2 = ""
        for Q in alev.keys():
            s2 += "\( \omega_{ %s } \) : %s <br>" % (Q, alev[Q])
        properties2.append((s1, s2))
        emf_logger.debug("properties={0}".format(properties2))
        # alev = WNF.atkin_lehner_eigenvalues_for_all_cusps() 
        # if isinstance(alev,dict) and len(alev.keys())>0:
        #     emf_logger.debug("alev={0}".format(alev))
        #     info['atkinlehner'] = list()
        #     for Q in alev.keys():
        #         s = "\(" + latex(c) + "\)"
        #         Q = alev[c][0]
        #         ev = alev[c][1]
        #         info['atkinlehner'].append([Q, c, ev])
    if(level == 1):
        poly = WNF.explicit_formulas.get('as_polynomial_in_E4_and_E6','')
        if poly != '':
            d,monom,coeffs = poly
            emf_logger.critical("poly={0}".format(poly))
            info['explicit_formulas'] = '\('
            for i in range(len(coeffs)):
                c = QQ(coeffs[i])
                s = ""
                if d>1 and i >0 and c>0:
                    s="+"
                if c<0:
                    s="-"
                if c.denominator()>1:
                    cc = "\\frac{{ {0} }}{{ {1} }}".format(abs(c.numerator()),c.denominator())
                else:
                    cc = str(abs(c))
                s += "{0} \cdot ".format(cc)
                a = monom[i][0]; b = monom[i][1]
                if a == 0 and b != 0:
                    s+="E_6^{{ {0} }}".format(b)
                elif b ==0 and a != 0:
                    s+="E_4^{{ {0} }}".format(a)
                else:
                    s+="E_4^{{ {0} }}E_6^{{ {1} }}".format(a,b)
                info['explicit_formulas'] += s
            info['explicit_formulas'] += " \)"            
    # cur_url = '?&level=' + str(level) + '&weight=' + str(weight) + '&character=' + str(character) + '&label=' + str(label) # never used
    if len(WNF.parent.hecke_orbits) > 1:
        for label_other in WNF.parent.hecke_orbits.keys():
            if(label_other != label):
                s = 'Modular form '
                if character:
                    s += newform_label(level,weight,character,label_other)
                else:
                    s += newform_label(level,weight,1,label_other)

                url = url_for('emf.render_elliptic_modular_forms', level=level,
                              weight=weight, character=character, label=label_other)
                friends.append((s, url))

    s = 'L-Function '
    if character:
        s += newform_label(level,weight,character,label)
    else:
        s += newform_label(level,weight,1,label)
    # url =
    # "/L/ModularForm/GL2/Q/holomorphic?level=%s&weight=%s&character=%s&label=%s&number=%s"
    # %(level,weight,character,label,0)
    url = '/L' + url_for(
        'emf.render_elliptic_modular_forms', level=level, weight=weight, character=character, label=label)
    if WNF.coefficient_field_degree > 1:
        for h in range(WNF.coefficient_field_degree):
            s0 = s + ".{0}".format(h)
            url0 = url + "{0}/".format(h)
            friends.append((s0, url0))
    else:
        friends.append((s, url))
    # if there is an elliptic curve over Q associated to self we also list that
    if WNF.weight == 2 and WNF.coefficient_field_degree == 1:
        llabel = str(level) + '.' + label
        s = 'Elliptic curve isogeny class ' + llabel
        url = '/EllipticCurve/Q/' + llabel
        friends.append((s, url))
    info['properties2'] = properties2
    info['friends'] = friends
    info['max_cn'] = WNF.max_available_prec()
    return info
Exemplo n.º 43
0
def search_for_eigenvalues(search):
    ev_l = float(search['ev_lower'])
    ev_u = float(search['ev_upper'])
    level_l = float(search['level_lower'])
    level_u = float(search['level_upper'])
    if level_l > 0 and level_u > 0:
        level_range = {"$gte": level_l, "$lte": level_u}
    elif level_u > 0:
        level_range = {"$lte": level_u}
    elif level_l > 0:
        level_range = {"$gte": level_l}
    if ev_l > 0 and ev_u > 0:
        ev_range = {"$gte": ev_l, "$lte": ev_u}
    elif ev_u > 0:
        ev_range = {"$lte": ev_u}
    elif ev_l > 0:
        ev_range = {"$gte": ev_l}
    # weight = float(search['weight']) # not used anywhere below
    rec_start = search['rec_start']
    limit = search['limit']
    res = dict()
    res['weights'] = []
    # SearchLimit = limit_u
    db = connect_db()
    index = 0
    searchp = {'fields': ['Eigenvalue', 'Symmetry', 'Level', 'Character', 'Weight', '_id'],
               'sort': [('Eigenvalue', pymongo.ASCENDING), ('Level', pymongo.ASCENDING)],
               'spec': {"Eigenvalue": ev_range}}
    if level_range:
        searchp['spec']["Level"] = level_range
    if limit > 0:
        searchp['limit'] = rec_start + limit

    # the limit of number of records is 'global', for all collections.
    # is this good?
    print "searchp=", searchp
    index = 0
    search['more'] = 0
    search['rec_start'] = rec_start
    search['rec_stop'] = -1
    for collection_name in db.collection_names():
        if collection_name in ['system.indexes', 'contributors']:
            continue
        c = pymongo.collection.Collection(db, collection_name)
        res[collection_name] = list()
        print "c=", c
        f = c.find(**searchp)
        search['num_recs'] = f.count()
        for rec in f:
            print "rec=", rec
            wt = my_get(rec, 'Weight', 0, float)
            # print "index=",index
            if index >= rec_start and index < limit + rec_start:
                res[collection_name].append(rec)
                if res['weights'].count(wt) == 0:
                    res['weights'].append(wt)
            index = index + 1
            if index > limit + rec_start:
                search['rec_stop'] = index - 1
                search['more'] = 1
                # if len(res[collection_name])<f.count():
                print "There are more to be displayed!"
                exit
    if search['rec_stop'] < 0:
        search['rec_stop'] = limit + rec_start
    return res