diff --git a/build/pkgs/cypari/checksums.ini b/build/pkgs/cypari/checksums.ini index 7539ab6a614..d81625b5867 100644 --- a/build/pkgs/cypari/checksums.ini +++ b/build/pkgs/cypari/checksums.ini @@ -1,4 +1,5 @@ tarball=cypari2-VERSION.tar.gz -sha1=d3fc80e83bafa3c7e6eb5a779de9395d4242dddc -md5=9f431126112828c923f82e0393cbf317 -cksum=2176941985 +sha1=2a3039aa6bd690206cb58d4c39aef21e736eacf1 +md5=6267c0dace847160763dc1777a390c0a +cksum=3639046443 +upstream_url=https://pypi.io/packages/source/c/cypari2/cypari2-VERSION.tar.gz diff --git a/build/pkgs/cypari/package-version.txt b/build/pkgs/cypari/package-version.txt index 3e3c2f1e5ed..eca07e4c1a8 100644 --- a/build/pkgs/cypari/package-version.txt +++ b/build/pkgs/cypari/package-version.txt @@ -1 +1 @@ -2.1.1 +2.1.2 diff --git a/src/sage/libs/pari/convert_sage.pyx b/src/sage/libs/pari/convert_sage.pyx index 33aa4d2d46d..32d6902bc90 100644 --- a/src/sage/libs/pari/convert_sage.pyx +++ b/src/sage/libs/pari/convert_sage.pyx @@ -144,6 +144,20 @@ cpdef gen_to_sage(Gen z, locals=None): sage: a.parent() Complex Field with 64 bits of precision + sage: z = pari('1 + 1.0*I'); z + 1 + 1.00000000000000*I + sage: a = gen_to_sage(z); a + 1.00000000000000000 + 1.00000000000000000*I + sage: a.parent() + Complex Field with 64 bits of precision + + sage: z = pari('1.0 + 1*I'); z + 1.00000000000000 + I + sage: a = gen_to_sage(z); a + 1.00000000000000000 + 1.00000000000000000*I + sage: a.parent() + Complex Field with 64 bits of precision + Converting polynomials:: sage: f = pari('(2/3)*x^3 + x - 5/7 + y') @@ -233,7 +247,7 @@ cpdef gen_to_sage(Gen z, locals=None): cdef GEN g = z.g cdef long t = typ(g) cdef long tx, ty - cdef Gen real, imag + cdef Gen real, imag, prec, xprec, yprec cdef Py_ssize_t i, j, nr, nc if t == t_INT: @@ -241,8 +255,12 @@ cpdef gen_to_sage(Gen z, locals=None): elif t == t_FRAC: return Rational(z) elif t == t_REAL: - prec = prec_words_to_bits(z.precision()) - return RealField(prec)(z) + prec = z.bitprecision() + if typ(prec.g) == t_INFINITY: + sage_prec = 53 + else: + sage_prec = prec + return RealField(sage_prec)(z) elif t == t_COMPLEX: real = z.real() imag = z.imag() @@ -251,17 +269,20 @@ cpdef gen_to_sage(Gen z, locals=None): if tx in [t_INTMOD, t_PADIC] or ty in [t_INTMOD, t_PADIC]: raise NotImplementedError("No conversion to python available for t_COMPLEX with t_INTMOD or t_PADIC components") if tx == t_REAL or ty == t_REAL: - xprec = real.precision() # will be 0 if exact - yprec = imag.precision() # will be 0 if exact - if xprec == 0: - prec = prec_words_to_bits(yprec) - elif yprec == 0: - prec = prec_words_to_bits(xprec) + xprec = real.bitprecision() # will be infinite if exact + yprec = imag.bitprecision() # will be infinite if exact + if typ(xprec.g) == t_INFINITY: + if typ(yprec.g) == t_INFINITY: + sage_prec = 53 + else: + sage_prec = yprec + elif typ(yprec.g) == t_INFINITY: + sage_prec = xprec else: - prec = max(prec_words_to_bits(xprec), prec_words_to_bits(yprec)) + sage_prec = max(xprec, yprec) - R = RealField(prec) - C = ComplexField(prec) + R = RealField(sage_prec) + C = ComplexField(sage_prec) return C(R(real), R(imag)) else: K = QuadraticField(-1, 'i') diff --git a/src/sage/matrix/matrix1.pyx b/src/sage/matrix/matrix1.pyx index 0455c169fe8..691826accb3 100644 --- a/src/sage/matrix/matrix1.pyx +++ b/src/sage/matrix/matrix1.pyx @@ -86,8 +86,6 @@ cdef class Matrix(Matrix0): sage: b = pari(a); b [1.000000000, 2.000000000; 3.000000000, 1.000000000] # 32-bit [1.00000000000000, 2.00000000000000; 3.00000000000000, 1.00000000000000] # 64-bit - sage: b[0][0].precision() # in words - 3 """ from sage.libs.pari.all import pari return pari.matrix(self._nrows, self._ncols, self._list()) diff --git a/src/sage/rings/fraction_field.py b/src/sage/rings/fraction_field.py index 9a263c29c66..4bd0421c380 100644 --- a/src/sage/rings/fraction_field.py +++ b/src/sage/rings/fraction_field.py @@ -661,8 +661,11 @@ def _element_constructor_(self, x, y=None, coerce=True): # Below, v is the variable with highest priority, # and the x[i] are rational functions in the # remaining variables. + d = x.poldegree() + if d.type() == 't_INFINITY': + return self.zero() v = self._element_class(self, x.variable(), 1) - x = sum(self(x[i]) * v**i for i in range(x.poldegree() + 1)) + x = sum(self(x[i]) * v**i for i in range(d + 1)) def resolve_fractions(x, y): xn = x.numerator() diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 4fe1fbc196d..ebf83f478aa 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -6745,7 +6745,7 @@ def units(self, proof=None): """ Return generators for the unit group modulo torsion. - ALGORITHM: Uses PARI's :pari:`bnfunit` command. + ALGORITHM: Uses PARI's :pari:`bnfinit` command. INPUT: @@ -6811,8 +6811,8 @@ def units(self, proof=None): except AttributeError: pass - # get PARI to compute the units - B = self.pari_bnf(proof).bnfunit() + # get PARI to compute the fundamental units + B = self.pari_bnf(proof).bnf_get_fu() B = tuple(self(b, check=False) for b in B) if proof: # cache the provable results and return them @@ -6827,7 +6827,7 @@ def unit_group(self, proof=None): """ Return the unit group (including torsion) of this number field. - ALGORITHM: Uses PARI's :pari:`bnfunit` command. + ALGORITHM: Uses PARI's :pari:`bnfinit` command. INPUT: diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 0c2499bfeeb..4088b8dad1b 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -1801,7 +1801,7 @@ cdef class NumberFieldElement(FieldElement): raise ValueError("L (=%s) must be a relative number field with base field K (=%s) in rnfisnorm" % (L, K)) rnf_data = K.pari_rnfnorm_data(L, proof=proof) - x, q = self.__pari__().rnfisnorm(rnf_data) + x, q = pari.rnfisnorm(rnf_data, self) return L(x, check=False), K(q, check=False) def _mpfr_(self, R): diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py index 641f662c2d9..d0508258a0d 100644 --- a/src/sage/rings/number_field/unit_group.py +++ b/src/sage/rings/number_field/unit_group.py @@ -324,7 +324,7 @@ def __init__(self, number_field, proof=True, S=None): self.__pS = pS = [P.pari_prime() for P in S] # compute the fundamental units via pari: - fu = [K(u, check=False) for u in pK.bnfunit()] + fu = [K(u, check=False) for u in pK.bnf_get_fu()] self.__nfu = len(fu) # compute the additional S-unit generators: diff --git a/src/sage/rings/polynomial/multi_polynomial_ring.py b/src/sage/rings/polynomial/multi_polynomial_ring.py index 077f3807308..91b350b61da 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ring.py +++ b/src/sage/rings/polynomial/multi_polynomial_ring.py @@ -379,6 +379,9 @@ def __call__(self, x, check=True): sage: f = pari(a*d) sage: B(f) a*d + sage: f = pari(a*d - (a+1)*d*e^3 + a*d^2) + sage: B(f) + (-a - 1)*d*e^3 + a*d^2 + a*d sage: A. = PolynomialRing(QQ) sage: B. = PolynomialRing(A) @@ -525,8 +528,11 @@ def __call__(self, x, check=True): # univariate polynomials. Below, v is the variable # with highest priority, and the x[i] are expressions # in the remaining variables. + d = x.poldegree() + if d.type() == 't_INFINITY': + return self.zero() v = self.gens_dict_recursive()[str(x.variable())] - return sum(self(x[i]) * v ** i for i in range(x.poldegree() + 1)) + return sum(self(x[i]) * v ** i for i in range(d + 1)) if isinstance(x, dict): return MPolynomial_polydict(self, x)