[Gmp-commit] /var/hg/gmp-5.0: Get ASSERT right.

mercurial at gmplib.org mercurial at gmplib.org
Tue Feb 7 22:10:51 CET 2012


details:   /var/hg/gmp-5.0/rev/5bed10c29692
changeset: 13549:5bed10c29692
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Tue Feb 07 22:10:41 2012 +0100
description:
Get ASSERT right.

diffstat:

 ChangeLog            |  5 +++++
 mpn/generic/gcdext.c |  5 ++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diffs (27 lines):

diff -r 77785806d3f1 -r 5bed10c29692 ChangeLog
--- a/ChangeLog	Mon Feb 06 22:28:53 2012 +0100
+++ b/ChangeLog	Tue Feb 07 22:10:41 2012 +0100
@@ -1,3 +1,8 @@
+2012-02-07  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/gcdext.c (mpn_gcdext): Fixed assert, related to the
+	special case A = (2k+1) G, B = 2 G.
+
 2012-02-06  Niels Möller  <nisse at lysator.liu.se>
 
 	* mpn/generic/hgcd.c (hgcd_matrix_update_q): Fixed carry handling
diff -r 77785806d3f1 -r 5bed10c29692 mpn/generic/gcdext.c
--- a/mpn/generic/gcdext.c	Mon Feb 06 22:28:53 2012 +0100
+++ b/mpn/generic/gcdext.c	Tue Feb 07 22:10:41 2012 +0100
@@ -386,7 +386,10 @@
       MPN_COPY (gp, ap, n);
 
       MPN_CMP (c, u0, u1, un);
-      ASSERT (c != 0);
+      /* c == 0 can happen only when A = (2k+1) G, B = 2 G. And in
+	 this case we choose the cofactor + 1, corresponding to G = A
+	 - k B, rather than -1, corresponding to G = - A + (k+1) B. */
+      ASSERT (c != 0 || (un == 1 && u0[0] == 1 && u1[0] == 1));
       if (c < 0)
 	{
 	  MPN_NORMALIZE (u0, un);


More information about the gmp-commit mailing list