Skip to content

Commit bf927cc

Browse files
Faster get_unsafe for NTL GF(p) polynomials
Unlike similar Zmod(n) polynomials, the GF(p) NTL polynomials would call the IntegerModRing constructor for each get_unsafe call resulting in very slow polynomial evaluation.
1 parent 27b077e commit bf927cc

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/sage/libs/ntl/ntl_ZZ_pX.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ cdef class ntl_ZZ_pX():
264264
if i < 0:
265265
r.set_from_int(0)
266266
else:
267-
sig_on()
268267
r.x = ZZ_pX_coeff( self.x, i)
269-
sig_off()
270268
return r
271269

272270
cdef int getitem_as_int(ntl_ZZ_pX self, long i):

src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ cdef class Polynomial_dense_mod_n(Polynomial):
209209
sage: f[:3]
210210
13*x^2 + 10*x + 5
211211
"""
212-
return self._parent._base(self.__poly[n]._sage_())
212+
return self._parent._base((<ntl_ZZ_pX> self.__poly)[n]._integer_())
213213

214214
def _unsafe_mutate(self, n, value):
215215
n = int(n)

0 commit comments

Comments
 (0)