[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Mon Mar 3 16:12:35 UTC 2014


details:   /var/hg/gmp/rev/f51e98c9f1cc
changeset: 16321:f51e98c9f1cc
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Mon Mar 03 16:58:16 2014 +0100
description:
mini-gmp tests: Move dump function to testutils.c.

details:   /var/hg/gmp/rev/f5eec81b94aa
changeset: 16322:f5eec81b94aa
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Mon Mar 03 17:02:09 2014 +0100
description:
mini-gmp tests: Move mpz_set_str_or_abort to testutils.c.

details:   /var/hg/gmp/rev/4b2fa878f853
changeset: 16323:4b2fa878f853
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Mon Mar 03 17:12:25 2014 +0100
description:
mini-gmp: New function mpz_congruent_p.

diffstat:

 ChangeLog                   |  15 +++++++++++++++
 mini-gmp/mini-gmp.c         |  18 ++++++++++++++++++
 mini-gmp/mini-gmp.h         |   1 +
 mini-gmp/tests/Makefile     |   2 +-
 mini-gmp/tests/t-add.c      |   8 --------
 mini-gmp/tests/t-aorsmul.c  |   8 --------
 mini-gmp/tests/t-bitops.c   |   8 --------
 mini-gmp/tests/t-cmp_d.c    |  12 ------------
 mini-gmp/tests/t-div.c      |   8 --------
 mini-gmp/tests/t-div_2exp.c |   8 --------
 mini-gmp/tests/t-double.c   |   8 --------
 mini-gmp/tests/t-gcd.c      |   8 --------
 mini-gmp/tests/t-import.c   |   8 --------
 mini-gmp/tests/t-invert.c   |   8 --------
 mini-gmp/tests/t-lcm.c      |   8 --------
 mini-gmp/tests/t-limbs.c    |   8 --------
 mini-gmp/tests/t-logops.c   |   8 --------
 mini-gmp/tests/t-mul.c      |   8 --------
 mini-gmp/tests/t-powm.c     |   8 --------
 mini-gmp/tests/t-reuse.c    |   8 ++++----
 mini-gmp/tests/t-root.c     |   8 --------
 mini-gmp/tests/t-scan.c     |   8 --------
 mini-gmp/tests/t-sqrt.c     |   8 --------
 mini-gmp/tests/t-str.c      |   8 --------
 mini-gmp/tests/t-sub.c      |   8 --------
 mini-gmp/tests/testutils.c  |  22 +++++++++++++++++++++-
 mini-gmp/tests/testutils.h  |   8 +++++++-
 27 files changed, 67 insertions(+), 171 deletions(-)

diffs (truncated from 529 to 300 lines):

diff -r 2ac090cf082a -r 4b2fa878f853 ChangeLog
--- a/ChangeLog	Sat Mar 01 11:42:08 2014 +0100
+++ b/ChangeLog	Mon Mar 03 17:12:25 2014 +0100
@@ -1,3 +1,18 @@
+2014-03-03  Niels Möller  <nisse at lysator.liu.se>
+
+	* mini-gmp/mini-gmp.c (mpz_congruent_p): New function.
+	* mini-gmp/mini-gmp.h: Declare it.
+	* mini-gmp/tests/t-cong.c: New file, based on tests/mpz/t-cong.c.
+	* mini-gmp/tests/Makefile (CHECK_PROGRAMS): Added t-cong.
+
+	* mini-gmp/tests/testutils.c (dump): New function. Deleted static
+	functions in other files.
+	(mpz_set_str_or_abort): Moved function here, from...
+	* mini-gmp/tests/t-cmp_d.c: ... old location.
+
+	* mini-gmp/tests/t-reuse.c (dump3): Renamed, from ...
+	(dump): ...old name.
+
 2014-03-01  Niels Möller  <nisse at lysator.liu.se>
 
 	* mpn/generic/sec_powm.c (mpn_sec_powm): Clarify comment and
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/mini-gmp.c	Mon Mar 03 17:12:25 2014 +0100
@@ -2490,6 +2490,24 @@
   return mpz_div_qr (NULL, NULL, n, d, GMP_DIV_TRUNC) == 0;
 }
 
+int
+mpz_congruent_p (const mpz_t a, const mpz_t b, const mpz_t m)
+{
+  mpz_t t;
+  int res;
+
+  /* a == b (mod 0) iff a == b */
+  if (mpz_sgn (m) == 0)
+    return (mpz_cmp (a, b) == 0);
+
+  mpz_init (t);
+  mpz_sub (t, a, b);
+  res = mpz_divisible_p (t, m);
+  mpz_clear (t);
+
+  return res;
+}
+
 static unsigned long
 mpz_div_qr_ui (mpz_t q, mpz_t r,
 	       const mpz_t n, unsigned long d, enum mpz_div_round_mode mode)
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/mini-gmp.h
--- a/mini-gmp/mini-gmp.h	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/mini-gmp.h	Mon Mar 03 17:12:25 2014 +0100
@@ -172,6 +172,7 @@
 void mpz_divexact (mpz_t, const mpz_t, const mpz_t);
 
 int mpz_divisible_p (const mpz_t, const mpz_t);
+int mpz_congruent_p (const mpz_t, const mpz_t, const mpz_t);
 
 unsigned long mpz_cdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long);
 unsigned long mpz_fdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long);
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/Makefile
--- a/mini-gmp/tests/Makefile	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/Makefile	Mon Mar 03 17:12:25 2014 +0100
@@ -30,7 +30,7 @@
 CHECK_PROGRAMS = t-add t-sub t-mul t-invert t-div t-div_2exp \
 	t-double t-cmp_d t-gcd t-lcm t-import t-comb t-signed \
 	t-sqrt t-root t-powm t-logops t-bitops t-scan t-str \
-	t-reuse t-aorsmul t-limbs
+	t-reuse t-aorsmul t-limbs t-cong
 
 MISC_OBJS = hex-random.o mini-random.o testutils.o
 
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-add.c
--- a/mini-gmp/tests/t-add.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-add.c	Mon Mar 03 17:12:25 2014 +0100
@@ -25,14 +25,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 testmain (int argc, char **argv)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-aorsmul.c
--- a/mini-gmp/tests/t-aorsmul.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-aorsmul.c	Mon Mar 03 17:12:25 2014 +0100
@@ -30,14 +30,6 @@
 #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
 #define MAXLIMBS ((MAXBITS + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS)
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 testmain (int argc, char **argv)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-bitops.c
--- a/mini-gmp/tests/t-bitops.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-bitops.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 testmain (int argc, char **argv)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-cmp_d.c
--- a/mini-gmp/tests/t-cmp_d.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-cmp_d.c	Mon Mar 03 17:12:25 2014 +0100
@@ -64,18 +64,6 @@
     }
 }
 
-static void
-mpz_set_str_or_abort (mpz_ptr z, const char *str, int base)
-{
-  if (mpz_set_str (z, str, base) != 0)
-    {
-      fprintf (stderr, "ERROR: mpz_set_str failed\n");
-      fprintf (stderr, "   str  = \"%s\"\n", str);
-      fprintf (stderr, "   base = %d\n", base);
-      abort();
-    }
-}
-
 void
 check_data (void)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-div.c
--- a/mini-gmp/tests/t-div.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-div.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 typedef void div_qr_func (mpz_t, mpz_t, const mpz_t, const mpz_t);
 typedef unsigned long div_qr_ui_func (mpz_t, mpz_t, const mpz_t, unsigned long);
 typedef void div_func (mpz_t, const mpz_t, const mpz_t);
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-div_2exp.c
--- a/mini-gmp/tests/t-div_2exp.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-div_2exp.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 typedef void div_func (mpz_t, const mpz_t, mp_bitcnt_t);
 
 void
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-double.c
--- a/mini-gmp/tests/t-double.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-double.c	Mon Mar 03 17:12:25 2014 +0100
@@ -29,14 +29,6 @@
 
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 static const struct
 {
   double d;
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-gcd.c
--- a/mini-gmp/tests/t-gcd.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-gcd.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 /* Called when g is supposed to be gcd(a,b), and g = s a + t b. */
 static int
 gcdext_valid_p (const mpz_t a, const mpz_t b,
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-import.c
--- a/mini-gmp/tests/t-import.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-import.c	Mon Mar 03 17:12:25 2014 +0100
@@ -27,14 +27,6 @@
 #define MAX_WORD_SIZE 10
 
 static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
-static void
 dump_bytes (const char *label, const unsigned char *s, size_t n)
 {
   size_t i;
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-invert.c
--- a/mini-gmp/tests/t-invert.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-invert.c	Mon Mar 03 17:12:25 2014 +0100
@@ -27,14 +27,6 @@
 
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 testmain (int argc, char **argv)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-lcm.c
--- a/mini-gmp/tests/t-lcm.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-lcm.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 testmain (int argc, char **argv)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-limbs.c
--- a/mini-gmp/tests/t-limbs.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-limbs.c	Mon Mar 03 17:12:25 2014 +0100
@@ -27,14 +27,6 @@
 #define MAXBITS 400
 #define COUNT 100
 
-static void
-dump (const char *label, const mpz_t x)
-{
-  char *buf = mpz_get_str (NULL, 16, x);
-  fprintf (stderr, "%s: %s\n", label, buf);
-  testfree (buf);
-}
-
 void
 my_mpz_mul (mpz_t r, mpz_srcptr a,  mpz_srcptr b)
 {
diff -r 2ac090cf082a -r 4b2fa878f853 mini-gmp/tests/t-logops.c
--- a/mini-gmp/tests/t-logops.c	Sat Mar 01 11:42:08 2014 +0100
+++ b/mini-gmp/tests/t-logops.c	Mon Mar 03 17:12:25 2014 +0100
@@ -26,14 +26,6 @@
 #define MAXBITS 400
 #define COUNT 10000
 


More information about the gmp-commit mailing list