# Ticket #13895: sage-trac_13895.patch

File sage-trac_13895.patch, 2.5 KB (added by mjo, 8 years ago)
• ## sage/rings/polynomial/polynomial_modn_dense_ntl.pyx

```# HG changeset patch
# User Michael Orlitzky <michael@orlitzky.com>
# Date 1357062862 18000
# Node ID 6600b298080b89da51f203b98b03efa2a21dbb87
# Parent  5843a384f289819727f25fec93c5358fc73ee4a1
Trac #13895: Fix ArithmeticError: 0^0 in sage/rings/polynomial/polynomial_modn_dense_ntl.pyx

diff --git a/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx```
 a sage: R. = Integers(101)[] sage: (x-1)^(-5) 1/(x^5 + 96*x^4 + 10*x^3 + 91*x^2 + 5*x + 100) We define ``0^0`` to be unity, :trac:`13895`:: sage: R. = PolynomialRing(Integers(100), implementation='NTL') sage: R(0)^0 1 The value returned from ``0^0`` should belong to our ring:: sage: R. = PolynomialRing(Integers(100), implementation='NTL') sage: type(R(0)^0) == type(R(0)) True """ cdef bint recip = 0, do_sig cdef long e = ee elif e < 0: recip = 1 e = -e if not self: if e == 0: raise ArithmeticError("0^0 is undefined.") if self == 0 and e == 0: return self.parent(1) cdef Polynomial_dense_modn_ntl_zz r = self._new() cdef zz_pX_Modulus_c *mod sage: R. = Integers(10^30)[] sage: (x+1)^5 x^5 + 5*x^4 + 10*x^3 + 10*x^2 + 5*x + 1 We define ``0^0`` to be unity, :trac:`13895`:: sage: R. = PolynomialRing(Integers(10^30), implementation='NTL') sage: R(0)^0 1 The value returned from ``0^0`` should belong to our ring:: sage: R. = PolynomialRing(Integers(10^30), implementation='NTL') sage: type(R(0)^0) == type(R(0)) True """ cdef bint recip = 0, do_sig cdef long e = ee elif e < 0: recip = 1 # delay because powering frac field elements is slow e = -e if not self: if e == 0: raise ArithmeticError("0^0 is undefined.") if self == 0 and e == 0: return self.parent(1) cdef Polynomial_dense_modn_ntl_ZZ r = self._new() cdef ZZ_pX_Modulus_c *mod