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

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Jeu 24 Juin 13:49:12 CEST 2010


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

Modified:
   trunk/mpfi/tests/mpfi-tests.c
   trunk/mpfi/tests/mpfi-tests.h
   trunk/mpfi/tests/type_i.c
   trunk/mpfi/tests/type_id.c
   trunk/mpfi/tests/type_idi.c
   trunk/mpfi/tests/type_ii.c
   trunk/mpfi/tests/type_iid.c
   trunk/mpfi/tests/type_iii.c
   trunk/mpfi/tests/type_iiq.c
   trunk/mpfi/tests/type_iir.c
   trunk/mpfi/tests/type_iis.c
   trunk/mpfi/tests/type_iiu.c
   trunk/mpfi/tests/type_iiz.c
   trunk/mpfi/tests/type_iq.c
   trunk/mpfi/tests/type_iqi.c
   trunk/mpfi/tests/type_ir.c
   trunk/mpfi/tests/type_iri.c
   trunk/mpfi/tests/type_is.c
   trunk/mpfi/tests/type_isi.c
   trunk/mpfi/tests/type_iu.c
   trunk/mpfi/tests/type_iui.c
   trunk/mpfi/tests/type_iz.c
   trunk/mpfi/tests/type_izi.c
   trunk/mpfi/tests/type_ri.c
Log:
Add support for domain restriction in random tests.

Modified: trunk/mpfi/tests/mpfi-tests.c
===================================================================
--- trunk/mpfi/tests/mpfi-tests.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/mpfi-tests.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -27,6 +27,12 @@
 #include "mpfi-tests.h"
 
 void
+mpfi_restrict_random (mpfi_function_ptr func, I_fun restrict)
+{
+  func->random_domain = restrict;
+}
+
+void
 mpfi_fun_clear (mpfi_function_ptr func)
 {
   func->clear (func);

Modified: trunk/mpfi/tests/mpfi-tests.h
===================================================================
--- trunk/mpfi/tests/mpfi-tests.h	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/mpfi-tests.h	2010-06-24 11:49:12 UTC (rev 320)
@@ -179,6 +179,7 @@
   mpfi_fun_ptr        func;
   mpfi_fun_mpfr_ptr   mpfr_func; /* associated MPFR function */
   mpfi_fun_operand_t* operands;
+  I_fun               random_domain;
 
   void (*set_prec)   (mpfi_function_ptr, mp_prec_t);
   void (*read_line)  (mpfi_function_ptr, FILE *);
@@ -237,6 +238,7 @@
 void mpfi_fun_init_RI   (mpfi_function_ptr, RI_fun, NULL_fun);
 void mpfi_fun_clear     (mpfi_function_ptr);
 
+void mpfi_restrict_random (mpfi_function_ptr, I_fun);
 
 /* internal functions */
 

Modified: trunk/mpfi/tests/type_i.c
===================================================================
--- trunk/mpfi/tests/type_i.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_i.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -128,6 +128,7 @@
   this->type = I;
   this->func.I = mpfi_function;
   this->mpfr_func.I = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_id.c
===================================================================
--- trunk/mpfi/tests/type_id.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_id.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -112,6 +112,7 @@
   this->type = ID;
   this->func.ID = mpfi_function;
   this->mpfr_func.ID = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_idi.c
===================================================================
--- trunk/mpfi/tests/type_idi.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_idi.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -118,6 +118,10 @@
 
   d = random_double ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IDI (b, d, a);
   f_RDR (y, d, x, MPFI_RNDD);
@@ -170,6 +174,7 @@
   this->type = IDI;
   this->func.IDI = mpfi_function;
   this->mpfr_func.IDI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_ii.c
===================================================================
--- trunk/mpfi/tests/type_ii.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_ii.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -205,6 +205,10 @@
   mpfr_ptr y  = &(i->right);
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_II (b, a);
   f_RR (y, x, MPFI_RNDD);
@@ -251,11 +255,12 @@
    '.dat' files plus one additional variable before them. */
 void
 mpfi_fun_init_II (mpfi_function_ptr this, II_fun mpfi_function,
-              RR_fun mpfr_function)
+                  RR_fun mpfr_function)
 {
   this->type = II;
   this->func.II = mpfi_function;
   this->mpfr_func.II = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iid.c
===================================================================
--- trunk/mpfi/tests/type_iid.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iid.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -120,6 +120,10 @@
 
   d = random_double ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IID (b, a, d);
   f_RRD (y, x, d, MPFI_RNDD);
@@ -172,6 +176,7 @@
   this->type = IID;
   this->func.IID = mpfi_function;
   this->mpfr_func.IID = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iii.c
===================================================================
--- trunk/mpfi/tests/type_iii.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iii.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -161,8 +161,16 @@
   mpfr_init2 (z, mpfi_get_prec (c));
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   random_interval (b);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (b);
+  }
   mpfi_alea (y, b);
   f_III (c, a, b);
   f_RRR (z, x, y, MPFI_RNDD);
@@ -223,6 +231,7 @@
   this->type = III;
   this->func.III = mpfi_function;
   this->mpfr_func.III = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iiq.c
===================================================================
--- trunk/mpfi/tests/type_iiq.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iiq.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -121,6 +121,10 @@
 
   random_mpq (q);
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IIQ (b, a, q);
   f_RRQ (y, x, q, MPFI_RNDD);
@@ -129,7 +133,7 @@
             "the point y, image of (x, q) where x is in a.\na = ");
     mpfi_out_str (stdout, 10, 0, a);
     printf ("\nq = ");
-    mpq_out_str (stdout, 10, q); 
+    mpq_out_str (stdout, 10, q);
     printf ("\nb = ");
     mpfi_out_str (stdout, 10, 0, b);
     printf ("\nx = ");
@@ -176,6 +180,7 @@
   this->type = IIQ;
   this->func.IIQ = mpfi_function;
   this->mpfr_func.IIQ = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iir.c
===================================================================
--- trunk/mpfi/tests/type_iir.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iir.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -120,6 +120,10 @@
   mpfr_ptr z  = &(i->right);
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   random_mpfr (x);
   mpfi_alea (y, a);
   f_IIR (b, a, x);
@@ -177,6 +181,7 @@
   this->type = IIR;
   this->func.IIR = mpfi_function;
   this->mpfr_func.IIR = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iis.c
===================================================================
--- trunk/mpfi/tests/type_iis.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iis.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -120,6 +120,10 @@
 
   si = random_si ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IIS (b, a, si);
   f_RRS (y, x, si, MPFI_RNDD);
@@ -172,6 +176,7 @@
   this->type = IIS;
   this->func.IIS = mpfi_function;
   this->mpfr_func.IIS = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iiu.c
===================================================================
--- trunk/mpfi/tests/type_iiu.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iiu.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -120,6 +120,10 @@
 
   ui = random_ui ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IIU (b, a, ui);
   f_RRU (y, x, ui, MPFI_RNDD);
@@ -172,6 +176,7 @@
   this->type = IIU;
   this->func.IIU = mpfi_function;
   this->mpfr_func.IIU = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iiz.c
===================================================================
--- trunk/mpfi/tests/type_iiz.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iiz.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -123,6 +123,10 @@
 
   random_mpz (z, n);
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IIZ (b, a, z);
   f_RRZ (y, x, z, MPFI_RNDD);
@@ -131,7 +135,7 @@
             "the point y, image of (x, n) where x is in a.\na = ");
     mpfi_out_str (stdout, 10, 0, a);
     printf ("\nn = ");
-    mpz_out_str (stdout, 10, z); 
+    mpz_out_str (stdout, 10, z);
     printf ("\nb = ");
     mpfi_out_str (stdout, 10, 0, b);
     printf ("\nx = ");
@@ -178,6 +182,7 @@
   this->type = IIZ;
   this->func.IIZ = mpfi_function;
   this->mpfr_func.IIZ = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iq.c
===================================================================
--- trunk/mpfi/tests/type_iq.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iq.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -114,6 +114,7 @@
   this->type = IQ;
   this->func.IQ = mpfi_function;
   this->mpfr_func.IQ = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iqi.c
===================================================================
--- trunk/mpfi/tests/type_iqi.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iqi.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -124,6 +124,10 @@
   mpfr_ptr y  = &(i->right);
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   random_mpq (q);
   mpfi_alea (x, a);
   f_IQI (b, q, a);
@@ -180,6 +184,7 @@
   this->type = IQI;
   this->func.IQI = mpfi_function;
   this->mpfr_func.IQI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_ir.c
===================================================================
--- trunk/mpfi/tests/type_ir.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_ir.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -115,6 +115,7 @@
   this->type = IR;
   this->func.IR = mpfi_function;
   this->mpfr_func.IR = mpfr_function;
+  this->random_domain = NULL;
 
   MPFI_FUN_ARGS (*this) =
     (mpfi_fun_operand_t*) malloc (4 * sizeof (mpfi_fun_operand_t));

Modified: trunk/mpfi/tests/type_iri.c
===================================================================
--- trunk/mpfi/tests/type_iri.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iri.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -120,6 +120,10 @@
   mpfr_ptr z  = &(i->right);
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   random_mpfr (x);
   mpfi_alea (y, a);
   f_IRI (b, x, a);
@@ -177,6 +181,7 @@
   this->type = IRI;
   this->func.IRI = mpfi_function;
   this->mpfr_func.IRI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_is.c
===================================================================
--- trunk/mpfi/tests/type_is.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_is.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -112,6 +112,7 @@
   this->type = IS;
   this->func.IS = mpfi_function;
   this->mpfr_func.IS = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_isi.c
===================================================================
--- trunk/mpfi/tests/type_isi.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_isi.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -118,6 +118,10 @@
 
   si = random_si ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_ISI (b, si, a);
   f_RSR (y, si, x, MPFI_RNDD);
@@ -170,6 +174,7 @@
   this->type = ISI;
   this->func.ISI = mpfi_function;
   this->mpfr_func.ISI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iu.c
===================================================================
--- trunk/mpfi/tests/type_iu.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iu.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -112,6 +112,7 @@
   this->type = IU;
   this->func.IU = mpfi_function;
   this->mpfr_func.IU = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iui.c
===================================================================
--- trunk/mpfi/tests/type_iui.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iui.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -118,6 +118,10 @@
 
   ui = random_ui ();
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   mpfi_alea (x, a);
   f_IUI (b, ui, a);
   f_RUR (y, ui, x, MPFI_RNDD);
@@ -170,6 +174,7 @@
   this->type = IUI;
   this->func.IUI = mpfi_function;
   this->mpfr_func.IUI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_iz.c
===================================================================
--- trunk/mpfi/tests/type_iz.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_iz.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -114,6 +114,7 @@
   this->type = IZ;
   this->func.IZ = mpfi_function;
   this->mpfr_func.IZ = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_izi.c
===================================================================
--- trunk/mpfi/tests/type_izi.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_izi.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -122,6 +122,10 @@
   unsigned long n = mpfi_get_prec (a) + 17;
 
   random_interval (a);
+  if (this->random_domain != NULL) {
+    /* restrict the range of random interval to speed up tests */
+    this->random_domain (a);
+  }
   random_mpz (z, n);
   mpfi_alea (x, a);
   f_IZI (b, z, a);
@@ -178,6 +182,7 @@
   this->type = IZI;
   this->func.IZI = mpfi_function;
   this->mpfr_func.IZI = mpfr_function;
+  this->random_domain = NULL;
 
   /* init operands */
   MPFI_FUN_ARGS (*this) =

Modified: trunk/mpfi/tests/type_ri.c
===================================================================
--- trunk/mpfi/tests/type_ri.c	2010-06-24 11:40:01 UTC (rev 319)
+++ trunk/mpfi/tests/type_ri.c	2010-06-24 11:49:12 UTC (rev 320)
@@ -108,6 +108,7 @@
   this->type = RI;
   this->func.RI = mpfi_function;
   this->mpfr_func.RI = mpfr_function;
+  this->random_domain = NULL;
 
   MPFI_FUN_ARGS (*this) =
     (mpfi_fun_operand_t*) malloc (4 * sizeof (mpfi_fun_operand_t));




More information about the Mpfi-commits mailing list