diff --git a/src/sage/misc/classgraph.py b/src/sage/misc/classgraph.py index 6986f741e27..3281146e558 100644 --- a/src/sage/misc/classgraph.py +++ b/src/sage/misc/classgraph.py @@ -34,11 +34,11 @@ def class_graph(top, depth=5, name_filter=None, classes=None, as_graph = True): sage: from sage.rings.polynomial.padics import polynomial_padic_capped_relative_dense, polynomial_padic_flat sage: G = class_graph(sage.rings.polynomial.padics); G - Digraph on 4 vertices + Digraph on 8 vertices sage: G.vertices() - ['Polynomial_generic_dense', 'Polynomial_generic_domain', 'Polynomial_padic_capped_relative_dense', 'Polynomial_padic_flat'] + ['Polynomial_generic_dense', 'Polynomial_generic_dense_field', 'Polynomial_generic_domain', 'Polynomial_padic', 'Polynomial_padic_capped_relative_dense', 'Polynomial_padic_flat', 'Polynomial_padic_generic_field', 'Polynomial_padic_generic_ring'] sage: G.edges(labels=False) - [('Polynomial_padic_capped_relative_dense', 'Polynomial_generic_domain'), ('Polynomial_padic_flat', 'Polynomial_generic_dense')] + [('Polynomial_padic', 'Polynomial_generic_domain'), ('Polynomial_padic_capped_relative_dense', 'Polynomial_padic'), ('Polynomial_padic_flat', 'Polynomial_padic_generic_ring'), ('Polynomial_padic_generic_field', 'Polynomial_generic_dense_field'), ('Polynomial_padic_generic_field', 'Polynomial_padic'), ('Polynomial_padic_generic_ring', 'Polynomial_generic_dense'), ('Polynomial_padic_generic_ring', 'Polynomial_generic_domain'), ('Polynomial_padic_generic_ring', 'Polynomial_padic')] We construct the inheritance graph of a given class:: diff --git a/src/sage/rings/polynomial/padics/polynomial_padic.py b/src/sage/rings/polynomial/padics/polynomial_padic.py new file mode 100644 index 00000000000..a4f5baf5e30 --- /dev/null +++ b/src/sage/rings/polynomial/padics/polynomial_padic.py @@ -0,0 +1,57 @@ +r""" +Common base class for all polynomials over `p`-adic rings + +AUTHORS: + +- Julian Rueth (2013-09-12): initial version + +""" +#***************************************************************************** +# Copyright (C) 2013 Julian Rueth +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** +from sage.rings.polynomial.polynomial_element_generic import Polynomial_generic_domain + +class Polynomial_padic(Polynomial_generic_domain): + r""" + A polynomial over a `p`-adic ring. + + INPUT: + + - ``parent`` -- a polynomial ring over a `p`-adic ring + + - ``is_gen`` -- whether this is the generator of the polynomial ring + (default: ``False``) + + .. NOTE:: + + In contrast to :class:`polynomial_padic.Polynomial_padic_generic` + (which inherits from this class), this class is meant as a base class + for implementations which provide their own handling of the polynomial + data. + + EXAMPLES:: + + sage: R. = Zp(3)[] # indirect doctest + sage: from sage.rings.polynomial.padics.polynomial_padic import Polynomial_padic + sage: isinstance(x, Polynomial_padic) + True + + """ + def __init__(self, parent, is_gen=False): + r""" + Initialization. + + TESTS:: + + sage: from sage.rings.polynomial.padics.polynomial_padic import Polynomial_padic + sage: R. = Zp(3)[] + sage: type(Polynomial_padic(R)) + + + """ + Polynomial_generic_domain.__init__(self, parent, is_gen=is_gen) diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py index 0aa14f258ad..42af8b330a5 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py @@ -1,6 +1,25 @@ +r""" +`p`-adic polynomials with capped relative precision + +This module provides classes for `p`-adic polynomials over a ring with capped +relative precision. + +AUTHORS: + +- David Roe (2007): initial version + +- Julian Rueth (2013- 09-12): added some docstrings and cleanup of the inheritance + """ -p-adic Capped Relative Dense Polynomials -""" +#***************************************************************************** +# Copyright (C) 2007-2008 David Roe +# 2012-2013 Julian Rueth +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** import sage.rings.polynomial.polynomial_element_generic from sage.rings.polynomial.polynomial_element import Polynomial @@ -16,17 +35,53 @@ from sage.libs.ntl.all import ZZX from sage.structure.factorization import Factorization from sage.rings.infinity import infinity +from polynomial_padic_generic import Polynomial_padic min = misc.min ZZ = sage.rings.integer_ring.ZZ PrecisionError = precision_error.PrecisionError Integer = sage.rings.integer.Integer -Polynomial_generic_domain = sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_domain Polynomial_integer_dense = sage.rings.polynomial.polynomial_integer_dense_ntl.Polynomial_integer_dense_ntl -class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain): +class Polynomial_padic_capped_relative_dense(Polynomial_padic): + r""" + A polynomial over a `p`-adic base ring with capped relative precision. + Every coefficient of this polynomial can have its own relative precision, + however, the class keeps track of the precision data of the coefficients. + + INPUT: + + - ``parent`` -- a polynomial ring over a `p`-adic ring + + - ``x`` -- data to construct a polynomial (default: ``None``) + + - ``check`` -- a boolean (default: ``True``), whether to make sure that all + coefficients are in the `p`-adic base ring + + - ``is_gen`` -- a boolean (default: ``False``), whether this is the + generator of the polynomial ring + + - ``construct`` -- a boolean (default: ``False``), used internally, if + ``True``, then ``x`` contains the attributes of a polynomial + + - ``absprec`` -- an integer or ``infinity`` (default: ``infinity``), every + coefficient is capped to this absolute precision + + - ``absprec`` -- an integer or ``infinity`` (default: ``infinity``), every + coefficient is capped to this relative precision + + EXAMPLES:: + + sage: from sage.rings.polynomial.padics.polynomial_padic_capped_relative_dense import Polynomial_padic_capped_relative_dense + sage: R. = Qp(3)[] # indirect doctest + sage: isinstance(x, Polynomial_padic_capped_relative_dense) + True + + """ def __init__(self, parent, x=None, check=True, is_gen=False, construct = False, absprec = infinity, relprec = infinity): """ + Initialization. + TESTS:: sage: K = Qp(13,7) @@ -37,7 +92,7 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct = False, sage: R(t + 2) (1 + O(13^7))*t + (2 + O(13^7)) """ - Polynomial.__init__(self, parent, is_gen=is_gen) + Polynomial_padic.__init__(self, parent, is_gen=is_gen) parentbr = parent.base_ring() from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing if construct: diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_flat.py b/src/sage/rings/polynomial/padics/polynomial_padic_flat.py index f8be64ff7d8..fa475ed3b00 100644 --- a/src/sage/rings/polynomial/padics/polynomial_padic_flat.py +++ b/src/sage/rings/polynomial/padics/polynomial_padic_flat.py @@ -1,18 +1,74 @@ +r""" +`p`-adic polynomials with a flat precision + +This module provides classes for `p`-adic polynomials with a flat precision, +i.e., the absolute precision is the same for all coefficients of the +polynomial. + +AUTHORS: + +- Julian Rueth (2013- 09-12): added some docstrings and cleanup of the inheritance + +""" from sage.rings.integer import Integer -from sage.rings.polynomial.polynomial_element import Polynomial_generic_dense, Polynomial from sage.rings.infinity import infinity from sage.libs.all import pari_gen from sage.structure.factorization import Factorization +from polynomial_padic_generic import Polynomial_padic_generic_ring import sage.rings.padics.misc +#***************************************************************************** +# Copyright (C) 2008 David Roe +# 2008 John Cremona +# 2013 Julian Rueth +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** + +class Polynomial_padic_flat(Polynomial_padic_generic_ring): + r""" + A polynomial with a flat precision over a `p`-adic base ring. + + INPUT: + + - ``parent`` -- a polynomial ring over a `p`-adic ring + + - ``x`` -- data to construct a polynomial (default: ``None``) + + - ``check`` -- a boolean (default: ``True``), whether to make sure that all + coefficients are in the `p`-adic base ring -class Polynomial_padic_flat(Polynomial_generic_dense): + - ``is_gen`` -- a boolean (default: ``False``), whether this is the + generator of the polynomial ring + + - ``construct`` -- a boolean (default: ``False``), unused + + - ``absprec`` -- an integer or ``None`` (default: ``None``), if given, + every coefficient is capped to this precision + + EXAMPLES:: + + sage: from sage.rings.polynomial.padics.polynomial_padic_flat import Polynomial_padic_flat + sage: R. = ZpFM(3)[] # indirect doctest + sage: isinstance(x, Polynomial_padic_flat) + True + + """ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None): """ - Initialization function for the class Polynomial_padic_flat. - """ + Initialization. + + TESTS:: + sage: R. = ZpFM(3)[] + sage: type(x) + + + """ if x is None: - Polynomial_generic_dense.__init__(self, parent, x = None, is_gen = is_gen) + Polynomial_padic_generic_ring.__init__(self, parent, x = None, is_gen = is_gen) return R = parent.base_ring() if sage.rings.fraction_field_element.is_FractionFieldElement(x): @@ -20,6 +76,7 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab raise TypeError, "denominator must be 1" else: x = x.numerator() + from sage.rings.polynomial.polynomial_element import Polynomial if isinstance(x, Polynomial): if x.base_ring() is R: x = list(x.list()) @@ -42,7 +99,7 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab m = sage.rings.padics.misc.min(a.precision_absolute() for a in x.values()) if not absprec is None: m = min(m, absprec) - Polynomial_generic_dense.__init__(self, parent, x, absprec = m) + Polynomial_generic_dense_ring.__init__(self, parent, x, absprec = m) return elif isinstance(x, pari_gen): x = [R(w) for w in x.list()] @@ -51,7 +108,7 @@ def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, ab if absprec is None: absprec = infinity m = min([a.precision_absolute() for a in x] + [absprec]) - Polynomial_generic_dense.__init__(self, parent, x, absprec = m) + Polynomial_padic_generic_ring.__init__(self, parent, x) def _mul_(self, right): """ diff --git a/src/sage/rings/polynomial/padics/polynomial_padic_generic.py b/src/sage/rings/polynomial/padics/polynomial_padic_generic.py new file mode 100644 index 00000000000..b06d6ff98e5 --- /dev/null +++ b/src/sage/rings/polynomial/padics/polynomial_padic_generic.py @@ -0,0 +1,122 @@ +r""" +Common implementation for polynomials over `p`-adic rings + +AUTHORS: + +- Julian Rueth (2013-09-12): initial version + +""" +#***************************************************************************** +# Copyright (C) 2013 Julian Rueth +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# http://www.gnu.org/licenses/ +#***************************************************************************** +from sage.rings.polynomial.polynomial_element import Polynomial_generic_dense +from sage.rings.polynomial.polynomial_element_generic import Polynomial_generic_dense_field, Polynomial_generic_domain +from polynomial_padic import Polynomial_padic + +class Polynomial_padic_generic_ring(Polynomial_padic, Polynomial_generic_domain, Polynomial_generic_dense): + r""" + A polynomial over a `p`-adic ring which is not a field. + + INPUT: + + - ``parent`` -- a polynomial ring over a `p`-adic ring + + - ``x`` -- data which can be used to construct a polynomial + + - ``check`` -- a boolean (default: ``True``), unused + + - ``is_gen`` -- whether this is the generator of the polynomial ring + (default: ``False``) + + - ``construct`` -- a boolean (default: ``False``), unused + + - ``absprec`` -- an integer or ``None`` (default: ``None``), unused + + .. NOTE:: + + In contrast to :class:`polynomial_padic.Polynomial_padic`, this class + is meant as a base class for implementations which want to use the + generic handling of the polynomial data from + :class:`sage.rings.polynomial.polynomial_element.Polynomial_generic_dense`. + + EXAMPLES:: + + sage: R. = ZpFM(3)[] # indirect doctest + sage: from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_ring + sage: isinstance(x, Polynomial_padic_generic_ring) + True + + """ + def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None): + r""" + Initialization. + + TESTS:: + + sage: from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_ring + sage: R. = ZpFM(3)[] + sage: type(Polynomial_padic_generic_ring(R, None)) + + + """ + Polynomial_padic.__init__(self, parent, is_gen=is_gen) + Polynomial_generic_domain.__init__(self, parent, is_gen=is_gen) + Polynomial_generic_dense.__init__(self, parent, x) + +class Polynomial_padic_generic_field(Polynomial_padic, Polynomial_generic_dense_field): + r""" + A polynomial over a `p`-adic field. + + INPUT: + + - ``parent`` -- a polynomial ring over a `p`-adic ring + + - ``x`` -- data which can be used to construct a polynomial + + - ``check`` -- a boolean (default: ``True``), unused + + - ``is_gen`` -- whether this is the generator of the polynomial ring + (default: ``False``) + + - ``construct`` -- a boolean (default: ``False``), unused + + - ``absprec`` -- an integer or ``None`` (default: ``None``), unused + + .. NOTE:: + + In contrast to :class:`polynomial_padic.Polynomial_padic`, this class + is meant as a base class for implementations which want to use the + generic handling of the polynomial data from + :class:`sage.rings.polynomial.polynomial_element.Polynomial_generic_dense`. + + EXAMPLES:: + + sage: R. = Qp(3)[] + sage: L. = Qp(3).extension(a^2 - 3) + sage: R. = L[] # indirect doctest + sage: from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_field + sage: isinstance(x, Polynomial_padic_generic_field) + True + + """ + def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None): + r""" + Initialization. + + TESTS:: + + sage: from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_field + sage: R. = Qp(3)[] + sage: L. = Qp(3).extension(a^2 - 3) + sage: R. = L[] + sage: type(Polynomial_padic_generic_field(R, None)) + + + """ + Polynomial_padic.__init__(self, parent, is_gen=is_gen) + Polynomial_generic_dense_field.__init__(self, parent, x) diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py index 69f0739b5c5..3937406a4de 100644 --- a/src/sage/rings/polynomial/polynomial_ring.py +++ b/src/sage/rings/polynomial/polynomial_ring.py @@ -1,4 +1,3 @@ - """ Univariate Polynomial Rings @@ -18,6 +17,8 @@ - Simon King (2011-10): Choice of categories for polynomial rings. +- Julian Rueth (2013-09-12): simplified classes for `p`-adic base rings + EXAMPLES: Creating a polynomial ring injects the variable into the interpreter namespace:: @@ -146,13 +147,11 @@ sage: type(CC['t']['x'].0) """ - - ################################################################################# # Copyright (C) 2006 William Stein +# 2013 Julian Rueth # # Distributed under the terms of the GNU General Public License (GPL) -# # http://www.gnu.org/licenses/ #***************************************************************************** @@ -1862,122 +1861,32 @@ def irreducible_element(self, n, algorithm=None): raise ValueError("no such algorithm for finding an irreducible polynomial: %s" % algorithm) class PolynomialRing_dense_padic_ring_generic(PolynomialRing_integral_domain): - pass - -class PolynomialRing_dense_padic_field_generic(PolynomialRing_field): - pass - -class PolynomialRing_dense_padic_ring_capped_relative(PolynomialRing_dense_padic_ring_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: - - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_ring_capped_relative as PRing - sage: R = PRing(Zp(13), name='t'); R - Univariate Polynomial Ring in t over 13-adic Ring with capped relative precision 20 - sage: type(R.gen()) - - """ - if element_class is None: - from sage.rings.polynomial.padics.\ - polynomial_padic_capped_relative_dense import \ - Polynomial_padic_capped_relative_dense - element_class = Polynomial_padic_capped_relative_dense - PolynomialRing_dense_padic_ring_generic.__init__(self, base_ring, - name=name, element_class=element_class) + r""" + A polynomial ring over a `p`-adic ring which is not a field. -class PolynomialRing_dense_padic_ring_capped_absolute(PolynomialRing_dense_padic_ring_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: - - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_ring_capped_absolute as PRing - sage: R = PRing(Zp(13, type='capped-abs'), name='t'); R - Univariate Polynomial Ring in t over 13-adic Ring with capped absolute precision 20 - sage: type(R.gen()) - - """ - if element_class is None: - from sage.rings.polynomial.padics.polynomial_padic_flat import \ - Polynomial_padic_flat - element_class = Polynomial_padic_flat - PolynomialRing_dense_padic_ring_generic.__init__(self, base_ring, - name=name, element_class=element_class) + TESTS:: -class PolynomialRing_dense_padic_ring_fixed_mod(PolynomialRing_dense_padic_ring_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: - - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_ring_fixed_mod as PRing - sage: R = PRing(Zp(13, type='fixed-mod'), name='t'); R - Univariate Polynomial Ring in t over 13-adic Ring of fixed modulus 13^20 - - sage: type(R.gen()) - - """ - if element_class is None: - from sage.rings.polynomial.padics.polynomial_padic_flat import \ - Polynomial_padic_flat - element_class = Polynomial_padic_flat - PolynomialRing_dense_padic_ring_generic.__init__(self, base_ring, - name=name, element_class=element_class) - -class PolynomialRing_dense_padic_ring_lazy(PolynomialRing_dense_padic_ring_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: - - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_ring_lazy as PRing - sage: R = PRing(Zp(13, type='lazy'), name='t') - Traceback (most recent call last): - ... - NotImplementedError: lazy p-adics need more work. Sorry. - - #sage: type(R.gen()) - - """ - if element_class is None: - element_class = polynomial_element_generic.Polynomial_generic_dense - PolynomialRing_dense_padic_ring_generic.__init__(self, base_ring, - name=name, element_class=element_class) + sage: R. = Zp(3)[] + sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_ring_generic + sage: isinstance(R, PolynomialRing_dense_padic_ring_generic) + True -class PolynomialRing_dense_padic_field_capped_relative(PolynomialRing_dense_padic_field_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: + """ + pass - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_field_capped_relative as PRing - sage: R = PRing(Qp(13), name='t'); R - Univariate Polynomial Ring in t over 13-adic Field with capped relative precision 20 - sage: type(R.gen()) - - """ - if element_class is None: - from sage.rings.polynomial.padics.\ - polynomial_padic_capped_relative_dense import \ - Polynomial_padic_capped_relative_dense - element_class = Polynomial_padic_capped_relative_dense - PolynomialRing_dense_padic_field_generic.__init__(self, base_ring, - name=name, element_class=element_class) +class PolynomialRing_dense_padic_field_generic(PolynomialRing_field): + r""" + A polynomial ring over a `p`-adic field. -class PolynomialRing_dense_padic_field_lazy(PolynomialRing_dense_padic_field_generic): - def __init__(self, base_ring, name=None, element_class=None): - """ - TESTS:: + TESTS:: - sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_field_lazy as PRing - sage: R = PRing(Qp(13, type='lazy'), name='t') - Traceback (most recent call last): - ... - NotImplementedError: lazy p-adics need more work. Sorry. + sage: R. = Qp(3)[] + sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_field_generic + sage: isinstance(R, PolynomialRing_dense_padic_field_generic) + True - #sage: type(R.gen()) - """ - if element_class is None: - element_class = polynomial_element_generic.Polynomial_generic_dense - PolynomialRing_dense_padic_field_generic.__init__(self, base_ring, - name=name, element_class=element_class) + """ + pass class PolynomialRing_dense_mod_n(PolynomialRing_commutative): def __init__(self, base_ring, name=None, element_class=None, diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py index 625c016ac61..c4b1d6f8a3e 100644 --- a/src/sage/rings/polynomial/polynomial_ring_constructor.py +++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py @@ -13,31 +13,18 @@ constructor :func:`MPolynomialRing` (now subsumed by the generic :meth:`PolynomialRing`. """ - ################################################################# -# -# Sage: System for Algebra and Geometry Experimentation -# # Copyright (C) 2006 William Stein +# 2013 Julian Rueth # # Distributed under the terms of the GNU General Public License (GPL) -# -# This code is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# The full text of the GPL is available at: -# # http://www.gnu.org/licenses/ -# ###################################################################### - from sage.structure.parent_gens import normalize_names from sage.structure.element import is_Element import sage.rings.ring as ring -import sage.rings.padics.padic_base_leaves as padic_base_leaves +import sage.rings.padics.padic_generic from sage.rings.integer import Integer from sage.rings.finite_rings.constructor import is_FiniteField @@ -517,6 +504,41 @@ def _save_in_cache(key, R): def _single_variate(base_ring, name, sparse, implementation): + r""" + Return a univariate polynomial ring over ``base_ring`` in ``name``. + + INPUT: + + - ``base_ring`` -- a ring + + - ``name`` -- a string + + - ``sparse`` -- a boolean, whether the implementation should be optimized + for sparse polynomials + + - ``implementation`` -- a string or ``None``, for some values of ``base_ring``, + multiple implementations are available for the polynomial elements. This + parameter can be used to select a specific one. + + EXAMPLES:: + + sage: from sage.rings.polynomial.polynomial_ring_constructor import _single_variate + + sage: _single_variate(ZZ, name='x', sparse=False, implementation=None) + Univariate Polynomial Ring in x over Integer Ring + sage: _single_variate(ZZ, name='x', sparse=True, implementation=None) + Sparse Univariate Polynomial Ring in x over Integer Ring + + sage: _single_variate(ZpFM(3), name='x', sparse=False, implementation=None) + Univariate Polynomial Ring in x over 3-adic Ring of fixed modulus 3^20 + sage: _single_variate(ZpCA(3), name='x', sparse=False, implementation=None) + Univariate Polynomial Ring in x over 3-adic Ring with capped absolute precision 20 + sage: _single_variate(ZpCR(3), name='x', sparse=False, implementation=None) + Univariate Polynomial Ring in x over 3-adic Ring with capped relative precision 20 + sage: _single_variate(QpCR(3), name='x', sparse=False, implementation=None) + Univariate Polynomial Ring in x over 3-adic Field with capped relative precision 20 + + """ import sage.rings.polynomial.polynomial_ring as m name = normalize_names(1, name) key = (base_ring, name, sparse, implementation if not sparse else None) @@ -537,17 +559,29 @@ def _single_variate(base_ring, name, sparse, implementation): elif is_FiniteField(base_ring) and not sparse: R = m.PolynomialRing_dense_finite_field(base_ring, name, implementation=implementation) - elif isinstance(base_ring, padic_base_leaves.pAdicFieldCappedRelative): - R = m.PolynomialRing_dense_padic_field_capped_relative(base_ring, name) + elif isinstance(base_ring, sage.rings.padics.padic_generic.pAdicGeneric): + if sparse: + pass # ignored + if implementation is not None: + pass # ignored - elif isinstance(base_ring, padic_base_leaves.pAdicRingCappedRelative): - R = m.PolynomialRing_dense_padic_ring_capped_relative(base_ring, name) - - elif isinstance(base_ring, padic_base_leaves.pAdicRingCappedAbsolute): - R = m.PolynomialRing_dense_padic_ring_capped_absolute(base_ring, name) - - elif isinstance(base_ring, padic_base_leaves.pAdicRingFixedMod): - R = m.PolynomialRing_dense_padic_ring_fixed_mod(base_ring, name) + if base_ring.is_field(): + R = m.PolynomialRing_dense_padic_field_generic + from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_field + element_class = Polynomial_padic_generic_field + else: + from sage.rings.polynomial.padics.polynomial_padic_generic import Polynomial_padic_generic_ring + R = m.PolynomialRing_dense_padic_ring_generic + element_class = Polynomial_padic_generic_ring + + if base_ring.ground_ring_of_tower() is base_ring and (base_ring.is_fixed_mod() or base_ring.is_capped_absolute()): + from sage.rings.polynomial.padics.polynomial_padic_flat import Polynomial_padic_flat + element_class = Polynomial_padic_flat + elif base_ring.ground_ring_of_tower() is base_ring and base_ring.is_capped_relative(): + from sage.rings.polynomial.padics.polynomial_padic_capped_relative_dense import Polynomial_padic_capped_relative_dense + element_class = Polynomial_padic_capped_relative_dense + + R = R(base_ring, name, element_class=element_class) elif base_ring.is_field(proof = False): R = m.PolynomialRing_field(base_ring, name, sparse)