CoCalc Public Fileswww / cgi-bin / mfd / mfe_ap_data_powerbasis.pyOpen with one click!
Author: William A. Stein
Compute Environment: Ubuntu 18.04 (Deprecated)
1
#!/usr/bin/python
2
3
import cgi, mfd, sys, mfe_source, constants
4
5
def get_field_degree(field):
6
start = field.find("x");
7
rest = field[start + 1:];
8
9
if rest[0] != "^":
10
return 1
11
else:
12
rest = rest[1:]
13
stopp = rest.find("+")
14
if stopp != -1:
15
deg = rest[:stopp]
16
stopm = deg.find("-")
17
if stopm != -1:
18
return eval(deg[:stopm])
19
else:
20
return eval(deg)
21
else:
22
stopm = rest.find("-")
23
return eval(rest[:stopm])
24
25
def power_basis(field):
26
deg = get_field_degree(field)
27
basis = "["
28
for i in range(0, deg):
29
if i == 0:
30
basis = basis + "1, "
31
elif i == 1:
32
basis = basis + "x, "
33
else:
34
basis = basis + "x^%s, "%i
35
36
return basis[:-2] + "]"
37
38
39
form = cgi.FieldStorage()
40
41
print "Content-Type: text/html"
42
print ""
43
44
if form.has_key("code"):
45
code = form["code"].value
46
else:
47
print "Missing code"
48
sys.exit(0)
49
50
M = mfd.ModSym(code)
51
field = M.ap_field()
52
embedding = M.ap_embedding()
53
source = M.ap_source()
54
55
bar="////////////////////////////////////////////////////////////\n"
56
print "//<pre>%s// Basis for Hecke eigenvalue field for %s"%(bar,code)
57
if source != constants.not_computed:
58
print "// Source of data: %s"%mfe_source.Link(M.source(source))
59
print bar
60
if field != constants.not_computed:
61
print "// The field is K=Q[x]/(f)\n"
62
print "f := %s; \n"%field
63
print "// The eigenvalues are vectors on the power basis for K:\n"
64
print "power_basis := %s; \n"%power_basis(field)
65
66