File: aplist.py

package info (click to toggle)
sagemath-database-cremona-elliptic-curves 20221013-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,252,172 kB
  • sloc: python: 3,515; makefile: 83; sh: 28
file content (44 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Sage's E.aplist(100) returns a list of the Fourier coefficients for
# p<100.  For the aplist files, we want to replace the coefficient for
# p|N with the W-eigenvalue (the root number) and append the
# W-eigenvalues for p|N, p>100.  Not relevant for making LMFDBupload
# files.

from sage.all import prime_range

def wstr(n, w):  # str(n) with enough spaces prepended to give width w
    a = str(n)
    if len(a) < w:
        a = ' ' * (w - len(a)) + a
    return a

def my_ap(E, D, p):
    if p.divides(D):
        return E.root_number(p)
    return E.ap(p)

def my_ap_str(E, D, p):
    if p.divides(D):
        a = E.root_number(p)
        if a == 1:
            if p > 23:
                return '  +'
            return ' +'
        if p > 23:
            return '  -'
        return ' -'
    if p > 23:
        return wstr(E.ap(p), 3)
    return wstr(E.ap(p), 2)

def my_aplist(E):
    D = E.discriminant()
    ap = [my_ap_str(E, D, p) for p in prime_range(100)]
    qlist = D.support()
    for q in qlist:
        if q > 100:
            if E.root_number(q) == 1:
                ap.append('+('+str(q)+')')
            else:
                ap.append('-('+str(q)+')')
    return ' '.join(ap)