Example #1
0
    def __init__(self,
                 base_ring,
                 name=None,
                 default_prec=20,
                 sparse=False,
                 use_lazy_mpoly_ring=False,
                 category=None):
        """
        Initializes a power series ring.

        INPUT:


        -  ``base_ring`` - a commutative ring

        -  ``name`` - name of the indeterminate

        -  ``default_prec`` - the default precision

        -  ``sparse`` - whether or not power series are
           sparse

        - ``use_lazy_mpoly_ring`` - if base ring is a poly ring compute with
          multivariate polynomials instead of a univariate poly over the base
          ring. Only use this for dense power series where you won't do too
          much arithmetic, but the arithmetic you do must be fast. You must
          explicitly call ``f.do_truncation()`` on an element
          for it to truncate away higher order terms (this is called
          automatically before printing).
        """
        R = PolynomialRing(base_ring, name, sparse=sparse)
        self.__poly_ring = R
        self.__is_sparse = sparse
        self.__params = (base_ring, name, default_prec, sparse)

        if use_lazy_mpoly_ring and (is_MPolynomialRing(base_ring) or \
                                    is_PolynomialRing(base_ring)):
            K = base_ring
            names = K.variable_names() + (name, )
            self.__mpoly_ring = PolynomialRing(K.base_ring(), names=names)
            assert is_MPolynomialRing(self.__mpoly_ring)
            self.Element = power_series_mpoly.PowerSeries_mpoly
        commutative_ring.CommutativeRing.__init__(
            self,
            base_ring,
            names=name,
            category=getattr(self, '_default_category', _CommutativeRings))
        Nonexact.__init__(self, default_prec)
        self.__generator = self.element_class(self,
                                              R.gen(),
                                              check=True,
                                              is_gen=True)
Example #2
0
    def __init__(self, base_ring, name=None, default_prec=20, sparse=False,
                 use_lazy_mpoly_ring=False):
        """
        Initializes a power series ring.
        
        INPUT:
        
        
        -  ``base_ring`` - a commutative ring
        
        -  ``name`` - name of the indeterminate
        
        -  ``default_prec`` - the default precision
        
        -  ``sparse`` - whether or not power series are
           sparse
        
        - ``use_lazy_mpoly_ring`` - if base ring is a poly ring compute with
          multivariate polynomials instead of a univariate poly over the base
          ring. Only use this for dense power series where you won't do too
          much arithmetic, but the arithmetic you do must be fast. You must
          explicitly call ``f.do_truncation()`` on an element
          for it to truncate away higher order terms (this is called
          automatically before printing).
        """
        R = PolynomialRing(base_ring, name, sparse=sparse)
        self.__poly_ring = R
        self.__is_sparse = sparse
        self.__params = (base_ring, name, default_prec, sparse)

        if use_lazy_mpoly_ring and (is_MPolynomialRing(base_ring) or \
                                    is_PolynomialRing(base_ring)):
            K = base_ring
            names = K.variable_names() + (name,)
            self.__mpoly_ring = PolynomialRing(K.base_ring(), names=names)
            assert is_MPolynomialRing(self.__mpoly_ring)
            self.Element = power_series_mpoly.PowerSeries_mpoly
        commutative_ring.CommutativeRing.__init__(self, base_ring, names=name,
                                                  category=getattr(self,'_default_category',
                                                                  _CommutativeRings))
        Nonexact.__init__(self, default_prec)
        self.__generator = self.element_class(self, R.gen(), check=True, is_gen=True)
Example #3
0
    def __init__(self, base_ring, name=None, default_prec=None, sparse=False,
                 use_lazy_mpoly_ring=False, category=None):
        """
        Initializes a power series ring.

        INPUT:


        -  ``base_ring`` - a commutative ring

        -  ``name`` - name of the indeterminate

        -  ``default_prec`` - the default precision

        -  ``sparse`` - whether or not power series are
           sparse

        - ``use_lazy_mpoly_ring`` - if base ring is a poly ring compute with
          multivariate polynomials instead of a univariate poly over the base
          ring. Only use this for dense power series where you won't do too
          much arithmetic, but the arithmetic you do must be fast. You must
          explicitly call ``f.do_truncation()`` on an element
          for it to truncate away higher order terms (this is called
          automatically before printing).
          
        EXAMPLES:
    
        This base class inherits from :class:`~sage.rings.ring.CommutativeRing`.
        Since :trac:`11900`, it is also initialised as such, and since :trac:`14084`
        it is actually initialised as an integral domain::
    
            sage: R.<x> = ZZ[[]]
            sage: R.category()
            Category of integral domains
            sage: TestSuite(R).run()
    
        When the base ring `k` is a field, the ring `k[[x]]` is not only a
        commutative ring, but also a complete discrete valuation ring (CDVR).
        The appropriate (sub)category is automatically set in this case::
    
            sage: k = GF(11)
            sage: R.<x> = k[[]]
            sage: R.category()
            Category of complete discrete valuation rings
            sage: TestSuite(R).run()
        """
        R = PolynomialRing(base_ring, name, sparse=sparse)
        self.__poly_ring = R
        self.__is_sparse = sparse
        if default_prec is None:
            from sage.misc.defaults import series_precision
            default_prec = series_precision()
        self.__params = (base_ring, name, default_prec, sparse)

        if use_lazy_mpoly_ring and (is_MPolynomialRing(base_ring) or \
                                    is_PolynomialRing(base_ring)):
            K = base_ring
            names = K.variable_names() + (name,)
            self.__mpoly_ring = PolynomialRing(K.base_ring(), names=names)
            assert is_MPolynomialRing(self.__mpoly_ring)
            self.Element = power_series_mpoly.PowerSeries_mpoly
        commutative_ring.CommutativeRing.__init__(self, base_ring, names=name,
                                                  category=getattr(self,'_default_category',
                                                                  _CommutativeRings))
        Nonexact.__init__(self, default_prec)
        self.__generator = self.element_class(self, R.gen(), check=True, is_gen=True)
Example #4
0
    def __init__(self,
                 base_ring,
                 name=None,
                 default_prec=None,
                 sparse=False,
                 use_lazy_mpoly_ring=False,
                 category=None):
        """
        Initializes a power series ring.

        INPUT:


        -  ``base_ring`` - a commutative ring

        -  ``name`` - name of the indeterminate

        -  ``default_prec`` - the default precision

        -  ``sparse`` - whether or not power series are
           sparse

        - ``use_lazy_mpoly_ring`` - if base ring is a poly ring compute with
          multivariate polynomials instead of a univariate poly over the base
          ring. Only use this for dense power series where you won't do too
          much arithmetic, but the arithmetic you do must be fast. You must
          explicitly call ``f.do_truncation()`` on an element
          for it to truncate away higher order terms (this is called
          automatically before printing).
          
        EXAMPLES:
    
        This base class inherits from :class:`~sage.rings.ring.CommutativeRing`.
        Since :trac:`11900`, it is also initialised as such, and since :trac:`14084`
        it is actually initialised as an integral domain::

            sage: R.<x> = ZZ[[]]
            sage: R.category()
            Category of integral domains
            sage: TestSuite(R).run()
    
        When the base ring `k` is a field, the ring `k[[x]]` is not only a
        commutative ring, but also a complete discrete valuation ring (CDVR).
        The appropriate (sub)category is automatically set in this case::
    
            sage: k = GF(11)
            sage: R.<x> = k[[]]
            sage: R.category()
            Category of complete discrete valuation rings
            sage: TestSuite(R).run()

        It is checked that the default precision is non-negative
        (see :trac:`19409`)::

            sage: PowerSeriesRing(ZZ, 'x', default_prec=-5)
            Traceback (most recent call last):
            ...
            ValueError: default_prec (= -5) must be non-negative

        """
        R = PolynomialRing(base_ring, name, sparse=sparse)
        self.__poly_ring = R
        self.__is_sparse = sparse
        if default_prec is None:
            from sage.misc.defaults import series_precision
            default_prec = series_precision()
        elif default_prec < 0:
            raise ValueError("default_prec (= %s) must be non-negative" %
                             default_prec)
        self.__params = (base_ring, name, default_prec, sparse)

        if use_lazy_mpoly_ring and (is_MPolynomialRing(base_ring) or \
                                    is_PolynomialRing(base_ring)):
            K = base_ring
            names = K.variable_names() + (name, )
            self.__mpoly_ring = PolynomialRing(K.base_ring(), names=names)
            assert is_MPolynomialRing(self.__mpoly_ring)
            self.Element = power_series_mpoly.PowerSeries_mpoly
        commutative_ring.CommutativeRing.__init__(
            self,
            base_ring,
            names=name,
            category=getattr(self, '_default_category', _CommutativeRings))
        Nonexact.__init__(self, default_prec)
        self.__generator = self.element_class(self,
                                              R.gen(),
                                              check=True,
                                              is_gen=True)