# 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

b


825  825  sage: R.<x> = Integers(101)[] 
826  826  sage: (x1)^(5) 
827  827  1/(x^5 + 96*x^4 + 10*x^3 + 91*x^2 + 5*x + 100) 
 828  
 829  We define ``0^0`` to be unity, :trac:`13895`:: 
 830  
 831  sage: R.<x> = PolynomialRing(Integers(100), implementation='NTL') 
 832  sage: R(0)^0 
 833  1 
 834  
 835  The value returned from ``0^0`` should belong to our ring:: 
 836  
 837  sage: R.<x> = PolynomialRing(Integers(100), implementation='NTL') 
 838  sage: type(R(0)^0) == type(R(0)) 
 839  True 
 840  
828  841  """ 
829  842  cdef bint recip = 0, do_sig 
830  843  cdef long e = ee 
… 
… 

833  846  elif e < 0: 
834  847  recip = 1 
835  848  e = e 
836   if not self: 
837   if e == 0: 
838   raise ArithmeticError("0^0 is undefined.") 
 849  if self == 0 and e == 0: 
 850  return self.parent(1) 
 851  
839  852  cdef Polynomial_dense_modn_ntl_zz r = self._new() 
840  853  cdef zz_pX_Modulus_c *mod 
841  854  
… 
… 

1375  1388  sage: R.<x> = Integers(10^30)[] 
1376  1389  sage: (x+1)^5 
1377  1390  x^5 + 5*x^4 + 10*x^3 + 10*x^2 + 5*x + 1 
 1391  
 1392  We define ``0^0`` to be unity, :trac:`13895`:: 
 1393  
 1394  sage: R.<x> = PolynomialRing(Integers(10^30), implementation='NTL') 
 1395  sage: R(0)^0 
 1396  1 
 1397  
 1398  The value returned from ``0^0`` should belong to our ring:: 
 1399  
 1400  sage: R.<x> = PolynomialRing(Integers(10^30), implementation='NTL') 
 1401  sage: type(R(0)^0) == type(R(0)) 
 1402  True 
 1403  
1378  1404  """ 
1379  1405  cdef bint recip = 0, do_sig 
1380  1406  cdef long e = ee 
… 
… 

1383  1409  elif e < 0: 
1384  1410  recip = 1 # delay because powering frac field elements is slow 
1385  1411  e = e 
1386   if not self: 
1387   if e == 0: 
1388   raise ArithmeticError("0^0 is undefined.") 
 1412  if self == 0 and e == 0: 
 1413  return self.parent(1) 
1389  1414  cdef Polynomial_dense_modn_ntl_ZZ r = self._new() 
1390  1415  cdef ZZ_pX_Modulus_c *mod 
1391  1416  