[Gmp-commit] /var/hg/gmp-5.0: Also normalize the product q * u0.

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 5 20:44:39 CET 2012


details:   /var/hg/gmp-5.0/rev/11a901ce5242
changeset: 13545:11a901ce5242
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sun Feb 05 20:44:21 2012 +0100
description:
Also normalize the product q * u0.

diffstat:

 ChangeLog                        |  3 ++-
 mpn/generic/gcdext_subdiv_step.c |  4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r eab9e2a8bf48 -r 11a901ce5242 ChangeLog
--- a/ChangeLog	Sun Feb 05 19:36:21 2012 +0100
+++ b/ChangeLog	Sun Feb 05 20:44:21 2012 +0100
@@ -1,7 +1,8 @@
 2012-02-05  Niels Möller  <nisse at lysator.liu.se>
 
 	* mpn/generic/gcdext_subdiv_step.c (mpn_gcdext_subdiv_step):
-	Bugfix, in u1 += q * u0, handle carry in all cases.
+	Bugfix, in u1 += q * u0, handle carry in all cases. Also normalize
+	the product q * u0.
 
 2012-02-04 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
diff -r eab9e2a8bf48 -r 11a901ce5242 mpn/generic/gcdext_subdiv_step.c
--- a/mpn/generic/gcdext_subdiv_step.c	Sun Feb 05 19:36:21 2012 +0100
+++ b/mpn/generic/gcdext_subdiv_step.c	Sun Feb 05 20:44:21 2012 +0100
@@ -181,8 +181,10 @@
 
       if (qn + u0n > un)
 	{
-	  u1[qn + u0n] = mpn_add (u1, tp, qn + u0n, u1, un);
+	  mp_size_t u1n = un;
 	  un = qn + u0n;
+	  un -= (tp[un-1] == 0);	  
+	  u1[un] = mpn_add (u1, tp, un, u1, u1n);
 	}
       else
 	{


More information about the gmp-commit mailing list