# Ticket #10271: trac_10271.patch

File trac_10271.patch, 13.7 KB (added by boothby, 10 years ago)

apply only this patch

• ## sage/rings/big_oh.py

```# HG changeset patch
# Parent 5b2bc3154e8d467e993faa7638e8e9b94f1a8f96

diff -r 5b2bc3154e8d sage/rings/big_oh.py```
• ## sage/rings/integer.pyx

`diff -r 5b2bc3154e8d sage/rings/integer.pyx`
 a else: raise ValueError("algorithm must be one of: 'pari', 'mpir'") def big_oh(self): """ If self is a prime power, `self=p^e` return the `p`-adic number `O(p^e)`. Otherwise, this makes no sense, so we raise an ArithmeticError. EXAMPLES:: sage: (7^6).big_oh() O(7^6) sage: 1/3 + O(7^6) 5 + 4*7 + 4*7^2 + 4*7^3 + 4*7^4 + 4*7^5 + O(7^6) """ import rational return rational.Rational(self).big_oh() ONE = Integer(1) Py_INCREF(ONE)
• ## sage/rings/laurent_series_ring.py

`diff -r 5b2bc3154e8d sage/rings/laurent_series_ring.py`
 a - Any ring that canonically coerces to the base ring of R """ from sage.rings.polynomial.laurent_polynomial_ring import is_LaurentPolynomialRing try: P = x.parent() if is_LaurentSeriesRing(P): if is_LaurentSeriesRing(P) or is_LaurentPolynomialRing(P): if P.variable_name() == self.variable_name(): if self.has_coerce_map_from(P.base_ring()): return self(x)
• ## sage/rings/laurent_series_ring_element.pyx

`diff -r 5b2bc3154e8d sage/rings/laurent_series_ring_element.pyx`
 a x = x[0] return self.__u(x) * (x[0]**self.__n) def big_oh(self): """ If this Laurent series is a monomial `x^n`, then return `O(x^n)`. Otherwise, raise an ArithmeticError. EXAMPLES:: sage: R. = LaurentSeriesRing(ZZ) sage: (278*t^4).big_oh() O(t^4) sage: (1+t).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined """ if self.is_monomial(): return self.parent(0).add_bigoh(self.degree()) else: raise ArithmeticError, "O(x) not defined" def make_element_from_parent(parent, *args): return parent(*args)

`diff -r 5b2bc3154e8d sage/rings/padics/padic_base_generic_element.pyx`
 a mpz_mod(xnew, xnew, ppow) mpz_clear(u) mpz_clear(xnew)

`diff -r 5b2bc3154e8d sage/rings/padics/padic_generic_element.pyx`
 a 0.200000000000000 """ raise NotImplementedError def big_oh(self): """ Returns the `p`-adic `0 + O(x)` if `x = w^v` where `w` is the generator of the `p`-adic ring self belongs to, and `v` is the valuation of self.  Otherwise, raises an ArithmeticError. EXAMPLES:: sage: K. = Qp(5, 30) sage: O(w^9) O(w^9) sage: S. = ZZ[] sage: E. = K.ext(x^5 + 75*x^3 - 15*x^2 +125*x - 5) sage: w + O(z^10) z^5 + 2*z^7 + 4*z^9 + O(z^10) TESTS:: sage: O(z+w) Traceback (most recent call last): ... ArithmeticError: Cannot construct O(x) """ t = self.parent().gen()**self.valuation() if self == t: return self.parent()(0, absprec = self.valuation()) raise ArithmeticError, "Cannot construct O(x)"
• ## sage/rings/polynomial/laurent_polynomial.pyx

`diff -r 5b2bc3154e8d sage/rings/polynomial/laurent_polynomial.pyx`
 a # 3. Subtract return LaurentPolynomial_univariate(self._parent, f1 - f2, m) def add_bigoh(self, prec): """ EXAMPLES:: sage: R. = LaurentPolynomialRing(QQ) sage: f = t^2 + t^3 + O(t^10); f t^2 + t^3 + O(t^10) sage: f.add_bigoh(5) t^2 + t^3 + O(t^5) """ from sage.rings.infinity import infinity if prec == infinity: return self r = self._parent.completion(self._parent.gen()) return r(self.truncate(prec)).add_bigoh(prec) #    def add_bigoh(self, prec): #        """ #        EXAMPLES:: # #            sage: R. = LaurentPolynomialRing(QQ) #            sage: f = t^2 + t^3 + O(t^10); f #            t^2 + t^3 + O(t^10) #            sage: f.add_bigoh(5) #            t^2 + t^3 + O(t^5) #        """ #        if prec == infinity: #            return self #        u = self.__u.add_bigoh(prec - self.__n) #        return LaurentSeries(self._parent.completion(self._parent.gen()), u, self.__n) def big_oh(self): """ Returns O(self) if self is a monomial, and otherwise raises an ArithmeticError. EXAMPLES:: sage: k. = LaurentPolynomialRing(QQ,'w') sage: (19*w^-17).big_oh() O(w^-17) sage: (w^12 + 17).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined sage: k(0).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined """ if self.is_monomial() and self: r = self._parent.completion(self._parent.gen()) return r(0).add_bigoh(self.degree()) raise ArithmeticError, "O(x) not defined" def degree(self): """ Return the degree of this polynomial. f.append( (self.parent(d),t[1]) ) return Factorization(f, unit=u)
• ## sage/rings/polynomial/laurent_polynomial_ring.py

`diff -r 5b2bc3154e8d sage/rings/polynomial/laurent_polynomial_ring.py`
 a From: Multivariate Polynomial Ring in x, y over Rational Field To:   Multivariate Laurent Polynomial Ring in x, y over Rational Field """ from sage.rings.laurent_series_ring import is_LaurentSeriesRing if R is self._R: from sage.structure.coerce_maps import CallableConvertMap return CallableConvertMap(R, self, self._element_constructor_, parent_as_first_arg=False) elif isinstance(R, LaurentPolynomialRing_generic) and \ elif is_LaurentPolynomialRing(R) and \ R.variable_names() == self.variable_names() and \ self.base_ring().has_coerce_map_from(R.base_ring()): return True elif is_LaurentSeriesRing(R): return False else: f = self._R.coerce_map_from(R) if f is not None:
• ## sage/rings/polynomial/polynomial_element.pyx

`diff -r 5b2bc3154e8d sage/rings/polynomial/polynomial_element.pyx`
 a w += 1 return w def big_oh(self): """ Returns O(self) if self is a monomial. EXAMPLES:: sage: k. = QQ[] sage: w.big_oh() O(w^1) sage: (w^9).big_oh() O(w^9) TESTS:: sage: (1 + w).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined sage: k(0).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined """ if self.is_monomial(): return self.parent().completion(self.parent().gen())(0, self.degree()) raise ArithmeticError, "O(x) not defined" # ----------------- inner functions ------------- # Cython can't handle function definitions inside other function
• ## sage/rings/power_series_ring_element.pyx

`diff -r 5b2bc3154e8d sage/rings/power_series_ring_element.pyx`
 a coeffs = self[:prec] return self._parent(coeffs, prec) def big_oh(self): """ Returns O(self) if self is a monomial. EXAMPLES:: sage: k. = QQ[[]] sage: w.big_oh() O(w^1) sage: (w^9).big_oh() O(w^9) TESTS:: sage: (1 + w).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined sage: k(0).big_oh() Traceback (most recent call last): ... ArithmeticError: O(x) not defined """ if self.is_monomial(): return self.parent()(0,self.degree()) else: raise ArithmeticError, "O(x) not defined" def solve_linear_de(self, prec = infinity, b = None, f0 = None): r""" s += pari('O(%s^%d)' % (s.variable(), n))  # PARI series return s def _solve_linear_de(R, N, L, a, b, f0): r""" Internal function used by PowerSeries.solve_linear_de().
• ## sage/rings/rational.pyx

`diff -r 5b2bc3154e8d sage/rings/rational.pyx`
 a if neg: v = -v return v def big_oh(self): """ If self is a prime power, `self=p^e` return the `p`-adic number `O(p^e)`. Otherwise, this makes no sense, so we raise an ArithmeticError. EXAMPLES:: sage: (7^-6).big_oh() O(7^-6) sage: 1/3 + O(7^6) 5 + 4*7 + 4*7^2 + 4*7^3 + 4*7^4 + 4*7^5 + O(7^6) """ import sage.rings.padics.factory as padics_factory from sage.rings.arith import is_prime_power if self <= 0 or self == 1 or not is_prime_power(self): raise ArithmeticError, "x must be a prime power >= 2" F = self.factor() if len(F) != 1: raise ArithmeticError, "x must be prime power" p, r = F[0] if r >= 0: return padics_factory.Zp(p, prec = max(r, 20), type = 'capped-rel')(0, absprec = r) else: return padics_factory.Qp(p, prec = max(r, 20), type = 'capped-rel')(0, absprec = r) def pyrex_rational_reconstruction(integer.Integer a, integer.Integer m): """ Find the rational reconstruction of a mod m, if it exists.