File: twoadic.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 (31 lines) | stat: -rw-r--r-- 731 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
# Sage interface to 2adic Magma script

import os
from codec import parse_twoadic_string

TWOADIC_SCRIPT_DIR = "/home/jec/ecdata/scripts"

def init_2adic(mag, script_dir=TWOADIC_SCRIPT_DIR):
    """
    Load the 2adic magma script into this magma process
    """
    script = os.path.join(script_dir, "2adic.m")
    mag.eval('load "{}";'.format(script))

def get_2adic_data(E, mag):
    """
    Use 2adic.m Magma script to compute the 2-adic image data

    E is an elliptic curve over Q

    mag is a magma process.

    NB before calling this, the caller must have called init_2adic()
    """
    if E.has_cm():
        s = "inf inf [] CM"
    else:
        s = str(mag.make_2adic_string(E))
    return parse_twoadic_string(s)