Beispiel #1
0
 def populate_all_characters(self, level, weight, verbose=True):
     from sage.all import DirichletGroup
     G = DirichletGroup(level)
     B = G.galois_orbits()
     B = [character[0].minimize_base_ring() for character in B]
     for character in B:
         self.populate(level, weight, character, verbose)
def generate_dimension_table_gamma1(maxN=100, maxk=12, minN=3, mink=2):
    C = pymongo.connection.Connection(port=int(37010))
    ms = C['modularforms']['Modular_symbols.files']
    print ms
    data = dict()
    for N in range(minN, maxN + 1):
        data[N] = dict()
        for k in range(mink, maxk + 1):
            data[N][k] = dict()
            if N > 2:
                D = DirichletGroup(N)
                G = D.galois_orbits(reps_only=True)
                dimall = 0
                in_db_all = True
                for xi, x in enumerate(G):
                    dim = dimension_new_cusp_forms(x, k)
                    dimall += dim
                    finds = ms.find({'t': [int(N), int(k), int(xi)]})
                    in_db = finds.count() > 0
                    if not in_db:
                        in_db_all = False
                    data[N][k][xi] = {'dimension': dim, 'in_db': in_db}
            else:
                in_db_all = True
                # we only have the trivial character
                finds = ms.find({'t': [int(N), int(k), int(0)]})
                in_db = finds.count() > 0
                if not in_db:
                    in_db_all = False
                dimall = dimension_new_cusp_forms(N, k)
                data[N][k][0] = {'dimension': dimall, 'in_db': in_db}
            # print N,k,data[N][k]
            data[N][k][-1] = {'dimension': dimall, 'in_db': in_db_all}
        print "Computed data for level ", N
    return ms, data
Beispiel #3
0
 def populate_all_characters(self, level, weight, verbose=True):
     from sage.all import DirichletGroup
     G = DirichletGroup(level)
     B = G.galois_orbits()
     B = [character[0].minimize_base_ring() for character in B]
     for character in B:
         self.populate(level, weight, character, verbose)
Beispiel #4
0
 def populate_quadratic_characters(self, level, weight, verbose=True):
     from sage.all import DirichletGroup, QQ
     G = DirichletGroup(level,QQ)
     B = G.galois_orbits()
     B = [character[0].minimize_base_ring() for character in B
          if character[0].order()==2]
     for character in B:
         self.populate(level, weight, character, verbose)
Beispiel #5
0
 def populate_quadratic_characters(self, level, weight, verbose=True):
     from sage.all import DirichletGroup, QQ
     G = DirichletGroup(level, QQ)
     B = G.galois_orbits()
     B = [
         character[0].minimize_base_ring() for character in B
         if character[0].order() == 2
     ]
     for character in B:
         self.populate(level, weight, character, verbose)
Beispiel #6
0
 def to_dirichlet_character(self, character):
     if character['order'] == 1:
         from sage.all import trivial_character
         return trivial_character(character['modulus'])
     from sage.all import DirichletGroup, CyclotomicField, QQ
     from sage.modular.dirichlet import DirichletCharacter
     zeta_order = character['zeta_order']
     R = QQ if zeta_order == 2 else CyclotomicField(zeta_order)
     G = DirichletGroup(character['modulus'], R, zeta_order=zeta_order)
     v = G.an_element().element().parent()(character['element'])
     return DirichletCharacter(G, v)
Beispiel #7
0
 def to_dirichlet_character(self, character):
     if character['order'] == 1:
         from sage.all import trivial_character
         return trivial_character(character['modulus'])
     from sage.all import DirichletGroup, CyclotomicField, QQ
     from sage.modular.dirichlet import DirichletCharacter
     zeta_order = character['zeta_order']
     R = QQ if zeta_order == 2 else CyclotomicField(zeta_order)
     G = DirichletGroup(character['modulus'], R, zeta_order=zeta_order)
     v = G.an_element().element().parent()(character['element'])
     return DirichletCharacter(G, v)
Beispiel #8
0
def return_dimension(level=None, weight=None, chi=None, **kwds):
    if request.method == 'GET':
        info = to_dict(request.args)
    else:
        info = to_dict(request.form)
    level = my_get(info, 'level', level, int)
    weight = my_get(info, 'weight', weight, int)
    chi = my_get(info, 'chi', chi, int)
    if level is None or weight is None:
        return emf_error("Please supply level weight (and optional character)!"), 500
    ttype = my_get(kwds, 'ttype', info.get('ttype', 'new'), str)
    emf_logger.debug("level,weight,chi: {0},{1},{2}, type={3}".format(level, weight, chi, ttype))
    if chi == 0 or chi is None:
        x = level
    else:
        x = DirichletGroup(level).list()[chi]
    if ttype == 'new':
        return str(dimension_new_cusp_forms(x, weight))
    if ttype == 'cusp':
        return str(dimension_cusp_forms(x, weight))
    if ttype == 'modular':
        return str(dimension_modular_forms(x, weight))
    if ttype == 'eisenstein':
        return str(dimension_eis(x, weight))
    s = "Please use one of the available table types: 'new', 'cusp','modular', 'eisenstein' Got:{0}".format(
        ttype)
    return emf_error(s), 500
Beispiel #9
0
def get_sturm_bound(k, N, xi=0):
    r""" Return the Sturm bound of S_k(N,xi), i.e. the number of coefficients necessary to determine a form uniquely in the space.

    INPUT:

     - ''k'' -- positive integer : the weight
     - ''N'' -- positive integer (default 1) : level
     - ''xi''-- non-negative integer (default 0) : use character nr. xi in DirichletGroup(N)

    OUTPUT:

     - ''s'' -- string representation of t = sturm bound of S_k(N,xi)


    EXAMPLES::


        sage: get_sturm_bound(11,2)
        '3'
        sage: get_sturm_bound(3,14,3)
        '7'

    """
    # check input
    if (N <= 0 or k <= 0):
        raise ValueError("Need positive level and weight!")
    if (xi == 0):
        d = sturm_bound(N, k)
    else:
        chi = DirichletGroup(N)[xi]
        S = CuspForms(chi, k)
        d = S.sturm_bound()
    return str(d)
Beispiel #10
0
def get_dimension_cusp_forms(k, N=1, xi=0):
    r""" Return the dimension of S_k(N,xi).

    INPUT:
     - ''k'' -- positive integer : the weight
     - ''N'' -- positive integer (default 1) : level
     - ''xi''-- non-negative integer (default 0) : use character nr. xi in DirichletGroup(N)

    OUTPUT:
     - ''s'' -- string representation of d = dimension of S_k(N,xi)

    EXAMPLES::

        sage: get_dimension_cusp_forms(2,11)
        '1'
        sage: get_dimension_cusp_forms(3,14,3)
        '2'

    """
    # check input
    if (N <= 0 or k <= 0):
        raise ValueError("Need positive level and weight!")
    if (xi < 0):
        raise ValueError("Need positive character index!")
    elif (xi == 0):
        d = dimension_cusp_forms(N, k)
    else:
        DG = DirichletGroup(N)
        chi = list(DG)[xi]
        d = dimension_cusp_forms(chi, k)
    return str(d)
Beispiel #11
0
 def sage_character(self, order, genvalues):
     H = DirichletGroup(self.modulus,
                        base_ring=CyclotomicField(
                            self.sage_zeta_order(order)))
     M = H._module
     order_corrected_genvalues = get_sage_genvalues(
         self.modulus, order, genvalues, self.sage_zeta_order(order))
     return DirichletCharacter(H, M(order_corrected_genvalues))
 def twist_by(self, x):
     r"""
     twist self by a primitive Dirichlet character x
     """
     # xx = x.primitive()
     assert x.is_primitive()
     q = x.conductor()
     # what level will the twist live on?
     level = self.level()
     qq = self.character().conductor()
     new_level = lcm(self.level(), lcm(q * q, q * qq))
     D = DirichletGroup(new_level)
     new_x = D(self.character()) * D(x) * D(x)
     ix = D.list().index(new_x)
     #  the correct space
     NS = WebModFormSpace(self._k, new_level, ix, self._prec)
     # have to find whih form wee want
     NS.galois_decomposition()
     M = NS.sturm_bound() + len(divisors(new_level))
     C = self.coefficients(range(M))
     for label in NS._galois_orbits_labels:
         wmf_logger.debug("label={0}".format(label))
         FT = NS.f(label)
         CT = FT.f.coefficients(M)
         wmf_logger.debug("{0}".format(CT))
         K = FT.f.hecke_eigenvalue_field()
         try:
             for n in range(2, M):
                 if(new_level % n + 1 == 0):
                     continue
                 wmf_logger.debug("n={0}".format(n))
                 ct = CT[n]
                 c = K(x(n)) * K(C[n])
                 wmf_logger.debug("{0} {1}".format(ct, c))
                 if ct != c:
                     raise StopIteration()
         except StopIteration:
             pass
         else:
             wmf_logger.debug("Twist of f={0}".format(FT))
     return FT
Beispiel #13
0
def _get_newform(k, N, chi, fi):
    r"""
    Get an element of the space of newforms, incuding some error handling.

    INPUT:

     - ''k'' -- positive integer : the weight
     - ''N'' -- positive integer (default 1) : level
     - ''chi'' -- non-neg. integer (default 0) use character nr. chi
     - ''fi'' -- integer (default 0) We want to use the element nr. fi f=Newforms(N,k)[fi]. fi=-1 returns the whole list
     - ''prec'' -- integer (the number of coefficients to get)

    OUTPUT:

    -''t'' -- bool, returning True if we succesfully created the space and picked the wanted f
    -''f'' -- equals f if t=True, otherwise contains an error message.

    EXAMPLES::


        sage: _get_newform(16,10,1)
        (False, 'Could not construct space $S^{new}_{16}(10)$')
        sage: _get_newform(10,16,1)
        (True, q - 68*q^3 + 1510*q^5 + O(q^6))
        sage: _get_newform(10,16,3)
        (True, q + 156*q^3 + 870*q^5 + O(q^6))
        sage: _get_newform(10,16,4)
        (False, '')

     """
    t = False
    try:
        if (chi == 0):
            S = Newforms(N, k, names='x')
        else:
            S = Newforms(DirichletGroup(N)[chi], k, names='x')
        if (fi >= 0 and fi < len(S)):
            f = S[fi]
            t = True
        elif (fi == -1):
            return S
        else:
            f = ""
    except RuntimeError:
        if (chi == 0):
            f = "Could not construct space $S^{new}_{%s}(%s)$" % (k, N)
        else:
            f = "Could not construct space $S^{new}_{%s}(%s,\chi_{%s})$" % (
                k, N, chi)
    return (t, f)
def generate_dimension_table_gamma1(maxN=100, maxk=12, minN=3, mink=2):
    C = pymongo.connection.Connection(port=dbport)
    C = pymongo.connection.Connection(port=dbport)
    ms = C['modularforms']['Modular_symbols.files']
    print ms
    data = dict()
    for N in range(minN, maxN + 1):
        data[N] = dict()
        for k in range(mink, maxk + 1):
            data[N][k] = dict()
            if N > 2:
                D = DirichletGroup(N)
                G = D.galois_orbits(reps_only=True)
                dimall = 0
                in_db_all = True
                for xi, x in enumerate(G):
                    dim = dimension_new_cusp_forms(x, k)
                    dimall += dim
                    finds = ms.find({'t': [int(N), int(k), int(xi)]})
                    in_db = finds.count() > 0
                    if not in_db:
                        in_db_all = False
                    data[N][k][xi] = {'dimension': dim, 'in_db': in_db}
            else:
                in_db_all = True
                # we only have the trivial character
                finds = ms.find({'t': [int(N), int(k), int(0)]})
                in_db = finds.count() > 0
                if not in_db:
                    in_db_all = False
                dimall = dimension_new_cusp_forms(N, k)
                data[N][k][0] = {'dimension': dimall, 'in_db': in_db}
            # print N,k,data[N][k]
            data[N][k][-1] = {'dimension': dimall, 'in_db': in_db_all}
        print "Computed data for level ", N
    return ms, data
Beispiel #15
0
def is_CM(k, N=1, chi=0, fi=0, prec=10):
    r"""
    Checks if f has complex multiplication and if it has then it returns the character.

    INPUT:

    - ''k'' -- positive integer : the weight
    - ''N'' -- positive integer (default 1) : level
    - ''chi'' -- non-neg. integer (default 0) use character nr. chi    - ''fi'' -- non-neg. integer (default 0) We want to use the element nr. fi f=Newforms(N,k)[fi]


    OUTPUT:

    -''[t,x]'' -- string saying whether f is CM or not and if it is, the corresponding character

    EXAMPLES::



    """
    (t, f) = _get_newform(k, N, chi, fi)
    if (not t):
        return f
    max_nump = number_of_hecke_to_check(f)
    coeffs = f.coefficients(max_nump + 1)
    nz = coeffs.count(0)  # number of zero coefficients
    nnz = len(coeffs) - nz  # number of non-zero coefficients
    if (nz == 0):
        return [False, 0]
    # probaly checking too many
    for D in range(3, ceil(QQ(max_nump) / QQ(2))):
        try:
            for x in DirichletGroup(D):
                if (x.order() != 2):
                    continue
                # we know that for CM we need x(p) = -1 => c(p)=0
                # (for p not dividing N)
                if (x.values().count(-1) > nz):
                    raise StopIteration()  # do not have CM with this char
                for p in prime_range(max_nump + 1):
                    if (x(p) == -1 and coeffs[p] != 0):
                        raise StopIteration()  # do not have CM with this char
                # if we are here we have CM with x.
                return [True, x]
        except StopIteration:
            pass
    return [False, 0]
def insert_dirichlet_L_functions(start, end):
    print "Putting Dirichlet L-functions into database."
    start = max(3, start)
    for q in range(start, end):
        print "Working on modulus", q
        sys.stdout.flush()
        G = DirichletGroup(q)
        for n in range(len(G)):
            chi = G[n]
            if chi.is_primitive():
                L = lc.Lfunction_from_character(chi)
                z = L.find_zeros_via_N(1)[0]
                Lfunction_data = {}
                Lfunction_data['first_zero'] = float(z)
                Lfunction_data[
                    'description'] = "Dirichlet L-function for character number " + str(
                        n) + " modulo " + str(q)
                Lfunction_data['degree'] = 1
                Lfunction_data['signature'] = (1, 0)
                if chi.is_odd():
                    Lfunction_data['mu'] = [
                        (1.0, 0.0),
                    ]
                else:
                    Lfunction_data['mu'] = [
                        (0.0, 0.0),
                    ]

                Lfunction_data['level'] = q

                coeffs = []

                for k in range(0, 10):
                    coeffs.append(CC(chi(k)))

                Lfunction_data['coeffs'] = [(float(x.real()), float(x.imag()))
                                            for x in coeffs]
                Lfunction_data['special'] = {
                    'type': 'dirichlet',
                    'modulus': q,
                    'number': n
                }

                Lfunctions.insert(Lfunction_data)
Beispiel #17
0
def compare_vv_scalar(V, k):
    dv = V.dimension_cusp_forms(k)
    N = V._level
    m = V._M.order()
    if k in ZZ:
        D = DirichletGroup(N)
        if is_even(k):
            chi = D(kronecker_character(m))
        else:
            chi = D(kronecker_character(-m))
        S = CuspForms(chi, k)
        N = Newforms(chi, k, names='a')
        ds = S.dimension()
        B = N
    else:
        D = magma.DirichletGroup(V._level)
        chi = magma.D(magma.KroneckerCharacter(2 * m))
        M = magma.HalfIntegralWeightForms(chi, k)
        S = M.CuspidalSubspace()
        ds = S.Dimension()
        B = S.Basis()
    return dv, ds, S, B
Beispiel #18
0
def compare_formulas_1(D, k):
    DG = DirichletGroup(abs(D))
    chi = DG(kronecker_character(D))
    d1 = dimension_new_cusp_forms(chi, k)
    #if D>0:
    #    lvals=sage.lfunctions.all.lcalc.twist_values(1,2,D)
    #else:
    #    lvals=sage.lfunctions.all.lcalc.twist_values(1,D,0)
    #s1=RR(sum([sqrt(abs(lv[0]))*lv[1]*2**len(prime_factors(D/lv[0])) for lv in lvals if lv[0].divides(D) and Zmod(lv[0])(abs(D/lv[0])).is_square()]))
    #d2=RR(1/pi*s1)
    d2 = 0
    for d in divisors(D):
        if is_fundamental_discriminant(-d):
            K = QuadraticField(-d)
            DD = old_div(ZZ(D), ZZ(d))
            ep = euler_phi((chi * DG(kronecker_character(-d))).conductor())
            #ep=euler_phi(squarefree_part(abs(D*d)))
            print("ep=", ep, D, d)
            ids = [a for a in K.ideals_of_bdd_norm(-DD)[-DD]]
            eulers1 = []
            for a in ids:
                e = a.euler_phi()
                if e != 1 and ep == 1:
                    if K(-1).mod(a) != K(1).mod(a):
                        e = old_div(e, (2 * ep))
                else:
                    e = old_div(e, ep)
                eulers1.append(e)
            print(eulers1, ep)
            s = sum(eulers1)
            if ep == 1 and not (d.divides(DD) or abs(DD) == 1):
                continue
            print(d, s)
            if len(eulers1) > 0:
                d2 += s * K.class_number()
    return d1 - d2
Beispiel #19
0
def find_inverse_images_of_twists(k, N=1, chi=0, fi=0, prec=10, verbose=0):
    r"""
    Checks if f is minimal and if not, returns the associated
    minimal form to precision prec.

    INPUT:

    - ''k'' -- positive integer : the weight
    - ''N'' -- positive integer (default 1) : level
    - ''chi'' -- non-neg. integer (default 0) use character nr. chi
    - ''fi'' -- non-neg. integer (default 0) We want to use the element nr. fi f=Newforms(N,k)[fi]
    - ''prec'' -- integer (the number of coefficients to get)
    - ''verbose'' -- integer
    OUTPUT:

    -''[t,l]'' -- tuple of a Bool t and a list l. The list l contains all tuples of forms which twists to the given form.
              The actual minimal one is the first element of this list.

    EXAMPLES::



    """
    (t, f) = _get_newform(k, N, chi, fi)

    if (not t):
        return f
    if (is_squarefree(ZZ(N))):
        return [True, f]
    # We need to check all square factors of N
    logger.debug("investigating: %s" % f)
    N_sqfree = squarefree_part(ZZ(N))
    Nsq = ZZ(N / N_sqfree)
    twist_candidates = list()
    KF = f.base_ring()
    # check how many Hecke eigenvalues we need to check
    max_nump = number_of_hecke_to_check(f)
    maxp = max(primes_first_n(max_nump))
    for d in divisors(N):
        # we look at all d such that d^2 divdes N
        if (not ZZ(d**2).divides(ZZ(N))):
            continue
        D = DirichletGroup(d)
        # check possible candidates to twist into f
        # g in S_k(M,chi) wit M=N/d^2
        M = ZZ(N / d**2)
        logger.debug("Checking level %s" % M)
        for xig in range(euler_phi(M)):
            (t, glist) = _get_newform(k, M, xig)
            if (not t):
                return glist
            for g in glist:
                logger.debug("Comparing to function %s" % g)
                KG = g.base_ring()
                # we now see if twisting of g by xi in D gives us f
                for xi in D:
                    try:
                        for p in primes_first_n(max_nump):
                            if (ZZ(p).divides(ZZ(N))):
                                continue
                            bf = f.q_expansion(maxp + 1)[p]
                            bg = g.q_expansion(maxp + 1)[p]
                            if (bf == 0 and bg == 0):
                                continue
                            elif (bf == 0 and bg != 0 or bg == 0 and bf != 0):
                                raise StopIteration()
                            if (ZZ(p).divides(xi.conductor())):
                                raise ArithmeticError("")
                            xip = xi(p)
                            # make a preliminary check that the base rings match with respect to being
                            # real or not
                            try:
                                QQ(xip)
                                XF = QQ
                                if (KF != QQ or KG != QQ):
                                    raise StopIteration
                            except TypeError:
                                # we have a  non-rational (i.e. complex) value of the character
                                XF = xip.parent()
                                if ((KF == QQ or KF.is_totally_real()) and
                                    (KG == QQ or KG.is_totally_real())):
                                    raise StopIteration
                            ## it is diffcult to compare elements from diferent rings in general but we make some checcks
                            # is it possible to see if there is a larger ring which everything can be
                            # coerced into?
                            ok = False
                            try:
                                a = KF(bg / xip)
                                b = KF(bf)
                                ok = True
                                if (a != b):
                                    raise StopIteration()
                            except TypeError:
                                pass
                            try:
                                a = KG(bg)
                                b = KG(xip * bf)
                                ok = True
                                if (a != b):
                                    raise StopIteration()
                            except TypeError:
                                pass
                            if (
                                    not ok
                            ):  # we could coerce and the coefficients were equal
                                return "Could not compare against possible candidates!"
                            # otherwise if we are here we are ok and found a candidate
                        twist_candidates.append([dd, g.q_expansion(prec), xi])
                    except StopIteration:
                        # they are not equal
                        pass
    # logger.debug("Candidates=%s" % twist_candidates)
    if (len(twist_candidates) == 0):
        return (True, None)
    else:
        return (False, twist_candidates)
Beispiel #20
0
def make_table_of_dimensions(level_start=1, level_stop=50, weight_start=1, weight_stop=24, char=0, **kwds):
    r"""
    make an html table with information about spaces of modular forms
    with parameters in the given ranges. using a fixed character.
    Should use database in the future...
    """
    D = 0
    rowlen = 15  # split into rows of this length...
    rowlen0 = rowlen
    rowlen1 = rowlen
    characters = dict()
    level = 'N'
    weight = 'k'
    print "char=", char
    if level_start == level_stop:
        level = level_start
        count_min = weight_start
        count_max = weight_stop
        if (weight_stop - weight_start + 1) < rowlen:
            rowlen0 = weight_stop - weight_start + 1
    if weight_start == weight_stop:
        weight = weight_start
        count_min = level_start
        count_max = level_stop
        if (level_stop - level_start + 1) < rowlen:
            rowlen0 = level_stop - level_start + 1
    # else:
    #    return ""
    tbl = dict()
    if(char == 0):
        tbl['header'] = ''  # Dimension of \( S_{'+str(weight)+'}('+str(level)+',\chi_{n})\)'
        charst = ""
    else:
        # s = 'Dimension of \( S_{'+str(weight)+'}('+str(level)+')\)'
        # s += ' (trivial character)'
        charst = ",\chi_{%s}" % char
        tbl['header'] = ''
    tbl['headersv'] = list()
    tbl['headersh'] = list()
    if weight == 'k':
        tbl['corner_label'] = "weight \(k\):"
    else:
        tbl['corner_label'] = "level \(N\):"
    tbl['data'] = list()
    tbl['data_format'] = 'html'
    tbl['class'] = "dimension_table"
    tbl['atts'] = "border=\"1\" class=\"nt_data\" padding=\"25\" width=\"100%\""
    num_rows = ceil(QQ(count_max - count_min + 1) / QQ(rowlen0))
    print "num_rows=", num_rows
    for i in range(1, rowlen0 + 1):
        tbl['headersh'].append(i + count_min - 1)
    if level_start == level_stop:
        st = "Dimension of \(S_{k}(%s%s) \):" % (level, charst)
        tbl['headersv'] = [st]
    else:
        st = "Dimension of \(S_{%s}(N%s) \):" % (weight, charst)
        tbl['headersv'] = [st]
    tbl['headersv'].append('Link to space:')
    # make a dummy table first
    # num_rows = (num_rows-1)*2
    for r in range(num_rows * 2):
        row = []
        for k in range(1, rowlen0 + 1):
            row.append("")
        tbl['data'].append(row)
    tbl['data_format'] = dict()
    for k in range(0, rowlen0):
        tbl['data_format'][k] = 'html'

    print "nu_rows=", len(tbl['data'])
    print "num_cols=", rowlen0
    print "num_cols=", [len(r) for r in tbl['data']]
    for r in range(num_rows):
        for k in range(0, rowlen0):
            cnt = count_min + r * rowlen0 + k
            if level_start == level_stop:
                weight = cnt
            else:
                level = cnt
            url = url_for('emf.render_elliptic_modular_forms', level=level, weight=weight)
            if(cnt > count_max or cnt < count_min):
                tbl['data'][2 * r][k] = ""
                continue
            # s="<a name=\"#%s,%s\"></a>" % (level,weight)
            if(char == 0):
                d = dimension_cusp_forms(level, weight)
            else:
                x = DirichletGroup(level)[char]
                d = dimension_cusp_forms(x, weight)
            tbl['data'][2 * r][k] = str(d)
            if d > 0:
                s = "\(S_{%s}(%s)\)" % (weight, level)
                ss = "<a  href=\"" + url + "\">" + s + "</a>"
                tbl['data'][2 * r + 1][k] = ss
    s = html_table(tbl)
    # s=s+"\n <br> \(N="+str(rowlen0)+"\cdot row+col\)"
    # print "SS=",s
    return s
Beispiel #21
0
 def set_table_browsing(self,skip=[0,0],limit=[(2,16),(1,50)],keys=['Weight','Level'],character=0,dimension_fun=dimension_new_cusp_forms,title='Dimension of newforms'):
     r"""
     Table of Holomorphic modular forms spaces.
     Skip tells you how many chunks of data you want to skip (from the geginning) and limit tells you how large each chunk is.
     INPUT:
     - dimension_fun should be a function which gives you the desired dimensions, as functions of level N and weight k
     - character = 0 for trivial character and 1 for Kronecker symbol.
       set to 'all' for all characters.
     """
     self._keys=keys
     self._skip=skip
     self._limit=limit
     self._metadata=[]
     self._title=''
     self._cols=[]
     self.table={}
     self._character = character
     emf_logger.debug("skip= {0}".format(self._skip))
     emf_logger.debug("limit= {0}".format(self._limit))
     il  = self._keys.index('Level')
     iwt = self._keys.index('Weight')
     level_len = self._limit[il][1]-self._limit[il][0]+1
     level_ll=self._skip[il]*level_len+self._limit[il][0];   level_ul=self._skip[il]*level_len+self._limit[il][1]
     wt_len = self._limit[iwt][1]-self._limit[iwt][0]+1
     wt_ll=self._skip[iwt]*wt_len+self._limit[iwt][0]; wt_ul=self._skip[iwt]*wt_len+self._limit[iwt][1]
     if level_ll<1: level_l=1
     self._table={}
     self._table['rows']=[]
     self._table['col_heads']=[] #range(wt_ll,wt_ul+1)
     self._table['row_heads']=[] #range(level_ll,level_ul+1)
     emf_logger.debug("wt_range: {0} -- {1}".format(wt_ll,wt_ul))
     emf_logger.debug("level_range: {0} -- {1}".format(level_ll,level_ul))
     if character in [0,1]:
         if level_ll == level_ul:
             N=level_ll
             self._table['rowhead']='Weight'
             if character==0:
                 self._table['row_heads']=['Trivial character']
             else:
                 self._table['row_heads']=['\( \\( \frac{\cdot}{N} \\)\)']
             row=[]
             for k in range(wt_ll,wt_ul+1):
                 if character == 0 and is_odd(k):
                     continue
                 try:
                     if character==0:
                         d = dimension_fun(N,k)
                     elif character==1:
                         x = kronecker_character_upside_down(N)
                         d = dimension_fun(x,k)
                 except Exception as ex:
                     emf_logger.critical("Exception: {0}. \n Could not compute the dimension with function {0}".format(ex,dimension_fun))
                 url = url_for('emf.render_elliptic_modular_form_browsing',level=N,weight=k)
                 if not k in self._table['col_heads']:
                     self._table['col_heads'].append(k)
                 row.append({'N':N,'k':k,'url':url,'dim':d})
             self._table['rows'].append(row)                
         else:
             for N in range(level_ll,level_ul+1):
                 if not N in self._table['row_heads']:
                     self._table['row_heads'].append(N)
                 row=[]
                 for k in range(wt_ll,wt_ul+1):
                     if character == 0 and is_odd(k):
                         continue
                     try:
                         if character==0:
                             d = dimension_fun(N,k)
                         elif character==1:
                             x = kronecker_character_upside_down(N)
                             d = dimension_fun(x,k)
                     except Exception as ex:
                         emf_logger.critical("Exception: {0}. \n Could not compute the dimension with function {0}".format(ex,dimension_fun))
                     url = url_for('emf.render_elliptic_modular_form_browsing',level=N,weight=k)
                     if not k in self._table['col_heads']:
                         self._table['col_heads'].append(k)
                     row.append({'N':N,'k':k,'url':url,'dim':d})
                 self._table['rows'].append(row)
     elif character=='all':
         # make table with all characters.
         self._table['characters']=dict()
         if level_ll == level_ul:
             N = level_ll
             D = DirichletGroup(N)
             emf_logger.debug("I am here!")
             self._table['rowhead']='Character&nbsp;\&nbspWeight'
             for x in D:
                 xi = D.list().index(x)
                 row=[]
                 self._table['row_heads'].append(xi)
                 for k in range(wt_ll,wt_ul+1):
                     if not k in self._table['col_heads']:              
                         self._table['col_heads'].append(k)
                     try:
                         d = dimension_fun(x,k)
                     except Exception as ex:
                         emf_logger.critical("Exception: {0} \n Could not compute the dimension with function {0}".format(ex,dimension_fun))
                         d = -1
                     url = url_for('emf.render_elliptic_modular_form_space',level=N,weight=k,character=xi)
                     row.append({'N':N,'k':k,'chi':xi,'url':url,'dim':d})
                 self._table['rows'].append(row)                            
         else:
             for N in range(level_ll,level_ul+1):
                 self._table['row_heads'].append(N)
                 self._table['characters'][N]=list()
                 row=[]
                 if N==0: continue
                 D = DirichletGroup(N)
                 for k in range(wt_ll,wt_ul+1):
                     tbl=[]
                     for x in D:
                         xi = D.list().index(x)
                         if not N in self._table['characters'][N]:              
                             self._table['characters'][N].append(xi)
                         if x.is_even() and is_odd(k):
                             continue
                         if x.is_odd() and is_even(k):
                             continue
                         try:
                             d = dimension_fun(x,k)
                         except Exception as ex:
                             emf_logger.critical("Exception: {0} \n Could not compute the dimension with function {0}".format(ex,dimension_fun))
                         url = url_for('emf.render_elliptic_modular_form_browsing',level=N,weight=k)
                     if not k in self._table['col_heads']:
                         self._table['col_heads'].append(k)
                     tbl.append({'N':N,'k':k,'chi':xi,'url':url,'dim':d})
                     row.append(tbl)
                 self._table['rows'].append(row)            
Beispiel #22
0
 def set_table_browsing(self,
                        skip=[0, 0],
                        limit=[(2, 16), (1, 50)],
                        keys=['Weight', 'Level'],
                        character=0,
                        dimension_fun=dimension_new_cusp_forms,
                        title='Dimension of newforms'):
     r"""
     Table of Holomorphic modular forms spaces.
     Skip tells you how many chunks of data you want to skip (from the geginning) and limit tells you how large each chunk is.
     INPUT:
     - dimension_fun should be a function which gives you the desired dimensions, as functions of level N and weight k
     - character = 0 for trivial character and 1 for Kronecker symbol.
       set to 'all' for all characters.
     """
     self._keys = keys
     self._skip = skip
     self._limit = limit
     self._metadata = []
     self._title = ''
     self._cols = []
     self.table = {}
     self._character = character
     emf_logger.debug("skip= {0}".format(self._skip))
     emf_logger.debug("limit= {0}".format(self._limit))
     il = self._keys.index('Level')
     iwt = self._keys.index('Weight')
     level_len = self._limit[il][1] - self._limit[il][0] + 1
     level_ll = self._skip[il] * level_len + self._limit[il][0]
     level_ul = self._skip[il] * level_len + self._limit[il][1]
     wt_len = self._limit[iwt][1] - self._limit[iwt][0] + 1
     wt_ll = self._skip[iwt] * wt_len + self._limit[iwt][0]
     wt_ul = self._skip[iwt] * wt_len + self._limit[iwt][1]
     if level_ll < 1: level_l = 1
     self._table = {}
     self._table['rows'] = []
     self._table['col_heads'] = []  #range(wt_ll,wt_ul+1)
     self._table['row_heads'] = []  #range(level_ll,level_ul+1)
     emf_logger.debug("wt_range: {0} -- {1}".format(wt_ll, wt_ul))
     emf_logger.debug("level_range: {0} -- {1}".format(level_ll, level_ul))
     if character in [0, 1]:
         if level_ll == level_ul:
             N = level_ll
             self._table['rowhead'] = 'Weight'
             if character == 0:
                 self._table['row_heads'] = ['Trivial character']
             else:
                 self._table['row_heads'] = ['\( \\( \frac{\cdot}{N} \\)\)']
             row = []
             for k in range(wt_ll, wt_ul + 1):
                 if character == 0 and is_odd(k):
                     continue
                 try:
                     if character == 0:
                         d = dimension_fun(N, k)
                     elif character == 1:
                         x = kronecker_character_upside_down(N)
                         d = dimension_fun(x, k)
                 except Exception as ex:
                     emf_logger.critical(
                         "Exception: {0}. \n Could not compute the dimension with function {0}"
                         .format(ex, dimension_fun))
                 url = url_for('emf.render_elliptic_modular_form_browsing',
                               level=N,
                               weight=k)
                 if not k in self._table['col_heads']:
                     self._table['col_heads'].append(k)
                 row.append({'N': N, 'k': k, 'url': url, 'dim': d})
             self._table['rows'].append(row)
         else:
             for N in range(level_ll, level_ul + 1):
                 if not N in self._table['row_heads']:
                     self._table['row_heads'].append(N)
                 row = []
                 for k in range(wt_ll, wt_ul + 1):
                     if character == 0 and is_odd(k):
                         continue
                     try:
                         if character == 0:
                             d = dimension_fun(N, k)
                         elif character == 1:
                             x = kronecker_character_upside_down(N)
                             d = dimension_fun(x, k)
                     except Exception as ex:
                         emf_logger.critical(
                             "Exception: {0}. \n Could not compute the dimension with function {0}"
                             .format(ex, dimension_fun))
                     url = url_for(
                         'emf.render_elliptic_modular_form_browsing',
                         level=N,
                         weight=k)
                     if not k in self._table['col_heads']:
                         self._table['col_heads'].append(k)
                     row.append({'N': N, 'k': k, 'url': url, 'dim': d})
                 self._table['rows'].append(row)
     elif character == 'all':
         # make table with all characters.
         self._table['characters'] = dict()
         if level_ll == level_ul:
             N = level_ll
             D = DirichletGroup(N)
             emf_logger.debug("I am here!")
             self._table['rowhead'] = 'Character&nbsp;\&nbspWeight'
             for x in D:
                 xi = D.list().index(x)
                 row = []
                 self._table['row_heads'].append(xi)
                 for k in range(wt_ll, wt_ul + 1):
                     if not k in self._table['col_heads']:
                         self._table['col_heads'].append(k)
                     try:
                         d = dimension_fun(x, k)
                     except Exception as ex:
                         emf_logger.critical(
                             "Exception: {0} \n Could not compute the dimension with function {0}"
                             .format(ex, dimension_fun))
                         d = -1
                     url = url_for('emf.render_elliptic_modular_form_space',
                                   level=N,
                                   weight=k,
                                   character=xi)
                     row.append({
                         'N': N,
                         'k': k,
                         'chi': xi,
                         'url': url,
                         'dim': d
                     })
                 self._table['rows'].append(row)
         else:
             for N in range(level_ll, level_ul + 1):
                 self._table['row_heads'].append(N)
                 self._table['characters'][N] = list()
                 row = []
                 if N == 0: continue
                 D = DirichletGroup(N)
                 for k in range(wt_ll, wt_ul + 1):
                     tbl = []
                     for x in D:
                         xi = D.list().index(x)
                         if not N in self._table['characters'][N]:
                             self._table['characters'][N].append(xi)
                         if x.is_even() and is_odd(k):
                             continue
                         if x.is_odd() and is_even(k):
                             continue
                         try:
                             d = dimension_fun(x, k)
                         except Exception as ex:
                             emf_logger.critical(
                                 "Exception: {0} \n Could not compute the dimension with function {0}"
                                 .format(ex, dimension_fun))
                         url = url_for(
                             'emf.render_elliptic_modular_form_browsing',
                             level=N,
                             weight=k)
                     if not k in self._table['col_heads']:
                         self._table['col_heads'].append(k)
                     tbl.append({
                         'N': N,
                         'k': k,
                         'chi': xi,
                         'url': url,
                         'dim': d
                     })
                     row.append(tbl)
                 self._table['rows'].append(row)
def Dirichlet_Lfunctions_iterator(qMax):
    for q in [3..qMax]:
        for n in range(len(DirichletGroup(q))):
            yield Lfunction_Dirichlet(charactermodulus=q, characternumber=n)
Beispiel #24
0
import sys

from sage.all import DirichletGroup

import pymongo
from pymongo import Connection
import sage.libs.lcalc.lcalc_Lfunction as lc

from lmfdb import base
C = base.getDBConnection()
db = C.Lfunctions

first_zeros = db.first_zeros_testing

first_zeros.drop()

for q in range(3, 1500):
    print q
    sys.stdout.flush()
    G = DirichletGroup(q)
    for n in range(len(G)):
        if G[n].is_primitive():
            L = lc.Lfunction_from_character(G[n])
            z = L.find_zeros_via_N(1)[0]
            first_zeros.insert({
                'zero': float(z),
                'modulus': int(q),
                'character': int(n)
            })
Beispiel #25
0
 def set_table_browsing(self,
                        skip=[0, 0],
                        limit=[(2, 16), (1, 50)],
                        keys=['Weight', 'Level'],
                        character=0,
                        dimension_table=None,
                        dimension_fun=dimension_new_cusp_forms,
                        title='Dimension of newforms',
                        check_db=True):
     r"""
     Table of Holomorphic modular forms spaces.
     Skip tells you how many chunks of data you want to skip (from the geginning) and limit tells you how large each chunk is.
     INPUT:
     - dimension_fun should be a function which gives you the desired dimensions, as functions of level N and weight k
     - character = 0 for trivial character and 1 for Kronecker symbol.
       set to 'all' for all characters.
     - check_db=True means, that we will only link to spaces which are in the database
     """
     self._keys = keys
     self._skip = skip
     self._limit = limit
     self._metadata = []
     self._title = ''
     self._cols = []
     self.table = {}
     self._character = character
     emf_logger.debug("skip= {0}".format(self._skip))
     emf_logger.debug("limit= {0}".format(self._limit))
     il = self._keys.index('Level')
     iwt = self._keys.index('Weight')
     level_len = self._limit[il][1] - self._limit[il][0] + 1
     level_ll = self._skip[il] * level_len + self._limit[il][0]
     level_ul = self._skip[il] * level_len + self._limit[il][1]
     wt_len = self._limit[iwt][1] - self._limit[iwt][0] + 1
     wt_ll = self._skip[iwt] * wt_len + self._limit[iwt][0]
     wt_ul = self._skip[iwt] * wt_len + self._limit[iwt][1]
     if level_ll < 1:
         level_l = 1
     self._table = {}
     self._table['rows'] = []
     self._table['col_heads'] = []  # range(wt_ll,wt_ul+1)
     self._table['row_heads'] = []  # range(level_ll,level_ul+1)
     emf_logger.debug("wt_range: {0} -- {1}".format(wt_ll, wt_ul))
     emf_logger.debug("level_range: {0} -- {1}".format(level_ll, level_ul))
     emf_logger.debug("character: {0}".format(character))
     self._table['characters'] = dict()
     if dimension_table is not None:
         dimension_fun = dimension_table.dimension
         is_data_in_db = dimension_table.is_in_db
     factors = connect_db()['Newform_factors.files']
     list_of_data = factors.distinct('hecke_orbit_label')
     #else:
     #def is_data_in_db(N, k, character):
     #    n = self._files.find({'N':int(N),'k':int(k),'chi':int(character)}).count()
     #    emf_logger.debug("is_Data_in: N,k,character: {0} no. recs: {1} in {2}".format((N,k,character),n,self._files))
     #    return n>0
     # fixed level
     if level_ll == level_ul:
         N = level_ll
         # specific character =0,1
         if character == 0 or character == 1:
             self._table['rowhead'] = 'Weight'
             if character == 0:
                 cchi = 1  #xc = DirichletGroup_conrey(N)[1]
             else:
                 D = DirichletGroup_conrey(N)
                 for xc in D:
                     x = xc.sage_character()
                     if x == kronecker_character_upside_down(N):
                         cchi = xc.number()
                         break
             row = dict()
             row['head'] = "\(\chi_{" + str(N) + "}(" + str(
                 cchi) + ",\cdot) \)"
             row['url'] = url_for('characters.render_Dirichletwebpage',
                                  modulus=N,
                                  number=cchi)
             row['cells'] = list()
             for k in range(wt_ll, wt_ul + 1):
                 if character == 0 and is_odd(k):
                     continue
                 try:
                     if character == 0:
                         d = dimension_fun(N, k)
                     elif character == 1:
                         d = dimension_fun(x, k)
                 except Exception as ex:
                     emf_logger.critical(
                         "Exception: {0}. \n Could not compute the dimension with function {0}"
                         .format(ex, dimension_fun))
                 if (not check_db) or "{0}.{1}.{2}a".format(
                         N, k, cchi
                 ) in list_of_data:  #is_data_in_db(N, k, character):
                     url = url_for('emf.render_elliptic_modular_forms',
                                   level=N,
                                   weight=k,
                                   character=character)
                 else:
                     url = ''
                 if not k in self._table['col_heads']:
                     self._table['col_heads'].append(k)
                 row['cells'].append({'N': N, 'k': k, 'url': url, 'dim': d})
             self._table['rows'].append(row)
         else:
             D = DirichletGroup(N)
             G = D.galois_orbits()
             Greps = [X[0] for X in G]
             Dc = DirichletGroup_conrey(N)
             Gcreps = dict()
             # A security check, if we have at least weight 2 and trivial character,
             # otherwise don't show anything
             #if check_db and not is_data_in_db(N, 2, 0):
             #    emf_logger.debug("No data for level {0} and weight 2, trivial character".format(N)#)
             #self._table = None
             #    return None
             Gc = dict()
             for xi, g in enumerate(G):
                 Gc[xi] = list()
             self._table['maxGalCount'] = 0
             for xc in Dc:
                 x = xc.sage_character()
                 xi = G.index(x.galois_orbit())
                 # emf_logger.debug('Dirichlet Character Conrey {0} = sage_char {1}, has
                 # Galois orbit nr. {2}'.format(xc,x,xi))
                 Gc[xi].append(xc)
                 if x == Greps[xi]:
                     Gcreps[xi] = xc
             emf_logger.debug('Gc={0}'.format(Gc))
             for xi in Gc:
                 g = Gc[xi]
                 if len(g) > self._table['maxGalCount']:
                     self._table['maxGalCount'] = len(g)
                 emf_logger.debug('xi,g={0},{1}'.format(xi, g))
                 x = Greps[xi]
                 xc = Gcreps[xi]
                 cchi = xc.number()
                 row = dict()
                 row['head'] = "\(\chi_{" + str(N) + "}(" + str(
                     cchi) + ",\cdot) \)"
                 row['url'] = url_for('characters.render_Dirichletwebpage',
                                      modulus=N,
                                      number=cchi)
                 row['galois_orbit'] = [{
                     'chi':
                     str(xc.number()),
                     'url':
                     url_for('characters.render_Dirichletwebpage',
                             modulus=N,
                             number=cchi)
                 } for xc in g]
                 row['cells'] = []
                 for k in range(wt_ll, wt_ul + 1):
                     if not k in self._table['col_heads']:
                         # emf_logger.debug("Adding to col_heads:{0}s".format(k))
                         self._table['col_heads'].append(k)
                     try:
                         d = dimension_fun(x, k)
                     except Exception as ex:
                         emf_logger.critical(
                             "Exception: {0} \n Could not compute the dimension with function {1}"
                             .format(ex, dimension_fun))
                     if (not check_db) or "{0}.{1}.{2}a".format(
                             N, k, cchi
                     ) in list_of_data:  #is_data_in_db(N, k, xi):
                         url = url_for('emf.render_elliptic_modular_forms',
                                       level=N,
                                       weight=k,
                                       character=xi)
                     else:
                         url = ''
                     row['cells'].append({
                         'N': N,
                         'k': k,
                         'chi': xi,
                         'url': url,
                         'dim': d
                     })
                 self._table['rows'].append(row)
     else:
         for k in range(wt_ll, wt_ul + 1):
             if character == 0 and is_odd(k):
                 continue
             row = []
             for N in range(level_ll, level_ul + 1):
                 if not N in self._table['col_heads']:
                     self._table['col_heads'].append(N)
                 try:
                     if character == 0:
                         d = dimension_fun(N, k)
                     elif character == 1:
                         x = kronecker_character_upside_down(N)
                         d = dimension_fun(x, k)
                     else:
                         d = dimension_fun(N, k)
                 except Exception as ex:
                     emf_logger.critical(
                         "Exception: {0}. \n Could not compute the dimension with function {0}"
                         .format(ex, dimension_fun))
                 # emf_logger.debug("N,k,char,dim: {0},{1},{2},{3}".format(N,k,character,d))
                 if character == 0 or character == 1:
                     if (not check_db) or "{0}.{1}.{2}a".format(
                             N, k, 1
                     ) in list_of_data:  #is_data_in_db(N, k, character):
                         url = url_for('emf.render_elliptic_modular_forms',
                                       level=N,
                                       weight=k,
                                       character=character)
                     else:
                         url = ''
                 else:
                     t1 = "{0}.{1}.{2}a".format(N, k, 1)
                     t2 = "{0}.{1}.{2}a".format(N, k, 2)
                     if (
                             not check_db
                     ) or t1 in list_of_data or t2 in list_of_data:  # is_data_in_db(N, k, character):
                         url = url_for('emf.render_elliptic_modular_forms',
                                       level=N,
                                       weight=k)
                     else:
                         url = ''
                 if not k in self._table['row_heads']:
                     self._table['row_heads'].append(k)
                 row.append({'N': N, 'k': k, 'url': url, 'dim': d})
             emf_logger.debug("row:{0}".format(row))
             self._table['rows'].append(row)