Skip to content

Commit

Permalink
Trac #24353: Upgrade MPFR, MPC and MPFI
Browse files Browse the repository at this point in the history
  • Loading branch information
Release Manager authored and vbraun committed Jan 18, 2018
2 parents 5502506 + 3c089ff commit 334a31b
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 168 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/mpc/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=mpc-VERSION.tar.gz
sha1=b8be66396c726fdc36ebb0f692ed8a8cca3bcc66
md5=d6a1d5f8ddea3abd2cc3e98f58352d26
cksum=1941630434
sha1=b019d9e1d27ec5fb99497159d43a3164995de2d0
md5=4125404e41e482ec68282a2e687f6c73
cksum=3987925640
2 changes: 1 addition & 1 deletion build/pkgs/mpc/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3.p1
1.1.0
124 changes: 0 additions & 124 deletions build/pkgs/mpc/patches/mpc_mul_faster.patch

This file was deleted.

6 changes: 3 additions & 3 deletions build/pkgs/mpfi/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=mpfi-VERSION.tar.bz2
sha1=68773ce05e89e0f968687dd82d402f80ccc4c31f
md5=50d05e9d6f20a07c043b3b038927a456
cksum=2405993671
sha1=6a44e59f69fa72b4fe1c67b9c9ccf678f321ef80
md5=1c233f3646bfb8a363aee0cc653c8baa
cksum=4291278873
2 changes: 1 addition & 1 deletion build/pkgs/mpfi/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1.p0
1.5.2
6 changes: 3 additions & 3 deletions build/pkgs/mpfr/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=mpfr-VERSION.tar.bz2
sha1=874e84bb5959fd5a19c032cfb5d673dded4b5cff
md5=b1d23a55588e3b2a13e3be66bc69fd8d
cksum=3347469031
sha1=799245347044c8f0da9e513f86bb5e4c07974931
md5=ef619f3bb68039e35c4a219e06be72d0
cksum=3469661192
2 changes: 1 addition & 1 deletion build/pkgs/mpfr/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.5.p0
4.0.0
20 changes: 0 additions & 20 deletions build/pkgs/mpfr/patches/clang_workaround.patch

This file was deleted.

1 change: 1 addition & 0 deletions src/sage/libs/mpfr/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ cdef extern from "mpfr.h":
int mpfr_sqrt(mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
int mpfr_sqrt_ui(mpfr_t rop, unsigned long int op, mpfr_rnd_t rnd)
int mpfr_cbrt(mpfr_t rop, mpfr_t op, mpfr_rnd_t rnd)
int mpfr_rootn_ui(mpfr_t rop, mpfr_t op, unsigned long int k, mpfr_rnd_t rnd)
int mpfr_root(mpfr_t rop, mpfr_t op, unsigned long int k, mpfr_rnd_t rnd)
int mpfr_pow(mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)
int mpfr_pow_ui(mpfr_t rop, mpfr_t op1, unsigned long int op2, mpfr_rnd_t rnd)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
cdef RealNumber a,r
a = self.argument()/n
r = self.abs()
mpfr_root(r.value, r.value, n, rrnd)
mpfr_rootn_ui(r.value, r.value, n, rrnd)

cdef MPComplexNumber z
z = self._new()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_number.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
rho = abs(self)
arg = self.argument() / n
mpfr_init2(r, self._prec)
mpfr_root(r, rho.value, n, rnd)
mpfr_rootn_ui(r, rho.value, n, rnd)

mpfr_sin_cos(z.__im, z.__re, arg.value, rnd)
mpfr_mul(z.__re, z.__re, r, rnd)
Expand Down
26 changes: 16 additions & 10 deletions src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ def mpfr_prec_min():
sage: from sage.rings.real_mpfr import mpfr_prec_min
sage: mpfr_prec_min()
2
1
sage: R = RealField(2)
sage: R(2) + R(1)
3.0
sage: R(4) + R(1)
4.0
sage: R = RealField(1)
sage: R = RealField(0)
Traceback (most recent call last):
...
ValueError: prec (=1) must be >= 2 and <= 2147483391
ValueError: prec (=0) must be >= 1 and <= 2147483391
"""
return MPFR_PREC_MIN

Expand All @@ -218,7 +218,7 @@ def mpfr_prec_max():
sage: R = RealField(2^31-256)
Traceback (most recent call last):
...
ValueError: prec (=2147483392) must be >= 2 and <= 2147483391
ValueError: prec (=2147483392) must be >= 1 and <= 2147483391
"""
global MY_MPFR_PREC_MAX
return MY_MPFR_PREC_MAX
Expand Down Expand Up @@ -353,7 +353,7 @@ mpfr_set_exp_max(mpfr_get_emax_max())

from sage.arith.long cimport pyobject_to_long
cdef dict rounding_modes = dict(RNDN=MPFR_RNDN, RNDZ=MPFR_RNDZ,
RNDD=MPFR_RNDD, RNDU=MPFR_RNDU, RNDA=MPFR_RNDA)
RNDD=MPFR_RNDD, RNDU=MPFR_RNDU, RNDA=MPFR_RNDA, RNDF=MPFR_RNDF)

cdef double LOG_TEN_TWO_PLUS_EPSILON = 3.321928094887363 # a small overestimate of log(10,2)

Expand Down Expand Up @@ -384,6 +384,8 @@ cpdef RealField(int prec=53, int sci_not=0, rnd=MPFR_RNDN):
- ``'RNDZ'`` -- round towards zero
- ``'RNDU'`` -- round towards plus infinity
- ``'RNDA'`` -- round away from zero
- ``'RNDF'`` -- faithful rounding (currently experimental; not
guaranteed correct for every operation)
- for specialized applications, the rounding mode can also be
given as an integer value of type ``mpfr_rnd_t``. However, the
exact values are unspecified.
Expand Down Expand Up @@ -472,6 +474,8 @@ cdef class RealField_class(sage.rings.ring.Field):
Real Field with 100 bits of precision and rounding RNDD
sage: RealField(100, rnd="RNDA")
Real Field with 100 bits of precision and rounding RNDA
sage: RealField(100, rnd="RNDF")
Real Field with 100 bits of precision and rounding RNDF
sage: RealField(100, rnd=0)
Real Field with 100 bits of precision
sage: RealField(100, rnd=1)
Expand All @@ -482,14 +486,16 @@ cdef class RealField_class(sage.rings.ring.Field):
Real Field with 100 bits of precision and rounding RNDD
sage: RealField(100, rnd=4)
Real Field with 100 bits of precision and rounding RNDA
sage: RealField(100, rnd=5)
Real Field with 100 bits of precision and rounding RNDF
sage: RealField(100, rnd=3.14)
Traceback (most recent call last):
...
ValueError: rounding mode (=3.14000000000000) must be one of ['RNDA', 'RNDZ', 'RNDD', 'RNDU', 'RNDN']
sage: RealField(100, rnd=5)
ValueError: rounding mode (=3.14000000000000) must be one of ['RNDA', 'RNDD', 'RNDF', 'RNDN', 'RNDU', 'RNDZ']
sage: RealField(100, rnd=6)
Traceback (most recent call last):
...
ValueError: unknown rounding mode 5
ValueError: unknown rounding mode 6
sage: RealField(100, rnd=10^100)
Traceback (most recent call last):
...
Expand Down Expand Up @@ -4419,7 +4425,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
sage: r = -1.0
sage: r.eint()
NaN
-0.219383934395520
"""
cdef RealNumber x = self._new()
if (<RealField_class>self._parent).__prec > SIG_PREC_THRESHOLD: sig_on()
Expand Down Expand Up @@ -5275,7 +5281,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
if algorithm == 1:
x = self._new()
sig_on()
mpfr_root(x.value, self.value, n, (<RealField_class>self._parent).rnd)
mpfr_rootn_ui(x.value, self.value, n, (<RealField_class>self._parent).rnd)
sig_off()
return x

Expand Down

0 comments on commit 334a31b

Please sign in to comment.