[Mpfi-commits] r364 - trunk/mpfi/tests

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Mar 29 Juin 16:18:56 CEST 2010


Author: ptheveny
Date: 2010-06-29 16:18:56 +0200 (Tue, 29 Jun 2010)
New Revision: 364

Added:
   trunk/mpfi/tests/d_div.dat
Modified:
   trunk/mpfi/tests/Makefile.am
   trunk/mpfi/tests/td_div.c
Log:
Add test data for mpfi_d_div.

Modified: trunk/mpfi/tests/Makefile.am
===================================================================
--- trunk/mpfi/tests/Makefile.am	2010-06-29 14:17:44 UTC (rev 363)
+++ trunk/mpfi/tests/Makefile.am	2010-06-29 14:18:56 UTC (rev 364)
@@ -40,8 +40,8 @@
     bisect.dat blow.dat bounded_p.dat cbrt.dat			\
     const_catalan.dat const_euler.dat const_log2.dat		\
     const_pi.dat cos.dat cosh.dat cot.dat coth.dat csc.dat	\
-    csch.dat diam.dat diam_abs.dat diam_rel.dat div.dat		\
-    has_zero.dat increase.dat inf_p.dat inp_str.dat		\
+    csch.dat d_div.c diam.dat diam_abs.dat diam_rel.dat		\
+    div.dat has_zero.dat increase.dat inf_p.dat inp_str.dat	\
     intersect.dat inv.dat is_neg.dat is_nonneg.dat		\
     is_nonpos.dat is_pos.dat is_strictly_neg.dat		\
     is_strictly_pos.dat log.dat mag.dat mid.dat mig.dat		\

Added: trunk/mpfi/tests/d_div.dat
===================================================================
--- trunk/mpfi/tests/d_div.dat	                        (rev 0)
+++ trunk/mpfi/tests/d_div.dat	2010-06-29 14:18:56 UTC (rev 364)
@@ -0,0 +1,89 @@
+# data file for mpfi_d_div
+#
+# column fields:
+# 1: inexact flag (returned value)
+# 2: precision of result
+# 3: left endpoint value of result
+# 4: right endpoint value of result
+#
+# 5: first parameter value
+# 6: precision of second parameter
+# 7: left endpoint value of second parameter
+# 8: right endpoint value of second parameter
+
+#WARNING:
+# double values are read by the test suite with rounding towards minus
+# infinity to a machine-dependant precision (whereas the mpfi data are read
+# at the given precision with rounding to the nearest).
+# So as to ensure portability, use test values that are representable with a
+# 53 bit-significand which corresponds to the minimum default precision for
+# a double in the test suite.
+
+# special values
+0 53  nan  nan                       -0x170ef54646d497p-109  53  nan  nan
+0 53  nan  nan                        0.0                    53  nan  nan
+0 53  nan  nan                        0x170ef54646d497p-109  53  nan  nan
+0 53  nan  nan                       -0x114b37f4b51f71p-107  53  nan -inf
+0 53  nan  nan                        0.0                    53  nan -inf
+0 53  nan  nan                        0x114b37f4b51f71p-107  53  nan -inf
+0 53  nan  nan                       -0xfc339ab0a6b53p-99    53  nan -7
+0 53  nan  nan                        0.0                    53  nan -7
+0 53  nan  nan                        7.0                    53  nan -7
+0 53  nan  nan                       -15.0                   53  nan -0
+0 53  nan  nan                        0.0                    53  nan -0
+0 53  nan  nan                        15.0                   53  nan -0
+0 53  nan  nan                       -0xb2b3ece0a4ef9p-103   53  nan  1
+0 53  nan  nan                        0.0                    53  nan  1
+0 53  nan  nan                        0xb2b3ece0a4ef9p-103   53  nan  1
+0 53  nan  nan                       -0x5acae5c4b6e51p-101   53  nan +inf
+0 53  nan  nan                        0.0                    53  nan +inf
+0 53  nan  nan                        0x5acae5c4b6e51p-101   53  nan +inf
+0 53 +0   -0                         -0x170ef54646d497p-108  53 -inf -inf
+0 53 +0   -0                          0.0                    53 -inf -inf
+0 53 +0   -0                          0x170ef54646d497p-108  53 -inf -inf
+0 53 +0   +0x1a5a3ce29a1788p-110     -0x170ef54646d497p-107  53 -inf -7
+0 53 +0   -0                          0.0                    53 -inf -7
+0 53 -0x170ef54646d497p-110 -0        0x170ef54646d497p-107  53 -inf -8
+0 53 +0   +inf                       -0x170ef54646d497p-106  53 -inf -0
+0 53 -inf -0                          0.0                    53 -inf -0
+0 53 -inf -0                          0x170ef54646d497p-106  53 -inf -0
+0 53 -inf +inf                       -0x16345785d8a00000     53 -inf  8
+0 53 -inf +inf                        0.0                    53 -inf  8
+0 53 -inf +inf                        0x16345785d8a00000     53 -inf  7
+0 53 -inf +inf                       -0x170ef54646d497p-105  53 -inf +inf
+0 53 -inf +inf                        0.0e-17                53 -inf +inf
+0 53 -inf +inf                       +0x170ef54646d497p-105  53 -inf +inf
+0 53  nan  nan                       -0x170ef54646d497p-104  53 -inf  nan
+0 53  nan  nan                        0.0e-17                53 -inf  nan
+0 53  nan  nan                       +0x170ef54646d497p-104  53 -inf  nan
+0 53 -inf +inf                       -0x170ef54646d497p-109  53 +0   -0
+
+# should 0.0/[+0, -0] be [+0, -0]?
+0 53  nan +inf                        0.0                    53 +0   -0
+
+0 53 -inf +inf                        0x170ef54646d497p-109  53 +0   -0
+0 53 -inf -0x114b37f4b51f71p-110     -0x114b37f4b51f71p-107  53 +0    8
+0 53 +0   +inf                        0.0                    53 +0    8
+0 53  0x114b37f4b51f7p-106 +inf       0x114b37f4b51f7p-103   53 +0    8
+0 53 -inf -0                         -0x50b45a75f7e81p-104   53 +0   +inf
+0 53 +0   +inf                        0.0                    53 +0   +inf
+0 53 +0   +inf                        0x142d169d7dfa03p-106  53 +0   +inf
+0 53 +0   -0                         -0x170ef54646d497p-109  53 +inf +inf
+0 53 +0   -0                          0.0                    53 +inf +inf
+0 53 +0   -0                          0x170ef54646d497p-109  53 +inf +inf
+0 53  nan  nan                       -0x170ef54646d497p-109  53 +inf  nan
+0 53  nan  nan                        0.0                    53 +inf  nan
+0 53  nan  nan                        0x170ef54646d497p-109  53 +inf  nan
+
+# regular values
+0 53 -inf     +inf                                     -2.5  53 -8    8
+
+0 53  0x5p-4                0.5                        -2.5  53 -8   -5
+1 53 -0x1999999999999ap-56 -0x1p-4                     -2.5  53  25   40
+2 53  0x5p-5                0x16db6db6db6db7p-54       -2.5  53 -16  -7
+3 53 -0x1d1745d1745d18p-55 -0x11e6efe35b4cfap-58       -2.5  53  11   143
+
+0 53  0x1p-4                4                        33.125  53  8.28125 530
+1 53 -0x11111111111112p-56 -0x1p-4                   33.125  53 -530 -496.875
+2 53  0.125                 0x13a12f684bda13p-53     33.125  53  54   265
+3 53  0x13a12f684bda12p-53  0x14627627627628p-53     33.125  53  52   54

Modified: trunk/mpfi/tests/td_div.c
===================================================================
--- trunk/mpfi/tests/td_div.c	2010-06-29 14:17:44 UTC (rev 363)
+++ trunk/mpfi/tests/td_div.c	2010-06-29 14:18:56 UTC (rev 364)
@@ -24,8 +24,45 @@
 the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
 MA 02110-1301, USA. */
 
+#include <float.h>
 #include "mpfi-tests.h"
 
+#ifdef DBL_MAX_EXP
+void
+check_overflow (void)
+{
+  mpfi_t interval;
+  mpfi_t got;
+  double d = 2.0;
+  int inex;
+
+  if (DBL_MAX_EXP >= MPFR_EMAX_DEFAULT)
+    return;
+
+  mpfi_init2 (interval, 53);
+  mpfi_init2 (got, 53);
+
+  mpfi_set_ui (interval, 0);
+  mpfr_nextabove (&(interval->right));
+  mpfr_nextabove (&(interval->left)); /* tiny left endpoint x0 */
+  mpfr_nextabove (&(interval->right)); /* interval = [x0, x0 + 1 ulp] */
+
+  inex = mpfi_d_div (got, d, interval);
+  if (!MPFI_BOTH_ARE_INEXACT (inex) || mpfi_bounded_p (got)) {
+    printf ("Error: mpfi_d_div (rop, %g, op) does not correctly handle "
+            "overflow.\nop = ", d);
+    mpfi_out_str (stdout, 10, 0, interval);
+    printf ("\nrop = ");
+    mpfi_out_str (stdout, 10, 0, got);
+    printf ("\nreturn value = %d\n", inex);
+    exit (1);
+  }
+
+  mpfi_clear (interval);
+  mpfi_clear (got);
+}
+#endif
+
 int
 main (int argc, char **argv)
 {
@@ -34,9 +71,13 @@
   mpfi_fun_init_IDI (&i_d_div, mpfi_d_div, mpfr_d_div);
   test_start ();
 
-/*   check_data (&i_d_div, "d_div.dat"); */
+  check_data (&i_d_div, "d_div.dat");
   check_random (&i_d_div, 2, 1000, 10);
 
+#ifdef DBL_MAX_EXP
+  check_overflow ();
+#endif
+
   test_end ();
   mpfi_fun_clear (&i_d_div);
 




More information about the Mpfi-commits mailing list