1+ cimport cython
2+
13from cpython.list cimport PyList_GET_SIZE
24from flint.flint_base.flint_base cimport flint_poly
35from flint.utils.typecheck cimport typecheck
@@ -18,9 +20,10 @@ from flint.utils.flint_exceptions import DomainError
1820cdef dict _nmod_poly_ctx_cache = {}
1921
2022
23+ @cython.no_gc
2124cdef class nmod_poly_ctx:
2225 """
23- Context object for creating :class:`~.nmod_poly` initalised
26+ Context object for creating :class:`~.nmod_poly` initalised
2427 with modulus :math:`N`.
2528
2629 >>> nmod_poly_ctx.new(17)
@@ -170,6 +173,7 @@ cdef class nmod_poly_ctx:
170173 return nmod_poly(arg, self )
171174
172175
176+ @cython.no_gc
173177cdef class nmod_poly(flint_poly):
174178 """
175179 The nmod_poly type represents dense univariate polynomials
@@ -387,7 +391,7 @@ cdef class nmod_poly(flint_poly):
387391 """
388392 if n <= 0 :
389393 raise ValueError (f" {n = } must be positive" )
390-
394+
391395 if nmod_poly_get_coeff_ui(self .val, 0 ) == 0 :
392396 raise ZeroDivisionError (f" nmod_poly inverse_series_trunc: leading coefficient is zero" )
393397
@@ -417,8 +421,8 @@ cdef class nmod_poly(flint_poly):
417421 if other is NotImplemented :
418422 raise TypeError (" cannot convert input to nmod_poly" )
419423 res = self .ctx.new_nmod_poly()
420- nmod_poly_compose(res.val, self .val, (< nmod_poly> other).val)
421- return res
424+ nmod_poly_compose(res.val, self .val, (< nmod_poly> other).val)
425+ return res
422426
423427 def compose_mod (self , other , modulus ):
424428 r """
@@ -449,8 +453,8 @@ cdef class nmod_poly(flint_poly):
449453 raise ZeroDivisionError (" cannot reduce modulo zero" )
450454
451455 res = self .ctx.new_nmod_poly()
452- nmod_poly_compose_mod(res.val, self .val, (< nmod_poly> other).val, (< nmod_poly> modulus).val)
453- return res
456+ nmod_poly_compose_mod(res.val, self .val, (< nmod_poly> other).val, (< nmod_poly> modulus).val)
457+ return res
454458
455459 def __call__ (self , other ):
456460 cdef nmod_poly r
@@ -638,7 +642,6 @@ cdef class nmod_poly(flint_poly):
638642 >>> f = 30* x** 6 + 104* x** 5 + 76* x** 4 + 33* x** 3 + 70* x** 2 + 44* x + 65
639643 >>> g = 43* x** 6 + 91* x** 5 + 77* x** 4 + 113* x** 3 + 71* x** 2 + 132* x + 60
640644 >>> mod = x** 4 + 93* x** 3 + 78* x** 2 + 72* x + 149
641- >>>
642645 >>> f. pow_mod( 123, mod)
643646 3* x^ 3 + 25* x^ 2 + 115* x + 161
644647 >>> f. pow_mod( 2** 64, mod)
@@ -663,7 +666,7 @@ cdef class nmod_poly(flint_poly):
663666
664667 # Output polynomial
665668 res = self .ctx.new_nmod_poly()
666-
669+
667670 # For small exponents, use a simple binary exponentiation method
668671 if e.bit_length() < 32 :
669672 nmod_poly_powmod_ui_binexp(
0 commit comments