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.codelangs = ('pari', 'sage') @lazy_attribute def conductor(self): return self.chi.conductor() @lazy_attribute def indlabel(self): if self.chi.indlabel is not None: return self.chi.indlabel else: # Calling conductor computes the indlabel self.chi.conductor() return self.chi.indlabel @lazy_attribute def codeinit(self): return { 'sage': [ 'H = DirichletGroup(%i)'%(self.modulus), 'chi = H[%i]'%(self.number) ], 'pari': '[g,chi] = znchar(Mod(%i,%i))'%(self.number,self.modulus), } @lazy_attribute def title(self): return r"Dirichlet character %s" % (self.texname) @lazy_attribute def texname(self): return self.char2tex(self.modulus, self.number) @lazy_attribute def codeisprimitive(self): return { 'sage': 'chi.is_primitive()', 'pari': '#znconreyconductor(g,chi)==1 \\\\ if not primitive returns [cond,factorization]' } @lazy_attribute def codecond(self): return { 'sage': 'chi.conductor()', 'pari': 'znconreyconductor(g,chi)' } @lazy_attribute def parity(self): return (parity_string(-1),parity_string(1))[self.chi.is_even()] @lazy_attribute def codeparity(self): return { 'sage': 'chi.is_odd()', 'pari': 'zncharisodd(g,chi)' } 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()) @lazy_attribute def symbol(self): return kronecker_symbol(self.symbol_numerator()) @lazy_attribute def codesymbol(self): m = self.symbol_numerator() if m: return { 'sage': 'kronecker_character(%i)'%m, 'pari': 'znchartokronecker(g,chi)' } return None @lazy_attribute def codegaloisorbit(self): return { 'sage': ['chi.galois_orbit()'], 'pari': [ 'order = charorder(g,chi)', '[ charpow(g,chi, k % order) | k <-[1..order-1], gcd(k,order)==1 ]' ] }
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
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