# HG changeset patch
# User Peter Bruin <peter.bruin@math.uzh.ch>
# Date 1372186250 7200
# Node ID 641e5b0716af72a1bcb7e9d9338a3d88a998557c
# Parent 739c6c4c4f751f2fe95f291c9b4e75cd7e51e4c2
Trac 14832: new class PolynomialRing_dense_finite_field
diff git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py
a

b


1404  1404  PolynomialRing_singular_repr, 
1405  1405  principal_ideal_domain.PrincipalIdealDomain, 
1406  1406  ): 
1407   def __init__(self, base_ring, name="x", sparse=False, element_class=None, implementation=None): 
 1407  def __init__(self, base_ring, name="x", sparse=False, element_class=None): 
1408  1408  """ 
1409  1409  TESTS: 
1410  1410  sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_field as PRing 
… 
… 

1426  1426  sage: x^(10^20) # this should be fast 
1427  1427  x^100000000000000000000 
1428  1428  """ 
1429   from sage.rings.finite_rings.finite_field_base import is_FiniteField 
1430   from sage.rings.rational_field import QQ 
1431  1429  from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular 
1432   if implementation is None: 
1433   implementation = "NTL" 
1434   
1435   if implementation == "NTL" and is_FiniteField(base_ring) and not(sparse): 
1436   from sage.libs.ntl.ntl_ZZ_pEContext import ntl_ZZ_pEContext 
1437   from sage.libs.ntl.ntl_ZZ_pX import ntl_ZZ_pX 
1438   from sage.rings.polynomial.polynomial_zz_pex import Polynomial_ZZ_pEX 
1439   
1440   p=base_ring.characteristic() 
1441   self._modulus = ntl_ZZ_pEContext(ntl_ZZ_pX(list(base_ring.polynomial()), p)) 
1442   element_class = Polynomial_ZZ_pEX 
1443  1430  
1444  1431  if not element_class: 
1445  1432  if sparse: 
… 
… 

1798  1785  self._fraction_field = FractionField_1poly_field(self) 
1799  1786  return self._fraction_field 
1800  1787  
 1788  class PolynomialRing_dense_finite_field(PolynomialRing_field): 
 1789  """ 
 1790  Univariate polynomial ring over a finite field. 
 1791  
 1792  EXAMPLE:: 
 1793  
 1794  sage: R = PolynomialRing(GF(27, 'a'), 'x') 
 1795  sage: type(R) 
 1796  <class 'sage.rings.polynomial.polynomial_ring.PolynomialRing_dense_finite_field_with_category'> 
 1797  """ 
 1798  def __init__(self, base_ring, name="x", element_class=None, implementation=None): 
 1799  if implementation is None: 
 1800  implementation = "NTL" 
 1801  
 1802  if implementation == "NTL": 
 1803  from sage.libs.ntl.ntl_ZZ_pEContext import ntl_ZZ_pEContext 
 1804  from sage.libs.ntl.ntl_ZZ_pX import ntl_ZZ_pX 
 1805  from sage.rings.polynomial.polynomial_zz_pex import Polynomial_ZZ_pEX 
 1806  
 1807  p=base_ring.characteristic() 
 1808  self._modulus = ntl_ZZ_pEContext(ntl_ZZ_pX(list(base_ring.polynomial()), p)) 
 1809  element_class = Polynomial_ZZ_pEX 
 1810  
 1811  PolynomialRing_field.__init__(self, base_ring, sparse=False, name=name, 
 1812  element_class=element_class) 
 1813  
1801  1814  class PolynomialRing_dense_padic_ring_generic(PolynomialRing_integral_domain): 
1802  1815  pass 
1803  1816  
… 
… 

1995  2008  return s + self._implementation_repr 
1996  2009  
1997  2010  
1998   class PolynomialRing_dense_mod_p(PolynomialRing_field, 
 2011  class PolynomialRing_dense_mod_p(PolynomialRing_dense_finite_field, 
1999  2012  PolynomialRing_dense_mod_n, 
2000  2013  PolynomialRing_singular_repr): 
2001  2014  def __init__(self, base_ring, name="x", implementation=None): 