[Gmp-commit] /var/hg/gmp: c_uiui.c: Support limb != ui.

mercurial at gmplib.org mercurial at gmplib.org
Wed May 2 14:13:17 CEST 2012


details:   /var/hg/gmp/rev/dce05d842517
changeset: 14933:dce05d842517
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed May 02 14:13:11 2012 +0200
description:
c_uiui.c: Support limb != ui.

diffstat:

 ChangeLog       |   4 ++++
 mpz/mfac_uiui.c |  19 ++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diffs (53 lines):

diff -r 6daa4e5ce87e -r dce05d842517 ChangeLog
--- a/ChangeLog	Wed May 02 12:36:58 2012 +0200
+++ b/ChangeLog	Wed May 02 14:13:11 2012 +0200
@@ -1,3 +1,7 @@
+2012-05-02 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpz/mfac_uiui.c: Support limb != ui.
+
 2012-05-02  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/arm/logops_n.asm: Work around register clobbering issue.
diff -r 6daa4e5ce87e -r dce05d842517 mpz/mfac_uiui.c
--- a/mpz/mfac_uiui.c	Wed May 02 12:36:58 2012 +0200
+++ b/mpz/mfac_uiui.c	Wed May 02 14:13:11 2012 +0200
@@ -54,7 +54,8 @@
     mp_limb_t g, sn;
     mpz_t     t;
 
-    g = mpn_gcd_1 (&n, 1, m);
+    sn = n;
+    g = mpn_gcd_1 (&sn, 1, m);
     if (g != 1) { n/=g; m/=g; }
 
     if (m <= 2) { /* fac or 2fac */
@@ -63,18 +64,22 @@
 	  mpz_init (t);
 	  mpz_fac_ui (t, n);
 	  sn = n;
-	} else if (g == 2) {
-	  mpz_2fac_ui (x, n << 1);
-	  g = 1;
-	} else
-	  mpz_fac_ui (x, n);
+	} else {
+	  if (g == 2)
+	    mpz_2fac_ui (x, n << 1);
+	  else
+	    mpz_fac_ui (x, n);
+	  return;
+	}
       } else { /* m == 2 */
 	if (g != 1) {
 	  mpz_init (t);
 	  mpz_2fac_ui (t, n);
 	  sn = n / 2 + 1;
-	} else
+	} else {
 	  mpz_2fac_ui (x, n);
+	  return;
+	}
       }
     } else { /* m >= 3, gcd(n,m) = 1 */
       mp_limb_t *factors;


More information about the gmp-commit mailing list