Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241818 views
1
include "wrapper0.pyx"
2
include 'stdsage.pxi'
3
4
cdef class GroupModp:
5
pass
6
7
cdef class FrobPoly:
8
cdef long a
9
cdef unsigned long p
10
def __init__(self, a, p):
11
self.a = a
12
self.p = p
13
14
def __reduce__(self):
15
return FrobPoly_new, (self.a, self.p)
16
17
def __repr__(self):
18
return "Frobenius in characteristic %s with charpoly %s"%(self.p, self.characteristic_polynomial())
19
20
def prime(self):
21
return int(self.p)
22
23
def trace(self):
24
return -self.a
25
26
def characteristic_polynomial(self, var='x'):
27
from sage.rings.all import ZZ
28
return ZZ[var]([self.p, self.a, 1])
29
30
charpoly = characteristic_polynomial
31
32
cpdef FrobPoly_new(long a, unsigned long p):
33
cdef FrobPoly L = PY_NEW(FrobPoly)
34
L.a = a; L.p = p
35
return L
36
37
38
cdef int callback_Lpolys(smalljac_Qcurve_t c, unsigned long p, int good, long a[], int n, void *arg):
39
cdef int i
40
if good:
41
(<SmallJac>arg).tmp[int(p)] = FrobPoly_new(a[0], p)
42
else:
43
(<SmallJac>arg).tmp[int(p)] = None
44
return 1
45
46
cdef int callback_Lpolys_single(smalljac_Qcurve_t c, unsigned long p, int good, long a[], int n, void *arg):
47
if good:
48
(<SmallJac>arg).tmp = FrobPoly_new(a[0], p)
49
else:
50
(<SmallJac>arg).tmp = None
51
return 1
52
53
cdef int callback_ap_dict(smalljac_Qcurve_t c, unsigned long p, int good, long a[], int n, void *arg):
54
if good:
55
(<SmallJac>arg).tmp[int(p)] = -a[0]
56
else:
57
(<SmallJac>arg).tmp[int(p)] = None
58
return 1
59
60
cdef int callback_ap_single(smalljac_Qcurve_t c, unsigned long p, int good, long a[], int n, void *arg):
61
if good:
62
(<SmallJac>arg).tmp = -a[0]
63
else:
64
(<SmallJac>arg).tmp = None
65
return 1
66
67
cpdef long elliptic_curve_ap(unsigned long a4, unsigned long a6, unsigned long p, unsigned long flags=0):
68
s = 'x^3+%sx+%s'%(a4,a6)
69
cdef long a[2]
70
smalljac_Lpoly(a, s, p, flags)
71
return -a[0]
72
73