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

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Jeu 24 Juin 13:52:50 CEST 2010


Author: ptheveny
Date: 2010-06-24 13:52:49 +0200 (Thu, 24 Jun 2010)
New Revision: 321

Modified:
   trunk/mpfi/tests/tcos.c
   trunk/mpfi/tests/tcot.c
   trunk/mpfi/tests/tcoth.c
   trunk/mpfi/tests/tcsc.c
   trunk/mpfi/tests/tlog10.c
   trunk/mpfi/tests/tsec.c
   trunk/mpfi/tests/tsin.c
   trunk/mpfi/tests/ttan.c
Log:
Restrict domain of random tests to speed up some functions.

Modified: trunk/mpfi/tests/tcos.c
===================================================================
--- trunk/mpfi/tests/tcos.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tcos.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,27 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_cos;
 
   mpfi_fun_init_II (&i_cos, mpfi_cos, mpfr_cos);
+  mpfi_restrict_random (&i_cos, restrict_domain);
+
   test_start ();
 
   check_data (&i_cos, "cos.dat");

Modified: trunk/mpfi/tests/tcot.c
===================================================================
--- trunk/mpfi/tests/tcot.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tcot.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,27 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_cot;
 
   mpfi_fun_init_II (&i_cot, mpfi_cot, mpfr_cot);
+  mpfi_restrict_random (&i_cot, restrict_domain);
+
   test_start ();
 
   check_data (&i_cot, "cot.dat");

Modified: trunk/mpfi/tests/tcoth.c
===================================================================
--- trunk/mpfi/tests/tcoth.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tcoth.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,6 +26,16 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  if (MPFI_HAS_ZERO_NONSTRICT (a)) {
+    /* translate a <- a - left + 1 */
+    mpfi_sub_fr (a, a, &(a->left));
+    mpfi_add_ui (a, a, +1);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
@@ -38,11 +48,11 @@
 
 #if MPFR_VERSION < MPFR_VERSION_NUM(2, 4, 2)
   /* mpfr_coth is bugged: returns wrong value for +-0 */
-  check_random (&i_coth, 16, 1000, 10);
-#else
-  check_random (&i_coth, 2, 1000, 10);
+    mpfi_restrict_random (&i_coth, restrict_domain);
 #endif
 
+  check_random (&i_coth, 2, 1000, 10);
+
   test_end ();
   mpfi_fun_clear (&i_coth);
 

Modified: trunk/mpfi/tests/tcsc.c
===================================================================
--- trunk/mpfi/tests/tcsc.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tcsc.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,27 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_csc;
 
   mpfi_fun_init_II (&i_csc, mpfi_csc, mpfr_csc);
+  mpfi_restrict_random (&i_csc, restrict_domain);
+
   test_start ();
 
 /*   check_data (&i_csc, "csc.dat"); */

Modified: trunk/mpfi/tests/tlog10.c
===================================================================
--- trunk/mpfi/tests/tlog10.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tlog10.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,17 +26,32 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -100) < 0
+      || mpfr_cmp_si (&(a->left), +100) > 0) {
+    mpfr_set_si (&(a->left), -100, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -100) < 0
+      || mpfr_cmp_si (&(a->right), +100) > 0) {
+    mpfr_set_si (&(a->right), 100, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_log10;
 
   mpfi_fun_init_II (&i_log10, mpfi_log10, mpfr_log10);
+  mpfi_restrict_random (&i_log10, restrict_domain);
 
   test_start ();
 
 /*   check_data (&i_log10, "log10.dat"); */
-  check_random (&i_log10, 2, 1000, 10);
+  check_random (&i_log10, 2, 512, 10);
 
   test_end ();
   mpfi_fun_clear (&i_log10);

Modified: trunk/mpfi/tests/tsec.c
===================================================================
--- trunk/mpfi/tests/tsec.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tsec.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,26 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_sec;
 
   mpfi_fun_init_II (&i_sec, mpfi_sec, mpfr_sec);
+  mpfi_restrict_random (&i_sec, restrict_domain);
 
   test_start ();
 

Modified: trunk/mpfi/tests/tsin.c
===================================================================
--- trunk/mpfi/tests/tsin.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/tsin.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,26 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_sin;
 
   mpfi_fun_init_II (&i_sin, mpfi_sin, mpfr_sin);
+  mpfi_restrict_random (&i_sin, restrict_domain);
 
   test_start ();
 

Modified: trunk/mpfi/tests/ttan.c
===================================================================
--- trunk/mpfi/tests/ttan.c	2010-06-24 11:49:12 UTC (rev 320)
+++ trunk/mpfi/tests/ttan.c	2010-06-24 11:52:49 UTC (rev 321)
@@ -26,12 +26,26 @@
 
 #include "mpfi-tests.h"
 
+static int
+restrict_domain (mpfi_ptr a)
+{
+  /* speedup some tests restricting the possible random values */
+  if (mpfr_cmp_si (&(a->left), -7) < 0 || mpfr_cmp_si (&(a->left), +7) > 0) {
+    mpfr_set_si (&(a->left), -7, MPFI_RNDD);
+  }
+  if (mpfr_cmp_si (&(a->right), -7) < 0
+      || mpfr_cmp_si (&(a->right), +7) > 0) {
+    mpfr_set_si (&(a->right), 7, MPFI_RNDU);
+  }
+}
+
 int
 main (int argc, char **argv)
 {
   struct mpfi_function_t i_tan;
 
   mpfi_fun_init_II (&i_tan, mpfi_tan, mpfr_tan);
+  mpfi_restrict_random (&i_tan, restrict_domain);
 
   test_start ();
 




More information about the Mpfi-commits mailing list