def _coerce_map_from_(self, S): """ A coercion from `S` exists, if `S` coerces into ``self``'s base ring, or if `S` is a univariate polynomial or power series ring with the same variable name as self, defined over a base ring that coerces into ``self``'s base ring. EXAMPLES:: sage: A = GF(17)[['x']] sage: A.has_coerce_map_from(ZZ) # indirect doctest True sage: A.has_coerce_map_from(ZZ['x']) True sage: A.has_coerce_map_from(ZZ['y']) False sage: A.has_coerce_map_from(ZZ[['x']]) True """ if self.base_ring().has_coerce_map_from(S): return True if (is_PolynomialRing(S) or is_PowerSeriesRing(S)) and self.base_ring().has_coerce_map_from(S.base_ring()) \ and self.variable_names()==S.variable_names(): return True
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)
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)