[Gmp-commit] /var/hg/gmp: tests/mpz/t-primorial_ui.c: Test a single "large" n...

mercurial at gmplib.org mercurial at gmplib.org
Sun Nov 22 07:34:02 UTC 2015


details:   /var/hg/gmp/rev/1c1e187d843c
changeset: 16976:1c1e187d843c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Nov 22 08:33:53 2015 +0100
description:
tests/mpz/t-primorial_ui.c: Test a single "large" number.

diffstat:

 ChangeLog                  |   1 +
 tests/mpz/t-primorial_ui.c |  26 ++++++++++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 8aac33bb5843 -r 1c1e187d843c ChangeLog
--- a/ChangeLog	Sat Nov 21 17:35:22 2015 +0100
+++ b/ChangeLog	Sun Nov 22 08:33:53 2015 +0100
@@ -3,6 +3,7 @@
 	* gmp-impl.h (MPN_TOOM22_MUL_MINSIZE): Consider ToomX2 limits
 	  (thanks Paul).
 	* tests/mpn/t-toom22.c: Keep on testing small sizes.
+	* tests/mpz/t-primorial_ui.c: Test a single "large" number.
 
 2015-11-13 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
diff -r 8aac33bb5843 -r 1c1e187d843c tests/mpz/t-primorial_ui.c
--- a/tests/mpz/t-primorial_ui.c	Sat Nov 21 17:35:22 2015 +0100
+++ b/tests/mpz/t-primorial_ui.c	Sun Nov 22 08:33:53 2015 +0100
@@ -1,6 +1,6 @@
 /* Exercise mpz_primorial_ui.
 
-Copyright 2000-2002, 2012 Free Software Foundation, Inc.
+Copyright 2000-2002, 2012, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -53,7 +53,8 @@
   mpz_init_set_ui (f, 1);  /* 0# = 1 */
   mpz_init (r);
 
-  for (n = 0; n < limit; n++)
+  n = 0;
+  do
     {
       mpz_primorial_ui (r, n);
       MPZ_CHECK_FORMAT (r);
@@ -66,8 +67,25 @@
           abort ();
         }
 
-      if (isprime (n+1))
-	mpz_mul_ui (f, f, n+1);  /* p# = (p-1)# * (p) */
+      if (isprime (++n))
+	mpz_mul_ui (f, f, n);  /* p# = (p-1)# * (p) */
+      if (n%16 == 0) { mpz_clear (r); mpz_init (r); }
+    } while (n < limit);
+
+  /* Chech a single "big" value, modulo a larger prime */
+  n = 2095637;
+  mpz_primorial_ui (r, n);
+  mpz_set_ui (f, 13);
+  mpz_setbit (f, 64); /* f = 2^64 + 13 */
+  mpz_tdiv_r (r, r, f);
+  mpz_set_str (f, "BAFCBF3C95B217D5", 16);
+  
+  if (mpz_cmp (f, r) != 0)
+    {
+      printf ("mpz_primorial_ui(%lu) wrong\n", n);
+      printf ("  got  "); mpz_out_str (stdout, 10, r); printf("\n");
+      printf ("  want "); mpz_out_str (stdout, 10, f); printf("\n");
+      abort ();
     }
 
   mpz_clear (f);


More information about the gmp-commit mailing list