|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/PATCHES mpfr-3.1.6-b/PATCHES
|
|
|
c973bd |
--- mpfr-3.1.6-a/PATCHES 2017-12-15 12:37:44.074256548 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/PATCHES 2017-12-15 12:37:44.146256304 +0000
|
|
|
c973bd |
@@ -0,0 +1 @@
|
|
|
c973bd |
+root
|
|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/VERSION mpfr-3.1.6-b/VERSION
|
|
|
c973bd |
--- mpfr-3.1.6-a/VERSION 2017-10-26 13:55:51.236013121 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/VERSION 2017-12-15 12:37:44.142256319 +0000
|
|
|
c973bd |
@@ -1 +1 @@
|
|
|
c973bd |
-3.1.6-p1
|
|
|
c973bd |
+3.1.6-p2
|
|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/src/mpfr.h mpfr-3.1.6-b/src/mpfr.h
|
|
|
c973bd |
--- mpfr-3.1.6-a/src/mpfr.h 2017-10-26 13:55:51.232013138 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/src/mpfr.h 2017-12-15 12:37:44.142256319 +0000
|
|
|
c973bd |
@@ -27,7 +27,7 @@
|
|
|
c973bd |
#define MPFR_VERSION_MAJOR 3
|
|
|
c973bd |
#define MPFR_VERSION_MINOR 1
|
|
|
c973bd |
#define MPFR_VERSION_PATCHLEVEL 6
|
|
|
c973bd |
-#define MPFR_VERSION_STRING "3.1.6-p1"
|
|
|
c973bd |
+#define MPFR_VERSION_STRING "3.1.6-p2"
|
|
|
c973bd |
|
|
|
c973bd |
/* Macros dealing with MPFR VERSION */
|
|
|
c973bd |
#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
|
|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/src/root.c mpfr-3.1.6-b/src/root.c
|
|
|
c973bd |
--- mpfr-3.1.6-a/src/root.c 2017-01-01 01:39:09.000000000 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/src/root.c 2017-12-15 12:37:44.118256398 +0000
|
|
|
c973bd |
@@ -107,6 +107,11 @@
|
|
|
c973bd |
MPFR_RET_NAN;
|
|
|
c973bd |
}
|
|
|
c973bd |
|
|
|
c973bd |
+ /* Special case |x| = 1. Note that if x = -1, then k is odd
|
|
|
c973bd |
+ (NaN results have already been filtered), so that y = -1. */
|
|
|
c973bd |
+ if (mpfr_cmpabs (x, __gmpfr_one) == 0)
|
|
|
c973bd |
+ return mpfr_set (y, x, rnd_mode);
|
|
|
c973bd |
+
|
|
|
c973bd |
/* General case */
|
|
|
c973bd |
|
|
|
c973bd |
/* For large k, use exp(log(x)/k). The threshold of 100 seems to be quite
|
|
|
c973bd |
@@ -188,6 +193,14 @@
|
|
|
c973bd |
Assume all special cases have been eliminated before.
|
|
|
c973bd |
In the extended exponent range, overflows/underflows are not possible.
|
|
|
c973bd |
Assume x > 0, or x < 0 and k odd.
|
|
|
c973bd |
+ Also assume |x| <> 1 because log(1) = 0, which does not have an exponent
|
|
|
c973bd |
+ and would yield a failure in the error bound computation. A priori, this
|
|
|
c973bd |
+ constraint is quite artificial because if |x| is close enough to 1, then
|
|
|
c973bd |
+ the exponent of log|x| does not need to be used (in the code, err would
|
|
|
c973bd |
+ be 1 in such a domain). So this constraint |x| <> 1 could be avoided in
|
|
|
c973bd |
+ the code. However, this is an exact case easy to detect, so that such a
|
|
|
c973bd |
+ change would be useless. Values very close to 1 are not an issue, since
|
|
|
c973bd |
+ an underflow is not possible before the MPFR_GET_EXP.
|
|
|
c973bd |
*/
|
|
|
c973bd |
static int
|
|
|
c973bd |
mpfr_root_aux (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode)
|
|
|
c973bd |
@@ -219,7 +232,8 @@
|
|
|
c973bd |
mpfr_log (t, absx, MPFR_RNDN);
|
|
|
c973bd |
/* t = log|x| * (1 + theta) with |theta| <= 2^(-w) */
|
|
|
c973bd |
mpfr_div_ui (t, t, k, MPFR_RNDN);
|
|
|
c973bd |
- expt = MPFR_GET_EXP (t);
|
|
|
c973bd |
+ /* No possible underflow in mpfr_log and mpfr_div_ui. */
|
|
|
c973bd |
+ expt = MPFR_GET_EXP (t); /* assumes t <> 0 */
|
|
|
c973bd |
/* t = log|x|/k * (1 + theta) + eps with |theta| <= 2^(-w)
|
|
|
c973bd |
and |eps| <= 1/2 ulp(t), thus the total error is bounded
|
|
|
c973bd |
by 1.5 * 2^(expt - w) */
|
|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/src/version.c mpfr-3.1.6-b/src/version.c
|
|
|
c973bd |
--- mpfr-3.1.6-a/src/version.c 2017-10-26 13:55:51.232013138 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/src/version.c 2017-12-15 12:37:44.142256319 +0000
|
|
|
c973bd |
@@ -25,5 +25,5 @@
|
|
|
c973bd |
const char *
|
|
|
c973bd |
mpfr_get_version (void)
|
|
|
c973bd |
{
|
|
|
c973bd |
- return "3.1.6-p1";
|
|
|
c973bd |
+ return "3.1.6-p2";
|
|
|
c973bd |
}
|
|
|
c973bd |
diff -Naurd mpfr-3.1.6-a/tests/troot.c mpfr-3.1.6-b/tests/troot.c
|
|
|
c973bd |
--- mpfr-3.1.6-a/tests/troot.c 2017-01-01 01:39:09.000000000 +0000
|
|
|
c973bd |
+++ mpfr-3.1.6-b/tests/troot.c 2017-12-15 12:37:44.118256398 +0000
|
|
|
c973bd |
@@ -405,6 +405,26 @@
|
|
|
c973bd |
mpfr_clears (x, y1, y2, (mpfr_ptr) 0);
|
|
|
c973bd |
}
|
|
|
c973bd |
|
|
|
c973bd |
+static void
|
|
|
c973bd |
+bug20171214 (void)
|
|
|
c973bd |
+{
|
|
|
c973bd |
+ mpfr_t x, y;
|
|
|
c973bd |
+ int inex;
|
|
|
c973bd |
+
|
|
|
c973bd |
+ mpfr_init2 (x, 805);
|
|
|
c973bd |
+ mpfr_init2 (y, 837);
|
|
|
c973bd |
+ mpfr_set_ui (x, 1, MPFR_RNDN);
|
|
|
c973bd |
+ inex = mpfr_root (y, x, 120, MPFR_RNDN);
|
|
|
c973bd |
+ MPFR_ASSERTN (inex == 0);
|
|
|
c973bd |
+ MPFR_ASSERTN (mpfr_cmp_ui (y, 1) == 0);
|
|
|
c973bd |
+ mpfr_set_si (x, -1, MPFR_RNDN);
|
|
|
c973bd |
+ inex = mpfr_root (y, x, 121, MPFR_RNDN);
|
|
|
c973bd |
+ MPFR_ASSERTN (inex == 0);
|
|
|
c973bd |
+ MPFR_ASSERTN (mpfr_cmp_si (y, -1) == 0);
|
|
|
c973bd |
+ mpfr_clear (x);
|
|
|
c973bd |
+ mpfr_clear (y);
|
|
|
c973bd |
+}
|
|
|
c973bd |
+
|
|
|
c973bd |
int
|
|
|
c973bd |
main (void)
|
|
|
c973bd |
{
|
|
|
c973bd |
@@ -415,6 +435,7 @@
|
|
|
c973bd |
|
|
|
c973bd |
tests_start_mpfr ();
|
|
|
c973bd |
|
|
|
c973bd |
+ bug20171214 ();
|
|
|
c973bd |
exact_powers (3, 1000);
|
|
|
c973bd |
special ();
|
|
|
c973bd |
bigint ();
|