Exemplo n.º 1
0
 def is_consistent(self,k):
     r"""
     Return True if the Weil representation is a multiplier of weight k.
     """
     if self._verbose>0:
         print "is_consistent at wr! k={0}".format(k)
     twok =QQ(2)*QQ(k)
     if not twok.is_integral():
         return False
     if self._sym_type <>0:
         if self.is_dual():
             sig_mod_4 = -self._weil_module.signature() % 4
         else:
             sig_mod_4 = self._weil_module.signature() % 4
         if is_odd(self._weil_module.signature()):                
             return (twok % 4 == (self._sym_type*sig_mod_4 %4))
         else:
             if sig_mod_4 == (1 - self._sym_type) % 4:
                 return twok % 4 == 0
             else:
                 return twok % 4 == 2
     if is_even(twok) and  is_even(self._weil_module.signature()):
             return True
     if is_odd(twok) and  is_odd(self._weil_module.signature()):
             return True
     return False
Exemplo n.º 2
0
def eta_argument(a,b,c,d):
    res = (a+d)*c-b*d*(c*c-1)
    den = 24
    if is_odd(c):
        return res-3*c,den,kronecker(d,c)
    else:
        return res+3*d-3-3*c*d,den,kronecker(d,c)
Exemplo n.º 3
0
 def conductor(self):
     """ Computes the conductor if the extension is abelian.
         It raises an exception if the field is not abelian.
     """
     if not self.is_abelian():
         raise Exception('Invalid field for conductor')
     D = self.disc()
     plist = self.ramified_primes()
     K = self.K()
     f = ZZ(1)
     for p in plist:
         e = K.factor(p)[0][0].ramification_index()
         if p == ZZ(2):
             e = K.factor(p)[0][0].ramification_index()
             # ramification index must be a power of 2
             f *= e * 2
             c = D.valuation(p)
             res_deg = ZZ(self.degree() / e)
             # adjust disc expo for unramified part
             c = ZZ(c / res_deg)
             if is_odd(c):
                 f *= 2
         else:
             f *= p ** (e.valuation(p) + 1)
     return f
Exemplo n.º 4
0
def render_search_results_wp(info, search):
    # res contains a lst of Maass waveforms
    print "info=", info
    print "Search:", search
    res = search_for_eigenvalues(search)
    print "res=", res
    s = "<table><tr>"
    if search.has_key("more"):
        info["more"] = search["more"]
        if info["more"]:
            info["rec_start"] = search["rec_start"] + search["limit"]
            info["limit"] = search["limit"]
    for name in res.keys():
        if len(res[name]) == 0 or name == "weights":
            continue
        s += '<td valign="top">'
        s += '<table class="ntdata"><thead>'
        s += " <tr><td>Collection:" + name
        s += "     </td></tr>"
        s += "<tr><td>R</td><td>Level</td>\n"
        if len(res["weights"]) > 1:
            s += "<td>Weight</td>\n"
            s += "<td>Character</td>\n"
        s + "</tr></thead>"
        s += "<tbody>"
        i = 0
        for rec in res[name]:
            print "rec=", rec
            R = my_get(rec, "Eigenvalue", None)
            N = my_get(rec, "Level", "", str)
            k = my_get(rec, "Weight", "", str)
            ch = my_get(rec, "character", "", str)
            id = rec["_id"]
            if is_odd(i):
                cl = "odd"
            else:
                cl = "even"
            i += 1
            url = url_for("mwf.render_one_maass_waveform", id=str(id), db=name)
            if len(res["weights"]) > 1:
                s += (
                    '<tr class="%s"><td><a href="%s">%s</a></td><td align="center">%s</td><td>%s</td><td>%s</td></tr>\n'
                    % (cl, url, R, N, k, ch)
                )
            else:
                s += '<tr class="%s"><td><a href="%s">%s</a></td><td align="center">%s</td></tr>\n' % (cl, url, R, N)
        s += "</tbody>"
        s += "</table>"
        s += "</td>"
    s += "</tr></table>"
    # print "S=",s
    info["table_of_eigenvalues"] = s
    title = "Maass Forms"
    bread = [("Maass waveforms", url_for(".render_maass_waveforms"))]
    return render_template("mwf_display_search_result.html", info=info, title=title, search=search, bread=bread)
Exemplo n.º 5
0
def prime_range(n):
    X = [x for x in range(3, n + 1) if is_odd(x)]
    P = [2]

    p = X[0]
    while p <= sqrt(n):
        P.append(p)
        X = [x for x in X if x % p != 0]
        p = X[0]

    P.extend(X)

    return P
Exemplo n.º 6
0
def dimension_table_Sp4Z_j(wt_range, j_range):
    result = {}
    for wt in wt_range:
        result[wt] = {}
    for j in j_range:
        if is_odd(j):
            for wt in wt_range:
                result[wt][j]=0
        else:
            _,olddim= dimension_Sp4Z_j(wt_range, j)
            for wt in wt_range:
                result[wt][j]=olddim[wt]['Total']
    return result
Exemplo n.º 7
0
    def dirichlet_group(self, prime_bound=10000):
        f = self.conductor()
        if f == 1:  # To make the trivial case work correctly
            return [1]
        if euler_phi(f) > dir_group_size_bound:
            return []
        # Can do quadratic fields directly
        if self.degree() == 2:
            if is_odd(f):
                return [1, f-1]
            f1 = f/4
            if is_odd(f1):
                return [1, f-1]
            # we now want f with all powers of 2 removed
            f1 = f1/2
            if is_even(f1):
                raise Exception('Invalid conductor')
            if (self.disc()/8) % 4 == 3:
                return [1, 4*f1-1]
            # Finally we want congruent to 5 mod 8 and -1 mod f1
            if (f1 % 4) == 3:
                return [1, 2*f1-1]
            return [1, 6*f1-1]

        from dirichlet_conrey import DirichletGroup_conrey
        G = DirichletGroup_conrey(f)
        K = self.K()
        S = Set(G[1].kernel()) # trivial character, kernel is whole group

        for P in K.primes_of_bounded_norm_iter(ZZ(prime_bound)):
            a = P.norm() % f
            if gcd(a,f)>1:
                continue
            S = S.intersection(Set(G[a].kernel()))
            if len(S) == self.degree():
                return list(S)

        raise Exception('Failure in dirichlet group for K=%s using prime bound %s' % (K,prime_bound))
Exemplo n.º 8
0
def test_real_quadratic(minp=1,maxp=100,minwt=2,maxwt=1000):
    for p in prime_range(minp,maxp):
        if p%4==1:
            print "p = ", p
            gram=Matrix(ZZ,2,2,[2,1,1,(1-p)/2])
            M=VectorValuedModularForms(gram)
            if is_odd(minwt):
                minwt=minwt+1
            for kk in range(minwt,round(maxwt/2-minwt)):
                k = minwt+2*kk
                if M.dimension_cusp_forms(k)-dimension_cusp_forms(kronecker_character(p),k)/2 != 0:
                    print "ERROR: ", k, M.dimension_cusp_forms(k), dimension_cusp_forms(kronecker_character(p),k)/2
                    return False
    return true
Exemplo n.º 9
0
def dimension_Gamma0_4_psi_4(wt_range):
    """
    <ul>
      <li><span class="emph">Total</span>: The full space.</li>
    </ul>
    <p> Odd weights are not yet implemented.</p>
    """
    headers = ['Total']
    dct = dict()
    for k in wt_range:
        if is_odd(k): continue
        dims =  _dimension_Gamma0_4_psi_4(k)
        dct[k] = dict((headers[j],dims[j]) for j in range(len(headers)))
    return headers, dct
Exemplo n.º 10
0
    def xi(self,A):
        r""" The eight-root of unity in front of the Weil representation.

        INPUT:
        
        -''N'' -- integer
        -''A'' -- element of PSL(2,Z)

        EXAMPLES::

        
            sage: A=SL2Z([41,77,33,62])
            sage: WR.xi(A)
            -zeta8^3]
            sage: S,T=SL2Z.gens()
            sage: WR.xi(S)
            -zeta8^3
            sage: WR.xi(T)
            1
            sage: A=SL2Z([-1,1,-4,3])
            sage: WR.xi(A)
            -zeta8^2
            sage: A=SL2Z([0,1,-1,0])
            sage: WR.xi(A)
            -zeta8

        """
        a=Integer(A[0,0]); b=Integer(A[0,1])
        c=Integer(A[1,0]); d=Integer(A[1,1])
        if(c==0):
            return 1
        z=CyclotomicField(8).gen()    
        N=self._N
        N2=odd_part(N)
        Neven=ZZ(2*N).divide_knowing_divisible_by(N2)
        c2=odd_part(c)
        Nc=gcd(Integer(2*N),Integer(c))
        cNc=ZZ(c).divide_knowing_divisible_by(Nc)
        f1=kronecker(-a,cNc)
        f2=kronecker(cNc,ZZ(2*N).divide_knowing_divisible_by(Nc))
        if(is_odd(c)):
            s=c*N2
        elif( c % Neven == 0):
            s=(c2+1-N2)*(a+1)
        else:
            s=(c2+1-N2)*(a+1)-N2*a*c2
        r=-1-QQ(N2)/QQ(gcd(c,N2))+s
        xi=f1*f2*z**r
        return xi
Exemplo n.º 11
0
def eta_conjugated(a,b,c,d,l):
    r"""
    Gives eta(V_l A V_l^-1) with A=(a,b,c,d) for c>0
    """
    assert c>=0 and (c%l)==0
    if l<>1:
        cp = QQ(c)/QQ(l)
        bp = QQ(b)*QQ(l)
    else:
        cp=c; bp=b
    if c==0:
        l*bp,1
    res = (a+d)*cp-bp*d*(cp*cp-1)
    if is_odd(c):
        return res-3*cp,kronecker(d,cp)
    else:
        return res+3*d-3-3*cp*d,kronecker(cp,d)
Exemplo n.º 12
0
def test_jacobi(index=1,minwt=4,maxwt=100,eps=-1):
    m=index
    gram=Matrix(ZZ,1,1,[-eps*2*m])
    M=VectorValuedModularForms(gram)
    if is_odd(minwt):
        minwt=minwt+1
    for kk in range(0,round(maxwt/2-minwt)+2):
        k = minwt+2*kk+(1+eps)/2
        print "Testing k = ", k
        if eps==-1:
            dimJ=dimension_jac_forms(k,m,-1)
            dimV=M.dimension(k-1/2)
        else:
            dimJ=dimension_jac_cusp_forms(k,m,1)
            dimV=M.dimension_cusp_forms(k-1/2)
        if dimJ-dimV != 0:
            print "ERROR: ", k, dimJ, dimV
            return False
    return true
Exemplo n.º 13
0
def crack_given_decrypt(n, m):
    n = Integer(n)
    m = Integer(m)

    while True:
        if is_odd(m):
            break
        divide_out = True
        for _ in range(5):
            a = randrange(1, n)
            if gcd(a, n) == 1:
                if Mod(a, n) ** (m // 2) != 1:
                    divide_out = False
                    break
        if divide_out:
            m //= 2
        else:
            break

    while True:
        a = randrange(1, n)
        g = gcd(lift(Mod(a, n) ** (m // 2)) - 1, n)
        if g != 1 and g != n:
            return g
Exemplo n.º 14
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
     else:
         def is_data_in_db(N, k, character):
             return False
     # 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:
                 xc = DirichletGroup_conrey(N)[1]
             else:
                 D = DirichletGroup_conrey(N)
                 for xc in D:
                     if xc.sage_character() == kronecker_character_upside_down(N):
                         break
             x = xc.sage_character()
             row = dict()
             row['head'] = "\(\chi_{" + str(N) + "}(" + str(xc.number()) + ",\cdot) \)"
             row['url'] = url_for("render_Character", arg1=N, arg2=xc.number())
             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 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]
                 row = dict()
                 row['head'] = "\(\chi_{" + str(N) + "}(" + str(xc.number()) + ",\cdot) \)"
                 row['url'] = url_for("render_Character", arg1=N, arg2=xc.number())
                 row['galois_orbit'] = [
                     {'chi': str(xc.number()),
                      'url': url_for("render_Character", arg1=N, arg2=xc.number())}
                     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 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 is_data_in_db(N, k, character):
                         url = url_for(
                             'emf.render_elliptic_modular_forms', level=N, weight=k, character=character)
                     else:
                         url = ''
                 else:
                     url = url_for('emf.render_elliptic_modular_forms', level=N, weight=k)
                 if not k in self._table['row_heads']:
                     self._table['row_heads'].append(k)
                 row.append({'N': N, 'k': k, 'url': url, 'dim': d})
             self._table['rows'].append(row)
Exemplo n.º 15
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)            
Exemplo n.º 16
0
def _dimension_Gamma_2(wt_range, j, group='Gamma(2)'):
    """
    Return the dict
    {(k-> partition ->  [ d(k), e(k), c(k)] for k in wt_range]},
    where d(k), e(k), c(k) are the dimensions
    of the $p$-canonical part of $M_{k,j}(\Gamma(2))$ and its subspaces of
    Non-cusp forms and Cusp forms.
    """

    partitions = [
        u'6', u'51', u'42', u'411', u'33', u'321', u'3111', u'222', u'2211',
        u'21111', u'111111'
    ]
    latex_names = {
        'Gamma(2)': '\\Gamma(2)',
        'Gamma0(2)': '\\Gamma_0(2)',
        'Gamma1(2)': '\\Gamma_1(2)',
        'Sp4(Z)': '\\mathrm{Sp}(4,\mathbb{Z})'
    }

    if is_odd(j):
        dct = dict(
            (k, dict((h, [0, 0, 0]) for h in partitions)) for k in wt_range)
        for k in dct:
            dct[k]['All'] = [0, 0, 0]
        partitions.insert(0, 'All')
        return partitions, dct

    if 'Sp4(Z)' == group and 2 == j and wt_range[0] < 4:
        wt_range1 = [k for k in wt_range if k < 4]
        wt_range2 = [k for k in wt_range if k >= 4]
        if wt_range2 != []:
            headers, dct = _dimension_Gamma_2(wt_range2, j, group)
        else:
            headers, dct = ['Total', 'Non cusp', 'Cusp'], {}
        for k in wt_range1:
            dct[k] = dict([(h, 0) for h in headers])
        return headers, dct

    if j >= 2 and wt_range[0] < 4:
        raise NotImplementedError(
            "Dimensions of \(M_{k,j}(%s)\) for <span style='color:black'>\(k<4\)</span> and <span style='color:black'>\(j\ge 2\)</span> not implemented"
            % latex_names.get(group, group))

    query = {'sym_power': str(j), 'group': 'Gamma(2)', 'space': 'total'}
    db_total = db.smf_dims.lucky(query)
    if not db_total:
        raise NotImplementedError(
            'Dimensions of \(M_{k,j}\) for \(j=%d\) not implemented' % j)
    query['space'] = 'cusp'
    db_cusp = db.smf_dims.lucky(query)
    if not db_cusp:
        raise NotImplementedError(
            'Dimensions of \(M_{k,j}\) for \(j=%d\) not implemented' % j)

    P = PowerSeriesRing(ZZ, default_prec=wt_range[-1] + 1, names=('t'))
    Qt = FunctionField(QQ, names=('t'))
    total = dict()
    cusp = dict()
    for p in partitions:
        f = Qt(str(db_total[p]))
        total[p] = P(f.numerator()) / P(f.denominator())
        f = Qt(str(db_cusp[p]))
        cusp[p] = P(f.numerator()) / P(f.denominator())

    if 'Gamma(2)' == group:
        dct = dict(
            (k,
             dict((p, [total[p][k], total[p][k] - cusp[p][k], cusp[p][k]])
                  for p in partitions)) for k in wt_range)
        for k in dct:
            dct[k]['All'] = [
                sum(dct[k][p][i] for p in dct[k]) for i in range(3)
            ]

        partitions.insert(0, 'All')
        headers = partitions

    elif 'Gamma1(2)' == group:
        ps = {
            '3': ['6', '42', '222'],
            '21': ['51', '42', '321'],
            '111': ['411', '33']
        }

        dct = dict((k,
                    dict((p, [
                        sum(total[q][k] for q in ps[p]),
                        sum(total[q][k] - cusp[q][k] for q in ps[p]),
                        sum(cusp[q][k] for q in ps[p]),
                    ]) for p in ps)) for k in wt_range)
        for k in dct:
            dct[k]['All'] = [
                sum(dct[k][p][i] for p in dct[k]) for i in range(3)
            ]

        headers = ps.keys()
        headers.sort(reverse=True)
        headers.insert(0, 'All')

    elif 'Gamma0(2)' == group:
        headers = ['Total', 'Non cusp', 'Cusp']
        ps = ['6', '42', '222']
        dct = dict((k, {
            'Total': sum(total[p][k] for p in ps),
            'Non cusp': sum(total[p][k] - cusp[p][k] for p in ps),
            'Cusp': sum(cusp[p][k] for p in ps)
        }) for k in wt_range)

    elif 'Sp4(Z)' == group:
        headers = ['Total', 'Non cusp', 'Cusp']
        p = '6'
        dct = dict((k, {
            'Total': total[p][k],
            'Non cusp': total[p][k] - cusp[p][k],
            'Cusp': cusp[p][k]
        }) for k in wt_range)
    else:
        raise NotImplementedError('Dimension for %s not implemented' % group)

    return headers, dct
Exemplo n.º 17
0
class VectorValuedModularForms(SageObject):
    r"""
    Class representing a space of vector valued modular forms
    transforming with the Weil representation of a discriminant module.


    EXAMPLES:

        As input we use any input that one can use for a finite quadratic module.

        (For instance a genus symbol.)

        ::

            sage: V=VectorValuedModularForms('2_7^+1.3^-2')
            sage: V
            Vector valued modular forms for the Weil representation corresponding to: 
            Finite quadratic module in 3 generators:
            gens: e0, e1, e2
            form: 3/4*x0^2 + 2/3*x1^2 + 1/3*x2^2

    SEE ALSO:

        :class:`psage.modules.finite_quadratic_modules.FiniteQuadraticModule`
    """
    def __init__(self,
                 A,
                 use_genus_symbols=False,
                 aniso_formula=False,
                 use_reduction=False):
        try:
            from sfqm.fqm.genus_symbol import GenusSymbol
        except ImportError, e:
            print e
            use_genus_symbols = False
            print "Not using genus symbols."
        self._use_reduction = use_reduction
        if use_genus_symbols:
            if isinstance(A, str):
                g = GenusSymbol(A)
            else:
                try:
                    g = GenusSymbol(A.jordan_decomposition().genus_symbol())
                except:
                    raise ValueError
            self._g = g
            n2 = self._n2 = g.torsion(2)
            self._v2 = g.two_torsion_values()
            self._M = None
            self._aniso_formula = aniso_formula
        else:
            self._M = FiniteQuadraticModule(A)
            self._g = None
            self._level = self._M.level()
            self._aniso_formula = False
            if is_odd(self._M.order()):
                self._n2 = n2 = 1
                self._v2 = {0: 1}
            else:
                self._M2 = M2 = self._M.kernel_subgroup(2).as_ambient()[0]
                self._n2 = n2 = self._M2.order()
                self._v2 = self._M2.values()

        if use_genus_symbols:
            self._signature = g.signature()
            m = g.order()
        else:
            self._signature = self._M.signature()
            m = self._M.order()

        self._m = m
        self._alpha3 = None
        self._alpha4 = None
Exemplo n.º 18
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
     else:
         def is_data_in_db(N, k, character):
             return False
     # 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:
                 xc = DirichletGroup_conrey(N)[1]
             else:
                 D = DirichletGroup_conrey(N)
                 for xc in D:
                     if xc.sage_character() == kronecker_character_upside_down(N):
                         break
             x = xc.sage_character()
             row = dict()
             row['head'] = "\(\chi_{" + str(N) + "}(" + str(xc.number()) + ",\cdot) \)"
             row['url'] = url_character(type='Dirichlet', modulus=N, number=xc.number())
             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 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]
                 row = dict()
                 row['head'] = "\(\chi_{" + str(N) + "}(" + str(xc.number()) + ",\cdot) \)"
                 row['url'] = url_character(type='Dirichlet', modulus=N, number=xc.number())
                 row['galois_orbit'] = [
                     {'chi': str(xc.number()),
                      'url': url_character(type='Dirichlet', modulus=N, number=xc.number()) }
                     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 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 is_data_in_db(N, k, character):
                         url = url_for(
                             'emf.render_elliptic_modular_forms', level=N, weight=k, character=character)
                     else:
                         url = ''
                 else:
                     url = url_for('emf.render_elliptic_modular_forms', level=N, weight=k)
                 if not k in self._table['row_heads']:
                     self._table['row_heads'].append(k)
                 row.append({'N': N, 'k': k, 'url': url, 'dim': d})
             self._table['rows'].append(row)
Exemplo n.º 19
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)
Exemplo n.º 20
0
def _dimension_Gamma_2(wt_range, j, group = 'Gamma(2)'):
    """
    Return the dict
    {(k-> partition ->  [ d(k), e(k), c(k)] for k in wt_range]},
    where d(k), e(k), c(k) are the dimensions
    of the $p$-canonical part of $M_{k,j}(\Gamma(2))$ and its subspaces of
    Non-cusp forms and Cusp forms.
    """

    partitions = [ u'6', u'51', u'42', u'411', u'33', u'321', u'3111', u'222', u'2211', u'21111', u'111111']
    latex_names = { 'Gamma(2)':'\\Gamma(2)', 'Gamma0(2)':'\\Gamma_0(2)', 'Gamma1(2)':'\\Gamma_1(2)', 'Sp4(Z)':'\\mathrm{Sp}(4,\mathbb{Z})' }

    if is_odd(j):
        dct = dict((k,dict((h,[0,0,0]) for h in partitions)) for k in wt_range)
        for k in dct:
            dct[k]['All'] = [0,0,0]
        partitions.insert(0,'All')
        return partitions, dct

    if 'Sp4(Z)' == group and 2 == j and wt_range[0] < 4:
        wt_range1 = [ k for k in wt_range if k < 4]
        wt_range2 = [ k for k in wt_range if k >= 4]
        if wt_range2 != []: 
            headers, dct = _dimension_Gamma_2(wt_range2, j, group)
        else:
            headers, dct = ['Total', 'Non cusp', 'Cusp'], {}
        for k in wt_range1:
            dct[k] = dict([(h,0) for h in headers])
        return headers, dct
    
    if j>=2 and  wt_range[0] < 4:
        raise NotImplementedError("Dimensions of \(M_{k,j}(%s)\) for <span style='color:black'>\(k<4\)</span> and <span style='color:black'>\(j\ge 2\)</span> not implemented" % latex_names.get(group,group))

    query = { 'sym_power': str(j), 'group' : 'Gamma(2)', 'space': 'total' }
    db_total = db.smf_dims.lucky(query)
    if not db_total:
        raise NotImplementedError('Dimensions of \(M_{k,j}\) for \(j=%d\) not implemented' % j)
    query['space'] = 'cusp'
    db_cusp = db.smf_dims.lucky(query)
    if not db_cusp:
        raise NotImplementedError('Dimensions of \(M_{k,j}\) for \(j=%d\) not implemented' % j)
    
    P = PowerSeriesRing(ZZ,  default_prec =wt_range[-1] + 1,  names = ('t'))
    Qt = FunctionField(QQ, names=('t'))
    total = dict()
    cusp = dict()
    for p in partitions:
        f = Qt(str(db_total[p]))
        total[p] = P(f.numerator())/P(f.denominator())
        f = Qt(str(db_cusp[p]))
        cusp[p] = P(f.numerator())/P(f.denominator())
    
    if 'Gamma(2)' == group:
        dct = dict((k, dict((p, [total[p][k], total[p][k]-cusp[p][k], cusp[p][k]])
                              for p in partitions)) for k in wt_range)
        for k in dct:
            dct[k]['All'] = [sum(dct[k][p][i] for p in dct[k]) for i in range(3)]
            
        partitions.insert(0,'All')
        headers = partitions

    elif 'Gamma1(2)' == group:
        ps = { '3': ['6', '42', '222'],
               '21': ['51', '42', '321'],
               '111': ['411', '33']}
        
        dct = dict((k, dict((p,[
                            sum(total[q][k] for q in ps[p]),
                            sum(total[q][k]-cusp[q][k] for q in ps[p]),
                            sum(cusp[q][k] for q in ps[p]),
                            ]) for p in ps)) for k in wt_range) 
        for k in dct:
            dct[k]['All'] = [sum(dct[k][p][i] for p in dct[k]) for i in range(3)]       

        headers = ps.keys()
        headers.sort(reverse = True)
        headers.insert(0,'All')

    elif 'Gamma0(2)' == group:
        headers = ['Total', 'Non cusp', 'Cusp']
        ps = ['6', '42', '222']
        dct = dict((k, { 'Total': sum(total[p][k] for p in ps),
                          'Non cusp': sum(total[p][k]-cusp[p][k] for p in ps),
                          'Cusp': sum(cusp[p][k] for p in ps)})
                    for k in wt_range)

    elif 'Sp4(Z)' == group:
        headers = ['Total', 'Non cusp', 'Cusp']
        p = '6'
        dct = dict((k, { 'Total': total[p][k],
                          'Non cusp': total[p][k]-cusp[p][k],
                          'Cusp': cusp[p][k]})
                    for k in wt_range)
    else:
        raise NotImplementedError('Dimension for %s not implemented' % group)

    return headers, dct