def check_order_parity(self, rec, verbose=False): """ check order and parity by constructing a Conrey character in Sage (use the first index in galois_orbit) """ # TIME about 30000s for full table char = ConreyCharacter(rec['modulus'], rec['galois_orbit'][0]) parity = 1 if char.is_even() else -1 success = (parity == rec['parity'] and char.conductor() == rec['conductor'] and char.multiplicative_order() == rec['order']) if verbose and not success: print("Order-parity failure", parity, rec['parity'], char.conductor(), rec['conductor'], char.multiplicative_order(), rec['order']) return success
def get_character_modulus(a, b, limit=7): """ this function is also used by lfunctions/LfunctionPlot.py """ headers = list(range(1, limit)) headers.append("more") entries = {} rows = list(range(a, b + 1)) for row in rows: if row != 1: G = Integers(row).list_of_elements_of_multiplicative_group() else: G = [1] for chi_n in G: chi = ConreyCharacter(row, chi_n) multorder = chi.multiplicative_order() if multorder <= limit: el = chi col = multorder entry = entries.get((row, col), []) entry.append(el) entries[(row, col)] = entry entries2 = {} out = lambda chi: (chi.number, chi.is_primitive(), chi.multiplicative_order(), chi.is_even()) for k, v in entries.items(): l = [] v = sorted(v, key=lambda x: x.number) while v: e1 = v.pop(0) e1_num = e1.number inv_num = 1 if e1_num == 1 else e1_num.inverse_mod(e1.modulus) inv = ConreyCharacter(e1.modulus, inv_num) if e1_num == inv_num: l.append((out(e1), )) else: l.append((out(e1), out(inv))) v = [ x for x in v if (x.modulus, x.number) != (inv.modulus, inv.number) ] if k[1] == "more": l = sorted(l, key=lambda e: e[0][2]) entries2[k] = l cols = headers return headers, entries2, rows, cols
class WebSmallDirichletCharacter(WebChar, WebDirichlet): """ Heritage: WebChar -> __init__() WebDirichlet -> _compute() """ def _compute(self): self.modulus = int(self.modlabel) self.number = int(self.numlabel) self.chi = ConreyCharacter(self.modulus, self.number) self.credit = '' self.codelangs = ('pari', 'sage') @property def conductor(self): return self.chi.conductor() @property def previous(self): return None @property def next(self): return None @property def genvalues(self): return None @property def indlabel(self): return None def value(self, *args): return None def charsums(self, *args): return False def gauss_sum(self, *args): return None def jacobi_sum(self, *args): return None def kloosterman_sum(self, *args): return None @property def codeinit(self): return { 'sage': [ 'from dirichlet_conrey import DirichletGroup_conrey # requires nonstandard Sage package to be installed', 'H = DirichletGroup_conrey(%i)'%(self.modulus), 'chi = H[%i]'%(self.number) ], 'pari': '[g,chi] = znchar(Mod(%i,%i))'%(self.number,self.modulus), } @property def title(self): return r"Dirichlet Character %s" % (self.texname) @property def texname(self): return self.char2tex(self.modulus, self.number) @property def codeisprimitive(self): return { 'sage': 'chi.is_primitive()', 'pari': '#znconreyconductor(g,chi)==1 \\\\ if not primitive returns [cond,factorization]' } @property def codecond(self): return { 'sage': 'chi.conductor()', 'pari': 'znconreyconductor(g,chi)' } @property def parity(self): return ('Odd', 'Even')[self.chi.is_even()] @property def codeparity(self): return { 'sage': 'chi.is_odd()', 'pari': 'zncharisodd(g,chi)' } @property def galoisorbit(self): order = self.order mod, num = self.modulus, self.number prim = self.isprimitive #beware this **must** be a generator orbit = ( power_mod(num, k, mod) for k in xsrange(1, order) if gcd(k, order) == 1) # use xsrange not xrange return ( self._char_desc(num, prim=prim) for num in orbit ) def symbol_numerator(self): """ chi is equal to a kronecker symbol if and only if it is real """ if self.order != 2: return None return symbol_numerator(self.conductor, self.chi.is_odd()) @property def symbol(self): return kronecker_symbol(self.symbol_numerator()) @property def codesymbol(self): m = self.symbol_numerator() if m: return { 'sage': 'kronecker_character(%i)'%m } return None @property def codegaloisorbit(self): return { 'sage': 'chi.sage_character().galois_orbit()', 'pari': [ 'order = charorder(g,chi)', '[ charpow(g,chi, k % order) | k <-[1..order-1], gcd(k,order)==1 ]' ] }
def set_info_for_gamma1(level,weight,weight2=None): dimension_table_name = WebModFormSpace._dimension_table_name if weight != None and weight2>weight: w1 = weight; w2 = weight2 else: w1 = weight; w2 = weight table = {'galois_orbit':{},'galois_orbits_reps':{},'cells':{}} table['weights']=range(w1,w2+1) emf_logger.debug("dimension table name={0}".format(dimension_table_name)) db_dim = getDBConnection()['modularforms2'][dimension_table_name] s = {'level':int(level),'weight':{"$lt":int(w2+1),"$gt":int(w1-1)},'cchi':{"$exists":True}} q = db_dim.find(s).sort([('cchi',int(1)),('weight',int(1))]) if q.count() == 0: emf_logger.debug("No spaces in the database!") flash('The database does not currently contain any spaces matching these parameters. Please try again!') return None #'error':'The database does not currently contain any spaces matching these parameters!'} else: table['maxGalCount']=1 for r in q: xi = r['cchi'] orbit = r['character_orbit'] k = r['weight'] ## This is probably still quicker if it is in the database parity = r.get('character_parity','n/a') if parity == 'n/a': chi = ConreyCharacter(level,xi) if chi.is_odd(): parity = -1 elif chi.is_even(): parity = 1 else: emf_logger.critical("Could not determine the parity of ConreyCharacter({0},{1})".format(xi,level)) trivial_trivially = "" if parity != 'n/a': if k % 2 == (1 + parity)/2: # is space empty because of parity? trivial_trivially = "yes" else: trivial_trivially = "" if parity == 1: parity = 'even' elif parity == -1: parity = 'odd' d = r.get('d_newf',"n/a") indb = r.get('in_wdb',0) if d == 0: indb = 1 if indb: url = url_for('emf.render_elliptic_modular_forms', level=level, weight=k, character=xi) else: url = '' if not table['galois_orbits_reps'].has_key(xi): table['galois_orbits_reps'][xi]={ 'head' : "\(\chi_{{{0}}}({1},\cdot) \)".format(level,xi), # yes, {{{ is required 'chi': "{0}".format(xi), 'url': url_for('characters.render_Dirichletwebpage', modulus=level, number=xi), 'parity':parity} table['galois_orbit'][xi]= [ { #'head' : "\(\chi_{{{0}}}({1},\cdot) \)".format(level,xci), # yes, {{{ is required ## 'head' : "\(S_{{{0}}}({1},\chi({2}, \cdot) ) \)".format(weight,level,xci), # yes, {{{ is required ## 'head' : "\(S_{{{0}}}(\chi({1}, \cdot) ) \)".format(weight,xci), # yes, {{{ is required 'head' : r"\(S_{{{0}}}(\chi_{{{1}}}({2}, \cdot)) \)".format(weight,level,xci), # yes, {{{ is required # 'head' : "\({0}\)".format(xci), 'chi': "{0}".format(xci), # 'url': url_for('characters.render_Dirichletwebpage', modulus=level, number=xci) 'url': url_for('emf.render_elliptic_modular_forms', level=level, weight=k, character=xci) if indb else '' } for xci in orbit] if len(orbit)>table['maxGalCount']: table['maxGalCount']=len(orbit) table['cells'][xi]={} table['cells'][xi][k] ={'N': level, 'k': k, 'chi': xi, 'url': url, 'dim': d, 'trivial_trivially': trivial_trivially,} table['galois_orbits_reps_numbers']=table['galois_orbits_reps'].keys() table['galois_orbits_reps_numbers'].sort() #emf_logger.debug("Table:{0}".format(table)) return table