本文整理汇总了Python中lmfdb.WebNumberField.WebNumberField类的典型用法代码示例。如果您正苦于以下问题:Python WebNumberField类的具体用法?Python WebNumberField怎么用?Python WebNumberField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebNumberField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download_hmf_magma
def download_hmf_magma(**args):
label = str(args['label'])
f = get_hmf(label)
if f is None:
return "No such form"
F = WebNumberField(f['field_label'])
F_hmf = get_hmf_field(f['field_label'])
hecke_pol = f['hecke_polynomial']
hecke_eigs = f['hecke_eigenvalues']
AL_eigs = f['AL_eigenvalues']
outstr = 'P<x> := PolynomialRing(Rationals());\n'
outstr += 'g := P!' + str(F.coeffs()) + ';\n'
outstr += 'F<w> := NumberField(g);\n'
outstr += 'ZF := Integers(F);\n\n'
# outstr += 'ideals_str := [' + ','.join([st for st in F_hmf["ideals"]]) + '];\n'
# outstr += 'ideals := [ideal<ZF | {F!x : x in I}> : I in ideals_str];\n\n'
outstr += 'NN := ideal<ZF | {' + f["level_ideal"][1:-1] + '}>;\n\n'
outstr += 'primesArray := [\n' + ','.join([st for st in F_hmf["primes"]]).replace('],[', '],\n[') + '];\n'
outstr += 'primes := [ideal<ZF | {F!x : x in I}> : I in primesArray];\n\n'
if hecke_pol != 'x':
outstr += 'heckePol := ' + hecke_pol + ';\n'
outstr += 'K<e> := NumberField(heckePol);\n'
else:
outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n'
outstr += '\nheckeEigenvaluesArray := [' + ', '.join([st for st in hecke_eigs]) + '];'
outstr += '\nheckeEigenvalues := AssociativeArray();\n'
outstr += 'for i := 1 to #heckeEigenvaluesArray do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesArray[i];\nend for;\n\n'
outstr += 'ALEigenvalues := AssociativeArray();\n'
for s in AL_eigs:
outstr += 'ALEigenvalues[ideal<ZF | {' + s[0][1:-1] + '}>] := ' + s[1] + ';\n'
outstr += '\n// EXAMPLE:\n// pp := Factorization(2*ZF)[1][1];\n// heckeEigenvalues[pp];\n\n'
outstr += '/* EXTRA CODE: recompute eigenform (warning, may take a few minutes or longer!):\n'
outstr += 'M := HilbertCuspForms(F, NN);\n'
outstr += 'S := NewSubspace(M);\n'
outstr += '// SetVerbose("ModFrmHil", 1);\n'
outstr += 'newspaces := NewformDecomposition(S);\n'
outstr += 'newforms := [Eigenform(U) : U in newspaces];\n'
outstr += 'ppind := 0;\n'
outstr += 'while #newforms gt 1 do\n'
outstr += ' pp := primes[ppind];\n'
outstr += ' newforms := [f : f in newforms | HeckeEigenvalue(f,pp) eq heckeEigenvalues[pp]];\n'
outstr += 'end while;\n'
outstr += 'f := newforms[1];\n'
outstr += '// [HeckeEigenvalue(f,pp) : pp in primes] eq heckeEigenvaluesArray;\n'
outstr += '*/\n'
return outstr
示例2: __init__
def __init__(self, label):
self.Fdata = db_hmfnf().find_one({"label": label})
self.ideals = self.Fdata["ideals"]
self.primes = self.Fdata["primes"]
self.var = findvar(self.ideals)
WebNumberField.__init__(self, label, gen_name=self.var)
self.ideal_dict = {}
self.label_dict = {}
for I in self.ideals_iter():
self.ideal_dict[I["label"]] = I["ideal"]
self.label_dict[I["ideal"]] = I["label"]
示例3: __init__
def __init__(self, label):
self.Fdata = db_hmfnf().find_one({'label':label})
self.ideals = self.Fdata['ideals']
self.primes = self.Fdata['primes']
self.var = findvar(self.ideals)
WebNumberField.__init__(self,label,gen_name=self.var)
self.ideal_dict = {}
self.label_dict = {}
for I in self.ideals_iter():
self.ideal_dict[I['label']]=I['ideal']
self.label_dict[I['ideal']]=I['label']
示例4: __init__
def __init__(self, label):
self.Fdata = db.hmf_fields.lookup(label)
self.ideals = self.Fdata['ideals']
self.primes = self.Fdata['primes']
self.var = findvar(self.ideals)
WebNumberField.__init__(self,label,gen_name=self.var)
self.ideal_dict = {}
self.label_dict = {}
for I in self.ideals_iter():
self.ideal_dict[I['label']]=I['ideal']
self.label_dict[I['ideal']]=I['label']
示例5: render_Heckewebpage
def render_Heckewebpage(number_field=None, modulus=None, number=None):
#args = request.args
#temp_args = to_dict(args)
args = {}
args['type'] = 'Hecke'
args['number_field'] = number_field
args['modulus'] = modulus
args['number'] = number
if number_field == None:
info = WebHeckeExamples(**args).to_dict()
return render_template('Hecke.html', **info)
else:
WNF = WebNumberField(number_field)
if WNF.is_null():
return flask.abort(404, "Number field %s not found."%number_field)
if modulus == None:
try:
info = WebHeckeFamily(**args).to_dict()
except (ValueError,KeyError,TypeError) as err:
return flask.abort(404,err.args)
return render_template('CharFamily.html', **info)
elif number == None:
try:
info = WebHeckeGroup(**args).to_dict()
except (ValueError,KeyError,TypeError) as err:
# Typical failure case is a GP error inside bnrinit which we don't really want to display
return flask.abort(404,'Unable to construct modulus %s for number field %s'%(modulus,number_field))
m = info['modlabel']
info['bread'] = [('Characters', url_for(".render_characterNavigation")),
('Hecke', url_for(".render_Heckewebpage")),
('Number Field %s'%number_field, url_for(".render_Heckewebpage", number_field=number_field)),
('%s'%m, url_for(".render_Heckewebpage", number_field=number_field, modulus=m))]
info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
return render_template('CharGroup.html', **info)
else:
try:
X = WebHeckeCharacter(**args)
except (ValueError,KeyError,TypeError) as err:
return flask.abort(404, 'Unable to construct Hecke character %s modulo %s in number field %s.'%(number,modulus,number_field))
info = X.to_dict()
info['bread'] = [('Characters',url_for(".render_characterNavigation")),
('Hecke', url_for(".render_Heckewebpage")),
('Number Field %s'%number_field,url_for(".render_Heckewebpage", number_field=number_field)),
('%s'%X.modulus, url_for(".render_Heckewebpage", number_field=number_field, modulus=X.modlabel)),
('%s'%X.number2label(X.number), '')]
info['code'] = dict([(k[4:],info[k]) for k in info if k[0:4] == "code"])
info['code']['show'] = { lang:'' for lang in info['codelangs'] } # use default show names
return render_template('Character.html', **info)
示例6: av_data
def av_data(label):
abvar = db.av_fqisog.lookup(label)
wnf = WebNumberField(abvar['nf'])
inf = '<div>Dimension: ' + str(abvar['g']) + '<br />'
if not wnf.is_null():
inf += 'Number field: ' + nf_display_knowl(abvar['nf'], name = abvar['nf']) + '<br />'
inf += 'Galois group: ' + group_display_knowl(abvar['gal']['n'],abvar['gal']['t']) + '<br />'
inf += '$p$-rank: ' + str(abvar['p_rank']) + '</div>'
inf += '<div align="right">'
g, q, iso = split_label(label)
url = url_for("abvarfq.abelian_varieties_by_gqi", g = g, q = q, iso = iso)
inf += '<a href="%s">%s home page</a>' % (url, label)
inf += '</div>'
return inf
示例7: nf_code
def nf_code(**args):
label = args['nf']
nf = WebNumberField(label)
nf.make_code_snippets()
lang = args['download_type']
code = "{} {} code for working with number field {}\n\n".format(Comment[lang],Fullname[lang],label)
code += "{} (Note that not all these functions may be available, and some may take a long time to execute.)\n".format(Comment[lang])
if lang=='gp':
lang = 'pari'
for k in sorted_code_names:
if lang in nf.code[k]:
code += "\n{} {}: \n".format(Comment[lang],code_names[k])
code += nf.code[k][lang] + ('\n' if not '\n' in nf.code[k][lang] else '')
return code
示例8: EllipticCurve_to_ecnf_dict
def EllipticCurve_to_ecnf_dict(E):
"""
Make the dict that should be fed to `make_curves_line` in `lmfdb/scripts/ecnf/import_utils.py`.
It sets `iso_label`, 'a' and `number` to '1' and `cm` and `base_change` to '?'
INPUT:
* E - A sage elliptic curve over a number field
"""
E = EllipticCurve_polredabs(E)
K = E.base_field()
WNF = WebNumberField.from_polredabs(K.polynomial())
ainvs = [map(str,ai) for ai in map(list,E.a_invariants())]
conductor = E.conductor()
conductor_str = "".join(str([conductor.norm()]+list(conductor.gens_two())).split())
ec = {'field_label':WNF.label,
'conductor_label':ideal_label(conductor),
'iso_label':'a',
'number':'1',
'conductor_ideal':conductor_str,
'conductor_norm':str(conductor.norm()),
'ainvs':ainvs,
'cm':'?',
'base_change':'?'}
return ec
示例9: label
def label(self):
if "label" in self._data.keys():
return self._data["label"]
else:
#from number_fields.number_field import poly_to_field_label
#pol = PolynomialRing(QQ, 'x')(map(str,self.polynomial()))
#label = poly_to_field_label(pol)
label = WebNumberField.from_coeffs(self._data["Polynomial"]).get_label()
if label:
self._data["label"] = label
return label
示例10: download_hmf_sage
def download_hmf_sage(**args):
label = str(args['label'])
f = get_hmf(label)
if f is None:
return "No such form"
hecke_pol = f['hecke_polynomial']
hecke_eigs = f['hecke_eigenvalues']
AL_eigs = f['AL_eigenvalues']
F = WebNumberField(f['field_label'])
F_hmf = get_hmf_field(f['field_label'])
outstr = 'P.<x> = PolynomialRing(QQ)\n'
outstr += 'g = P(' + str(F.coeffs()) + ')\n'
outstr += 'F.<w> = NumberField(g)\n'
outstr += 'ZF = F.ring_of_integers()\n\n'
outstr += 'NN = ZF.ideal(' + f["level_ideal"] + ')\n\n'
outstr += 'primes_array = [\n' + ','.join([st for st in F_hmf["primes"]]).replace('],[',
'],\\\n[') + ']\n'
outstr += 'primes = [ZF.ideal(I) for I in primes_array]\n\n'
if hecke_pol != 'x':
outstr += 'heckePol = ' + hecke_pol + '\n'
outstr += 'K.<e> = NumberField(heckePol)\n'
else:
outstr += 'heckePol = x\nK = QQ\ne = 1\n'
outstr += '\nhecke_eigenvalues_array = [' + ', '.join([st for st in hecke_eigs]) + ']'
outstr += '\nhecke_eigenvalues = {}\n'
outstr += 'for i in range(len(hecke_eigenvalues_array)):\n hecke_eigenvalues[primes[i]] = hecke_eigenvalues_array[i]\n\n'
outstr += 'AL_eigenvalues = {}\n'
for s in AL_eigs:
outstr += 'AL_eigenvalues[ZF.ideal(%s)] = %s\n' % (s[0],s[1])
outstr += '\n# EXAMPLE:\n# pp = ZF.ideal(2).factor()[0][0]\n# hecke_eigenvalues[pp]\n'
return outstr
示例11: G_name
def G_name(self):
"""
More-or-less standardized name of the abstract group
"""
import re
wnf = WebNumberField.from_polredabs(self.polredabs())
if not wnf.is_null():
mygalstring = wnf.galois_string()
if re.search('Trivial', mygalstring) is not None:
return '$C_1$'
# Have to remove dollar signs
return mygalstring
if self.polredabs().degree() < 12:
# Let pari compute it for us now
from sage.all import pari
galt = int(list(pari('polgalois(' + str(self.polredabs()) + ')'))[2])
from lmfdb.transitive_group import WebGaloisGroup
tg = WebGaloisGroup.from_nt(self.polredabs().degree(), galt)
return tg.display_short()
return self._data["G-Name"]
示例12: __init__
def __init__(self, **args):
constructor_logger(self, args)
self.motivic_weight = 0
# Check for compulsory arguments
if not 'label' in args.keys():
raise Exception("You have to supply a label for a Dedekind zeta function")
# Initialize default values
# Put the arguments into the object dictionary
self.__dict__.update(args)
# Fetch the polynomial of the field from the database
wnf = WebNumberField(self.label)
# poly_coeffs = wnf.coeffs()
# Extract the L-function information from the polynomial
R = QQ['x']
(x,) = R._first_ngens(1)
# self.polynomial = sum([poly_coeffs[i]*x**i for i in range(len(poly_coeffs))])
self.NF = wnf.K() # NumberField(self.polynomial, 'a')
self.signature = wnf.signature() # self.NF.signature()
self.sign = 1
self.quasidegree = sum(self.signature)
self.level = wnf.disc().abs() # self.NF.discriminant().abs()
self.degreeofN = self.NF.degree()
self.Q_fe = float(
sqrt(self.level) / (2 ** (self.signature[1]) * (math.pi) ** (float(self.degreeofN) / 2.0)))
self.kappa_fe = self.signature[0] * [0.5] + self.signature[1] * [1]
self.lambda_fe = self.quasidegree * [0]
self.mu_fe = self.signature[0] * [0] # not in use?
self.nu_fe = self.signature[1] * [0] # not in use?
self.langlands = True
# self.degree = self.signature[0] + 2 * self.signature[1] # N = r1 +2r2
self.degree = self.degreeofN
self.dirichlet_coefficients = [Integer(x) for x in self.NF.zeta_coefficients(5000)]
self.h = wnf.class_number() # self.NF.class_number()
self.R = wnf.regulator() # self.NF.regulator()
self.w = len(self.NF.roots_of_unity())
self.res = RR(2 ** self.signature[0] * self.h * self.R / self.w) # r1 = self.signature[0]
self.grh = wnf.used_grh()
if self.degree > 1:
if wnf.is_abelian():
cond = wnf.conductor()
dir_group = wnf.dirichlet_group()
# Remove 1 from the list
j = 0
while dir_group[j] != 1:
j += 1
dir_group.pop(j)
self.factorization = r'\(\zeta_K(s) =\) <a href="/L/Riemann/">\(\zeta(s)\)</a>'
fullchargroup = wnf.full_dirichlet_group()
for j in dir_group:
chij = fullchargroup[j]
mycond = chij.conductor()
myj = j % mycond
self.factorization += r'\(\;\cdot\) <a href="/L/Character/Dirichlet/%d/%d/">\(L(s,\chi_{%d}(%d, \cdot))\)</a>' % (mycond, myj, mycond, myj)
self.poles = [1, 0] # poles of the Lambda(s) function
self.residues = [self.res, -self.res] # residues of the Lambda(s) function
self.poles_L = [1] # poles of L(s) used by createLcalcfile_ver2
self.residues_L = [1234]
# residues of L(s) used by createLcalcfile_ver2, XXXXXXXXXXXX needs to be set
self.coefficient_period = 0
self.selfdual = True
self.primitive = True
self.coefficient_type = 0
self.texname = "\\zeta_K(s)"
self.texnamecompleteds = "\\Lambda_K(s)"
if self.selfdual:
self.texnamecompleted1ms = "\\Lambda_K(1-s)"
else:
self.texnamecompleted1ms = "\\Lambda_K(1-s)"
self.title = "Dedekind zeta-function: $\\zeta_K(s)$"
self.title = self.title + ", where $K$ is the " + str(self.NF).replace("in a ", "")
self.credit = 'Sage'
self.citation = ''
self.generateSageLfunction()
示例13: FIELD
def FIELD(label):
nf = WebNumberField(label, gen_name=special_names.get(label, 'a'))
nf.parse_NFelt = lambda s: nf.K()([QQ(str(c)) for c in s])
return nf
示例14: render_bmf_space_webpage
def render_bmf_space_webpage(field_label, level_label):
info = {}
t = "Bianchi modular forms of level %s over %s" % (level_label, field_label)
credit = bianchi_credit
bread = [('Bianchi modular forms', url_for(".index")),
(field_pretty(field_label), url_for(".render_bmf_field_dim_table_gl2", field_label=field_label)),
(level_label, '')]
friends = []
properties2 = []
if not field_label_regex.match(field_label):
info['err'] = "%s is not a valid label for an imaginary quadratic field" % field_label
else:
pretty_field_label = field_pretty(field_label)
if not db_dims().find({'field_label': field_label}):
info['err'] = "no dimension information exists in the database for field %s" % pretty_field_label
else:
t = "Bianchi Modular Forms of level %s over %s" % (level_label, pretty_field_label)
data = db_dims().find({'field_label': field_label, 'level_label': level_label})
nres = data.count()
if nres==0:
info['err'] = "no dimension information exists in the database for level %s and field %s" % (level_label, pretty_field_label)
else:
data = data.next()
info['label'] = data['label']
nf = WebNumberField(field_label)
info['base_galois_group'] = nf.galois_string()
info['field_label'] = field_label
info['pretty_field_label'] = pretty_field_label
info['level_label'] = level_label
info['level_norm'] = data['level_norm']
info['field_degree'] = nf.degree()
info['field_classno'] = nf.class_number()
info['field_disc'] = str(nf.disc())
info['field_poly'] = teXify_pol(str(nf.poly()))
info['field_knowl'] = nf_display_knowl(field_label, getDBConnection(), pretty_field_label)
w = 'i' if nf.disc()==-4 else 'a'
L = nf.K().change_names(w)
alpha = L.gen()
info['field_gen'] = latex(alpha)
I = ideal_from_label(L,level_label)
info['level_gen'] = latex(I.gens_reduced()[0])
info['level_fact'] = latex(I.factor())
dim_data = data['gl2_dims']
weights = dim_data.keys()
weights.sort(key=lambda w: int(w))
for w in weights:
dim_data[w]['dim']=dim_data[w]['cuspidal_dim']
info['dim_data'] = dim_data
info['weights'] = weights
info['nweights'] = len(weights)
newdim = data['gl2_dims']['2']['new_dim']
newforms = db_forms().find({'field_label':field_label, 'level_label':level_label}).sort('label_suffix', ASCENDING)
info['nfdata'] = [{
'label': f['short_label'],
'url': url_for(".render_bmf_webpage",field_label=f['field_label'], level_label=f['level_label'], label_suffix=f['label_suffix']),
'wt': f['weight'],
'dim': f['dimension'],
'sfe': "+1" if f['sfe']==1 else "-1",
'bc': bc_info(f['bc']),
'cm': cm_info(f['CM']),
} for f in newforms]
info['nnewforms'] = len(info['nfdata'])
properties2 = [('Base field', pretty_field_label), ('Level',info['level_label']), ('Norm',str(info['level_norm'])), ('New dimension',str(newdim))]
friends = [('Newform {}'.format(f['label']), f['url']) for f in info['nfdata'] ]
return render_template("bmf-space.html", info=info, credit=credit, title=t, bread=bread, properties2=properties2, friends=friends)
示例15: render_hmf_webpage
def render_hmf_webpage(**args):
C = getDBConnection()
if 'data' in args:
data = args['data']
label = data['label']
else:
label = str(args['label'])
data = C.hmfs.forms.find_one({'label': label})
if data is None:
return "No such form"
info = {}
try:
info['count'] = args['count']
except KeyError:
info['count'] = 10
try:
numeigs = request.args['numeigs']
numeigs = int(numeigs)
except:
numeigs = 20
hmf_field = C.hmfs.fields.find_one({'label': data['field_label']})
gen_name = findvar(hmf_field['ideals'])
nf = WebNumberField(data['field_label'], gen_name=gen_name)
info['hmf_field'] = hmf_field
info['field'] = nf
info['base_galois_group'] = nf.galois_string()
info['field_degree'] = nf.degree()
info['field_disc'] = str(nf.disc())
info['field_poly'] = teXify_pol(str(nf.poly()))
info.update(data)
info['downloads'] = [
('Download to Magma', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='magma')),
('Download to Sage', url_for(".render_hmf_webpage_download", field_label=info['field_label'], label=info['label'], download_type='sage'))
]
if hmf_field['narrow_class_no'] == 1 and nf.disc()**2 * data['level_norm'] < 40000:
info['friends'] = [('L-function',
url_for("l_functions.l_function_hmf_page", field=info['field_label'], label=info['label'], character='0', number='0'))]
else:
info['friends'] = [('L-function not available', "")]
if data['dimension'] == 1: # Try to attach associated elliptic curve
lab = split_class_label(info['label'])
ec_from_hmf = db_ecnf().find_one({"label": label + '1'})
if ec_from_hmf == None:
info['friends'] += [('Elliptic curve not available', "")]
else:
info['friends'] += [('Isogeny class ' + info['label'], url_for("ecnf.show_ecnf_isoclass", nf=lab[0], conductor_label=lab[1], class_label=lab[2]))]
bread = [('Hilbert Modular Forms', url_for(".hilbert_modular_form_render_webpage")), ('%s' % data[
'label'], ' ')]
t = "Hilbert Cusp Form %s" % info['label']
forms_space = C.hmfs.forms.search.find(
{'field_label': data['field_label'], 'level_ideal': data['level_ideal']},{'dimension':True})
dim_space = 0
for v in forms_space:
dim_space += v['dimension']
info['newspace_dimension'] = dim_space
eigs = data['hecke_eigenvalues']
eigs = eigs[:min(len(eigs), numeigs)]
primes = hmf_field['primes']
n = min(len(eigs), len(primes))
info['eigs'] = [{'eigenvalue': teXify_pol(eigs[i]),
'prime_ideal': teXify_pol(primes[i]),
'prime_norm': primes[i][1:primes[i].index(',')]} for i in range(n)]
try:
display_eigs = request.args['display_eigs']
if display_eigs in ['True', 'true', '1', 'yes']:
display_eigs = True
else:
display_eigs = False
except KeyError:
display_eigs = False
if 'numeigs' in request.args:
display_eigs = True
info['hecke_polynomial'] = teXify_pol(info['hecke_polynomial'])
if 'AL_eigenvalues_fixed' in data:
if data['AL_eigenvalues_fixed'] == 'done':
info['AL_eigs'] = [{'eigenvalue': teXify_pol(al[1]),
'prime_ideal': teXify_pol(al[0]),
'prime_norm': al[0][1:al[0].index(',')]} for al in data['AL_eigenvalues']]
else:
info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}]
else:
info['AL_eigs'] = [{'eigenvalue': '?', 'prime_ideal': '?'}]
info['AL_eigs_count'] = len(info['AL_eigs']) != 0
max_eig_len = max([len(eig['eigenvalue']) for eig in info['eigs']])
display_eigs = display_eigs or (max_eig_len<=300)
#.........这里部分代码省略.........