CoCalc Public Fileswww / cgi-bin / mfd / mfe_ap_data_powerbasis.py
Author: William A. Stein
Compute Environment: Ubuntu 18.04 (Deprecated)
1#!/usr/bin/python
2
3import cgi, mfd, sys, mfe_source, constants
4
5def 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
25def 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
39form = cgi.FieldStorage()
40
41print "Content-Type: text/html"
42print ""
43
44if form.has_key("code"):
45    code = form["code"].value
46else:
47    print "Missing code"
48    sys.exit(0)
49
50M = mfd.ModSym(code)
51field = M.ap_field()
52embedding = M.ap_embedding()
53source = M.ap_source()
54
55bar="////////////////////////////////////////////////////////////\n"
56print "//<pre>%s// Basis for Hecke eigenvalue field for %s"%(bar,code)
57if source != constants.not_computed:
58    print "// Source of data: %s"%mfe_source.Link(M.source(source))
59print bar
60if 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