コード例 #1
0
ファイル: local_generic.py プロジェクト: sagemathinc/smc-sage
    def __init__(self, base, prec, names, element_class, category=None):
        """
        Initializes self.

        EXAMPLES::

            sage: R = Zp(5) #indirect doctest
            sage: R.precision_cap()
            20

        In :trac:`14084`, the category framework has been implemented for p-adic rings::

            sage: TestSuite(R).run()
            sage: K = Qp(7)
            sage: TestSuite(K).run()

        TESTS::

            sage: R = Zp(5, 5, 'fixed-mod')
            sage: R._repr_option('element_is_atomic')
            False
        """
        self._prec = prec
        self.Element = element_class
        default_category = getattr(self, '_default_category', None)
        if self.is_field():
            category = CompleteDiscreteValuationFields()
        else:
            category = CompleteDiscreteValuationRings()
        if default_category is not None:
            category = check_default_category(default_category, category)
        Parent.__init__(self, base, names=(names,), normalize=False, category=category, element_constructor=element_class)
コード例 #2
0
class LaurentSeriesRing_field(LaurentSeriesRing_generic, ring.Field):
    """
    Laurent series ring over a field.

    TESTS::

        sage: TestSuite(LaurentSeriesRing(QQ,'t')).run()
    """
    _default_category = CompleteDiscreteValuationFields()
コード例 #3
0
    def __init__(self, power_series):
        """
        Initialization

        EXAMPLES::

            sage: K.<q> = LaurentSeriesRing(QQ, default_prec=4); K
            Laurent Series Ring in q over Rational Field
            sage: 1 / (q-q^2)
            q^-1 + 1 + q + q^2 + O(q^3)

            sage: RZZ = LaurentSeriesRing(ZZ, 't')
            sage: RZZ.category()
            Category of infinite commutative no zero divisors algebras over (euclidean domains and infinite enumerated sets and metric spaces)
            sage: TestSuite(RZZ).run()

            sage: R1 = LaurentSeriesRing(Zmod(1), 't')
            sage: R1.category()
            Category of finite commutative algebras over (finite commutative rings and subquotients of monoids and quotients of semigroups and finite enumerated sets)
            sage: TestSuite(R1).run()

            sage: R2 = LaurentSeriesRing(Zmod(2), 't')
            sage: R2.category()
            Join of Category of complete discrete valuation fields and Category of commutative algebras over (finite enumerated fields and subquotients of monoids and quotients of semigroups) and Category of infinite sets
            sage: TestSuite(R2).run()

            sage: R4 = LaurentSeriesRing(Zmod(4), 't')
            sage: R4.category()
            Category of infinite commutative algebras over (finite commutative rings and subquotients of monoids and quotients of semigroups and finite enumerated sets)
            sage: TestSuite(R4).run()

            sage: RQQ = LaurentSeriesRing(QQ, 't')
            sage: RQQ.category()
            Join of Category of complete discrete valuation fields and Category of commutative algebras over (number fields and quotient fields and metric spaces) and Category of infinite sets
            sage: TestSuite(RQQ).run()
        """
        base_ring = power_series.base_ring()
        category = Algebras(base_ring.category())
        if base_ring in Fields():
            category &= CompleteDiscreteValuationFields()
        elif base_ring in IntegralDomains():
            category &= IntegralDomains()
        elif base_ring in Rings().Commutative():
            category = category.Commutative()

        if base_ring.is_zero():
            category = category.Finite()
        else:
            category = category.Infinite()

        self._power_series_ring = power_series
        self._one_element = self.element_class(self, power_series.one())
        CommutativeRing.__init__(self,
                                 base_ring,
                                 names=power_series.variable_names(),
                                 category=category)
コード例 #4
0
class LaurentSeriesRing_field(LaurentSeriesRing_generic, ring.Field):
    _default_category = CompleteDiscreteValuationFields()

    def __init__(self, base_ring, name=None, default_prec=None, sparse=False):
        """
        Initialization

        TESTS::

            sage: TestSuite(LaurentSeriesRing(QQ,'t')).run()
        """
        LaurentSeriesRing_generic.__init__(self, base_ring, name, default_prec, sparse)
コード例 #5
0
    def __init__(self, power_series):
        """
        Initialization

        EXAMPLES::

            sage: K.<q> = LaurentSeriesRing(QQ, default_prec=4); K
            Laurent Series Ring in q over Rational Field
            sage: 1 / (q-q^2)
            q^-1 + 1 + q + q^2 + O(q^3)

            sage: RZZ = LaurentSeriesRing(ZZ, 't')
            sage: RZZ.category()
            Category of infinite integral domains
            sage: TestSuite(RZZ).run()

            sage: R1 = LaurentSeriesRing(Zmod(1), 't')
            sage: R1.category()
            Category of finite commutative rings
            sage: TestSuite(R1).run()

            sage: R2 = LaurentSeriesRing(Zmod(2), 't')
            sage: R2.category()
            Category of infinite complete discrete valuation fields
            sage: TestSuite(R2).run()

            sage: R4 = LaurentSeriesRing(Zmod(4), 't')
            sage: R4.category()
            Category of infinite commutative rings
            sage: TestSuite(R4).run()

            sage: RQQ = LaurentSeriesRing(QQ, 't')
            sage: RQQ.category()
            Category of infinite complete discrete valuation fields
            sage: TestSuite(RQQ).run()
        """
        base_ring = power_series.base_ring()
        if base_ring in Fields():
            category = CompleteDiscreteValuationFields()
        elif base_ring in IntegralDomains():
            category = IntegralDomains()
        elif base_ring in Rings().Commutative():
            category = Rings().Commutative()
        else:
            raise ValueError('unrecognized base ring')

        if base_ring.is_zero():
            category = category.Finite()
        else:
            category = category.Infinite()

        CommutativeRing.__init__(self,
                                 base_ring,
                                 names=power_series.variable_names(),
                                 category=category)

        self._power_series_ring = power_series
コード例 #6
0
    def __init__(self, base_ring, names, sparse=True, category=None):
        """
        Initialize ``self``.

        TESTS::

            sage: L = LazyLaurentSeriesRing(ZZ, 't')
            sage: elts = L.some_elements()[:-2]  # skip the non-exact elements
            sage: TestSuite(L).run(elements=elts, skip=['_test_elements', '_test_associativity', '_test_distributivity', '_test_zero'])
            sage: L.category()
            Category of infinite commutative no zero divisors algebras over
             (euclidean domains and infinite enumerated sets and metric spaces)

            sage: L = LazyLaurentSeriesRing(QQ, 't')
            sage: L.category()
            Join of Category of complete discrete valuation fields
             and Category of commutative algebras over (number fields and quotient fields and metric spaces)
             and Category of infinite sets
            sage: L = LazyLaurentSeriesRing(ZZ['x,y'], 't')
            sage: L.category()
            Category of infinite commutative no zero divisors algebras over
             (unique factorization domains and commutative algebras over
              (euclidean domains and infinite enumerated sets and metric spaces)
              and infinite sets)
            sage: E.<x,y> = ExteriorAlgebra(QQ)
            sage: L = LazyLaurentSeriesRing(E, 't')  # not tested
        """
        self._sparse = sparse
        self._coeff_ring = base_ring
        # We always use the dense because our CS_exact is implemented densely
        self._laurent_poly_ring = LaurentPolynomialRing(base_ring, names)
        self._internal_poly_ring = self._laurent_poly_ring

        category = Algebras(base_ring.category())
        if base_ring in Fields():
            category &= CompleteDiscreteValuationFields()
        else:
            if "Commutative" in base_ring.category().axioms():
                category = category.Commutative()
            if base_ring in IntegralDomains():
                category &= IntegralDomains()

        if base_ring.is_zero():
            category = category.Finite()
        else:
            category = category.Infinite()

        Parent.__init__(self, base=base_ring, names=names, category=category)
コード例 #7
0
from sage.rings.integer import Integer
from sage.rings.finite_rings.finite_field_base import is_FiniteField
from sage.rings.finite_rings.integer_mod_ring import is_IntegerModRing

from sage.misc.cachefunc import weak_cached_function

from sage.categories.fields import Fields

_Fields = Fields()
from sage.categories.commutative_rings import CommutativeRings

_CommutativeRings = CommutativeRings()
from sage.categories.complete_discrete_valuation import CompleteDiscreteValuationRings, CompleteDiscreteValuationFields

_CompleteDiscreteValuationRings = CompleteDiscreteValuationRings()
_CompleteDiscreteValuationFields = CompleteDiscreteValuationFields()

import sage.misc.weak_dict

_cache = sage.misc.weak_dict.WeakValueDictionary()


# The signature for this function is too complicated to express sensibly
# in any other way besides *args and **kwds (in Python 3 or Cython, we
# could probably do better thanks to PEP 3102).
def PolynomialRing(base_ring, *args, **kwds):
    r"""
    Return the globally unique univariate or multivariate polynomial
    ring with given properties and variable name or names.

    There are many ways to specify the variables for the polynomial ring:
コード例 #8
0
class PuiseuxSeriesRing_field(PuiseuxSeriesRing_generic, Field):
    _default_category = CompleteDiscreteValuationFields()

    def __init__(self, base_ring, name=None, default_prec=None, sparse=False):
        PuiseuxSeriesRing_generic.__init__(self, base_ring, name, default_prec, sparse)