[Gmp-commit] /home/hgfiles/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 16 16:38:35 CET 2009


details:   /home/hgfiles/gmp/rev/f440dc0cfb1e
changeset: 13090:f440dc0cfb1e
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Wed Dec 16 16:37:31 2009 +0100
description:
Fixed an ASSERT in mpn_gcdext_lehmer_n, and added a corresponding test case.

details:   /home/hgfiles/gmp/rev/34f43c28d9f6
changeset: 13091:34f43c28d9f6
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Wed Dec 16 16:38:29 2009 +0100
description:
Updated (c) year.

diffstat:

 ChangeLog                   |  8 ++++++++
 mpn/generic/gcdext_1.c      |  2 +-
 mpn/generic/gcdext_lehmer.c |  2 +-
 tests/mpz/t-gcd.c           |  7 +++++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diffs (55 lines):

diff -r 016e9203102f -r 34f43c28d9f6 ChangeLog
--- a/ChangeLog	Wed Dec 16 15:32:44 2009 +0100
+++ b/ChangeLog	Wed Dec 16 16:38:29 2009 +0100
@@ -1,3 +1,11 @@
+2009-12-16  Niels Möller  <nisse at lysator.liu.se>
+
+	* tests/mpz/t-gcd.c (main): Added test case to exercise the
+	unlikely u0 == u1 case in mpn_gcdext_lehmer_n.
+
+	* mpn/generic/gcdext_lehmer.c (mpn_gcdext_lehmer_n): Get ASSERT
+	right.
+
 2009-12-16  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tune/speed.c (routine): Measure speed_mpn_{sb,dc}pi1_div_qr,
diff -r 016e9203102f -r 34f43c28d9f6 mpn/generic/gcdext_1.c
--- a/mpn/generic/gcdext_1.c	Wed Dec 16 15:32:44 2009 +0100
+++ b/mpn/generic/gcdext_1.c	Wed Dec 16 16:38:29 2009 +0100
@@ -1,6 +1,6 @@
 /* mpn_gcdext -- Extended Greatest Common Divisor.
 
-Copyright 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 Free Software
+Copyright 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 Free Software
 Foundation, Inc.
 
 This file is part of the GNU MP Library.
diff -r 016e9203102f -r 34f43c28d9f6 mpn/generic/gcdext_lehmer.c
--- a/mpn/generic/gcdext_lehmer.c	Wed Dec 16 15:32:44 2009 +0100
+++ b/mpn/generic/gcdext_lehmer.c	Wed Dec 16 16:38:29 2009 +0100
@@ -134,7 +134,7 @@
       gp[0] = ap[0];
 
       MPN_CMP (c, u0, u1, un);
-      ASSERT (c != 0);
+      ASSERT (c != 0 || (un == 1 && u0[0] == 1 && u1[0] == 1));
       if (c < 0)
 	{
 	  MPN_NORMALIZE (u0, un);
diff -r 016e9203102f -r 34f43c28d9f6 tests/mpz/t-gcd.c
--- a/tests/mpz/t-gcd.c	Wed Dec 16 15:32:44 2009 +0100
+++ b/tests/mpz/t-gcd.c	Wed Dec 16 16:38:29 2009 +0100
@@ -130,6 +130,13 @@
   mpz_init (s);
   mpz_init (t);
 
+  /* Testcase to exercise the u0 == u1 case in mpn_gcdext_lehmer_n. */
+  mpz_set_ui (op2, GMP_NUMB_MAX);
+  mpz_mul_2exp (op1, op2, 100);
+  mpz_add (op1, op1, op2);
+  mpz_mul_ui (op2, op2, 2);
+  one_test (op1, op2, NULL, -1);
+  
 #if 0
   mpz_set_str (op1, "4da8e405e0d2f70d6d679d3de08a5100a81ec2cff40f97b313ae75e1183f1df2b244e194ebb02a4ece50d943640a301f0f6cc7f539117b783c3f3a3f91649f8a00d2e1444d52722810562bce02fccdbbc8fe3276646e306e723dd3b", 16);
   mpz_set_str (op2, "76429e12e4fdd8929d89c21657097fbac09d1dc08cf7f1323a34e78ca34226e1a7a29b86fee0fa7fe2cc2a183d46d50df1fe7029590974ad7da77605f35f902cb8b9b8d22dd881eaae5919675d49a337145a029c3b33fc2b0", 16);


More information about the gmp-commit mailing list