Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/cremona/newforms.pyx
4069 views
1
from sage.rings.rational import Rational
2
from sage.rings.integer cimport Integer
3
from sage.schemes import elliptic_curves
4
5
#*****************************************************************************
6
# Copyright (C) 2008 Tom Boothby <[email protected]>
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
# as published by the Free Software Foundation; either version 2 of
10
# the License, or (at your option) any later version.
11
# http://www.gnu.org/licenses/
12
#*****************************************************************************
13
14
15
cdef class ECModularSymbol:
16
"""
17
Modular symbol associated with an elliptic curve,
18
using John Cremona's newforms class.
19
20
EXAMPLES::
21
22
sage: from sage.libs.cremona.newforms import ECModularSymbol
23
sage: E = EllipticCurve('11a')
24
sage: M = ECModularSymbol(E,1); M
25
Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
26
sage: [M(1/i) for i in range(1,11)]
27
[0, 2, 1, -1, -2, -2, -1, 1, 2, 0]
28
29
"""
30
def __init__(self, E, sign=1):
31
"""
32
Construct the modular symbol.
33
34
EXAMPLES::
35
36
sage: from sage.libs.cremona.newforms import ECModularSymbol
37
sage: E = EllipticCurve('11a')
38
sage: M = ECModularSymbol(E)
39
sage: E = EllipticCurve('37a')
40
sage: M = ECModularSymbol(E)
41
sage: E = EllipticCurve('389a')
42
sage: M = ECModularSymbol(E)
43
44
TESTS:
45
46
This one is from trac #8042 (note that Cremona's code is more limited
47
when run on a 32-bit platform, but works fine on 64-bit in this
48
case; see trac #8114).
49
50
::
51
sage: from sage.libs.cremona.newforms import ECModularSymbol
52
sage: E = EllipticCurve('858k2')
53
sage: ECModularSymbol(E)
54
Traceback (most recent call last): # 32-bit
55
... # 32-bit
56
OverflowError: Python int too large to convert to C long # 32-bit
57
Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + x*y = x^3 + 16353089*x - 335543012233 over Rational Field # 64-bit
58
"""
59
cdef ZZ_c a1, a2, a3, a4, a6, N
60
cdef Curve *C
61
cdef Curvedata *CD
62
cdef CurveRed *CR
63
cdef int n, t
64
65
a1 = new_bigint(int(E.a1()))
66
a2 = new_bigint(int(E.a2()))
67
a3 = new_bigint(int(E.a3()))
68
a4 = new_bigint(int(E.a4()))
69
a6 = new_bigint(int(E.a6()))
70
71
sig_on()
72
C = new_Curve(a1,a2,a3,a4,a6)
73
CD = new_Curvedata(C[0],0)
74
CR = new_CurveRed(CD[0])
75
N = getconductor(CR[0])
76
n = I2int(N)
77
self.n = n
78
self.sign = sign
79
80
self.nfs = new_newforms(n,0)
81
self.nfs.createfromcurve(sign,CR[0])
82
self._E = E
83
sig_off()
84
85
def __repr__(self):
86
"""
87
TESTS::
88
89
sage: from sage.libs.cremona.newforms import ECModularSymbol
90
sage: E = EllipticCurve('11a')
91
sage: M = ECModularSymbol(E); M
92
Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
93
sage: E = EllipticCurve('37a')
94
sage: M = ECModularSymbol(E); M
95
Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
96
sage: E = EllipticCurve('389a')
97
sage: M = ECModularSymbol(E); M
98
Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field
99
"""
100
return "Modular symbol with sign %s over Rational Field attached to %s"%(self.sign, self._E)
101
102
def __call__(self, r):
103
"""
104
Computes the (rational) value of self at a rational number r.
105
106
EXAMPLES::
107
108
sage: from sage.libs.cremona.newforms import ECModularSymbol
109
sage: E = EllipticCurve('11a')
110
sage: M = ECModularSymbol(E)
111
sage: [M(1/i) for i in range(1,10)]
112
[0, 2, 1, -1, -2, -2, -1, 1, 2]
113
sage: E = EllipticCurve('37a')
114
sage: M = ECModularSymbol(E)
115
sage: [M(1/i) for i in range(1,10)]
116
[0, 0, 0, 0, 1, 0, 1, 1, 0]
117
sage: E = EllipticCurve('389a')
118
sage: M = ECModularSymbol(E)
119
sage: [M(1/i) for i in range(1,10)]
120
[0, 0, 0, 0, 4, 0, 2, 0, -2]
121
"""
122
cdef rational _r
123
cdef rational _s
124
cdef mpz_t *z_n, *z_d
125
cdef ZZ_c *Z_n, *Z_d
126
cdef long n, d
127
128
sig_on()
129
r = Rational(r)
130
d = r.denom()
131
n = r.numer() % d
132
_r = new_rational(n,d)
133
_s = self.nfs.plus_modular_symbol(_r)
134
r = Rational((rational_num(_s), rational_den(_s)))
135
sig_off()
136
return r
137
138