Skip to content

Commit eead343

Browse files
committed
Fix bug with pari interface in classical_modular_polynomial
1 parent 439065e commit eead343

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

src/sage/schemes/elliptic_curves/mod_poly.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ def classical_modular_polynomial(l, j=None):
8787
sage: Y = polygen(parent(j), 'Y')
8888
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
8989
True
90+
sage: p = 2^216 * 3^137 - 1
91+
sage: F.<i> = GF(p^2, modulus=[1,0,1])
92+
sage: l = random_prime(50)
93+
sage: j = F.random_element()
94+
sage: Y = polygen(parent(j), 'Y')
95+
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
96+
True
97+
sage: E = EllipticCurve(F, [0, 6, 0, 1, 0])
98+
sage: j = E.j_invariant()
99+
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
100+
True
101+
sage: R.<Y> = QQ['Y']
102+
sage: j = QQ(1/2)
103+
sage: classical_modular_polynomial(l, j) == classical_modular_polynomial(l)(j, Y)
104+
True
90105
"""
91106
l = ZZ(l)
92107

@@ -114,7 +129,8 @@ def classical_modular_polynomial(l, j=None):
114129

115130
return Phi
116131

117-
R = parent(j)['Y']
132+
Rb = j.parent()
133+
R = Rb['Y']
118134
Y = R.gen()
119135

120136
# If the generic polynomial is in the cache or the database, evaluating
@@ -133,12 +149,19 @@ def classical_modular_polynomial(l, j=None):
133149
# Now try to get the instantiated modular polynomial directly from PARI.
134150
# This should be slightly more efficient (in particular regarding memory
135151
# usage) than computing and evaluating the generic modular polynomial.
136-
try:
137-
pari_Phi = pari.polmodular(l, 0, j)
138-
except PariError:
139-
pass
140-
else:
141-
return R(pari_Phi)
152+
# This currently only works if we are over Z/nZ.
153+
n = Rb.characteristic()
154+
if n > 0:
155+
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
156+
try:
157+
jn = IntegerModRing(n)(j)
158+
pari_Phi = pari.polmodular(l, 0, jn)
159+
except TypeError:
160+
pass
161+
except PariError:
162+
pass
163+
else:
164+
return R(pari_Phi)
142165

143166
# Nothing worked. Fall back to computing the generic modular polynomial
144167
# and simply evaluating it.

0 commit comments

Comments
 (0)