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

mercurial at gmplib.org mercurial at gmplib.org
Sun Mar 4 07:02:54 CET 2012


details:   /var/hg/gmp/rev/b5ebb563d5c9
changeset: 14722:b5ebb563d5c9
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Mar 04 06:57:38 2012 +0100
description:
Typo in demos/primes.c

details:   /var/hg/gmp/rev/7eb3497228ac
changeset: 14723:7eb3497228ac
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Mar 04 07:02:49 2012 +0100
description:
mpz_invert: remove mod 0 branch.

diffstat:

 ChangeLog            |  5 +++++
 demos/primes.c       |  2 +-
 mpz/invert.c         |  8 ++++----
 tests/mpz/t-invert.c |  6 ++++--
 4 files changed, 14 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 60e29dbe3ccb -r 7eb3497228ac ChangeLog
--- a/ChangeLog	Sat Mar 03 20:50:30 2012 +0100
+++ b/ChangeLog	Sun Mar 04 07:02:49 2012 +0100
@@ -1,3 +1,8 @@
+2012-03-04 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpz/invert.c: Remove mod 0 branch.
+	* tests/mpz/t-invert.c: Avoid testing mod 0.
+
 2012-03-03  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86_64/k8/gmp-mparam.h: New file.
diff -r 60e29dbe3ccb -r 7eb3497228ac demos/primes.c
--- a/demos/primes.c	Sat Mar 03 20:50:30 2012 +0100
+++ b/demos/primes.c	Sun Mar 04 07:02:49 2012 +0100
@@ -62,7 +62,7 @@
 unsigned long n_primes;
 
 void find_primes (unsigned char *, mpz_t, unsigned long, mpz_t);
-void sieve_region ((unsigned char *, mpz_t, unsigned long);
+void sieve_region (unsigned char *, mpz_t, unsigned long);
 void make_primelist (unsigned long);
 
 int flag_print = 1;
diff -r 60e29dbe3ccb -r 7eb3497228ac mpz/invert.c
--- a/mpz/invert.c	Sat Mar 03 20:50:30 2012 +0100
+++ b/mpz/invert.c	Sun Mar 04 07:02:49 2012 +0100
@@ -2,8 +2,8 @@
    If X has an inverse, return non-zero and store inverse in INVERSE,
    otherwise, return 0 and put garbage in INVERSE.
 
-Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 Free Software Foundation,
-Inc.
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2012 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -34,8 +34,8 @@
   nsize = ABSIZ (n);
 
   /* No inverse exists if the leftside operand is 0.  Likewise, no
-     inverse exists if the mod operand is 1 or 0.  */
-  if (xsize == 0 || nsize == 0 || (nsize == 1 && (PTR (n))[0] == 1))
+     inverse exists if the mod operand is 1.  */
+  if (xsize == 0 || (nsize == 1 && (PTR (n))[0] == 1))
     return 0;
 
   size = MAX (xsize, nsize) + 1;
diff -r 60e29dbe3ccb -r 7eb3497228ac tests/mpz/t-invert.c
--- a/tests/mpz/t-invert.c	Sat Mar 03 20:50:30 2012 +0100
+++ b/tests/mpz/t-invert.c	Sun Mar 04 07:02:49 2012 +0100
@@ -53,8 +53,10 @@
 
       mpz_urandomb (bs, rands, size_range);
       mpz_rrandomb (a, rands, mpz_get_ui (bs));
-      mpz_urandomb (bs, rands, size_range);
-      mpz_rrandomb (m, rands, mpz_get_ui (bs));
+      do {
+	mpz_urandomb (bs, rands, size_range);
+	mpz_rrandomb (m, rands, mpz_get_ui (bs));
+      } while (mpz_sgn (m) == 0);
 
       mpz_urandomb (bs, rands, 8);
       bsi = mpz_get_ui (bs);


More information about the gmp-commit mailing list