Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
from defs cimport *
2
3
cdef class SmallJac:
4
cdef smalljac_Qcurve_t c
5
cdef object tmp
6
7
def __cinit__(self):
8
self.c = <smalljac_Qcurve_t>0
9
10
def __init__(self, v):
11
curve = str(v)
12
cdef int err
13
self.c = smalljac_Qcurve_init(curve, &err)
14
if err:
15
# todo -- see smalljac.h for how to parse this
16
raise RuntimeError, "Error code %s"%err
17
18
def __repr__(self):
19
return "Smalljac curve defined by %s"%smalljac_Qcurve_str(self.c)
20
21
def __dealloc__(self):
22
if self.c:
23
smalljac_Qcurve_clear(self.c)
24
25
cpdef int genus(self):
26
"""
27
EXAMPLES::
28
29
sage: import psage.libs.smalljac.wrapper as smalljac
30
sage: smalljac.SmallJac('x^3+x+1').genus()
31
1
32
sage: smalljac.SmallJac('x^5+x+1').genus()
33
2
34
sage: smalljac.SmallJac('x^7+x+1').genus()
35
3
36
sage: smalljac.SmallJac('x^9+x+1').genus()
37
4
38
sage: smalljac.SmallJac('x^11+x+1').genus()
39
Traceback (most recent call last):
40
...
41
RuntimeError: Error code -4
42
"""
43
return smalljac_Qcurve_genus(self.c)
44
45
def ap(self, unsigned long p, unsigned long b=0):
46
"""
47
If only p is given, return trace of Frobenius at p. If both p
48
and b are given, return a dictionary of key:value pairs, with
49
keys the primes < b, and values the traces of Frobenius at the
50
good primes, and None at the bad primes, where bad is "bad for
51
the given model".
52
53
EXAMPLES::
54
55
sage: import psage.libs.smalljac.wrapper as smalljac
56
sage: C = smalljac.SmallJac(x^3 - 13392*x - 1080432)
57
sage: C.ap(37)
58
3
59
sage: C.ap(0,37)
60
{2: None, 3: None, 5: 1, 7: -2, 11: None, 13: 4, 17: -2, 37: 3, 19: 0, 23: -1, 29: 0, 31: 7}
61
sage: C.ap(19, 37)
62
{31: 7, 37: 3, 19: 0, 29: 0, 23: -1}
63
64
sage: C = smalljac.SmallJac(x^5 - 1)
65
sage: C.ap(0,37)
66
{2: None, 3: 0, 5: None, 7: 0, 11: -4, 13: 0, 17: 0, 37: 0, 19: 0, 23: 0, 29: 0, 31: -4}
67
"""
68
if b == 0:
69
# Compute for a single p only
70
smalljac_Lpolys(self.c, p, p, SMALLJAC_A1_ONLY, callback_ap_single, <void*>self)
71
return self.tmp
72
# Compute for a range of primes, starting with p.
73
self.tmp = {}
74
smalljac_Lpolys(self.c, p, b, SMALLJAC_A1_ONLY, callback_ap_dict, <void*>self)
75
return self.tmp
76
77
def frob(self, unsigned long p, unsigned long b=0):
78
"""
79
EXAMPLES::
80
"""
81
if b == 0:
82
# Compute for a single p only
83
smalljac_Lpolys(self.c, p, p, 0, callback_Lpolys_single, <void*>self)
84
return self.tmp
85
self.tmp = {}
86
smalljac_Lpolys(self.c, p, b, 0, callback_Lpolys, <void*>self)
87
return self.tmp
88
89
def group(self, unsigned long p, unsigned long b=0):
90
raise NotImplementedError
91
92
93
94
95