[Gmp-commit] /var/hg/gmp: mpz/oddfac_1.c (FACTORS_PER_LIMB): Not too conserva...

mercurial at gmplib.org mercurial at gmplib.org
Sun Nov 14 10:52:33 UTC 2021


details:   /var/hg/gmp/rev/2d0aa5059850
changeset: 18285:2d0aa5059850
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Nov 14 11:52:22 2021 +0100
description:
mpz/oddfac_1.c (FACTORS_PER_LIMB): Not too conservative...

diffstat:

 mpz/oddfac_1.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (24 lines):

diff -r c30a956aa82f -r 2d0aa5059850 mpz/oddfac_1.c
--- a/mpz/oddfac_1.c	Thu Nov 11 21:34:10 2021 +0100
+++ b/mpz/oddfac_1.c	Sun Nov 14 11:52:22 2021 +0100
@@ -260,9 +260,9 @@
 /* FIXME: refine che following estimate. */
 
 #if TUNE_PROGRAM_BUILD
-#define FACTORS_PER_LIMB (GMP_NUMB_BITS / (LOG2C(FAC_DSC_THRESHOLD_LIMIT*FAC_DSC_THRESHOLD_LIMIT-1)+1) * 2 - 1)
+#define FACTORS_PER_LIMB (GMP_NUMB_BITS * 2 / (LOG2C(FAC_DSC_THRESHOLD_LIMIT*FAC_DSC_THRESHOLD_LIMIT-1)+1) - 1)
 #else
-#define FACTORS_PER_LIMB (GMP_NUMB_BITS / (LOG2C(FAC_DSC_THRESHOLD*FAC_DSC_THRESHOLD-1)+1) * 2 - 1)
+#define FACTORS_PER_LIMB (GMP_NUMB_BITS * 2 / (LOG2C(FAC_DSC_THRESHOLD*FAC_DSC_THRESHOLD-1)+1) - 1)
 #endif
 
 /* mpz_oddfac_1 computes the odd part of the factorial of the
@@ -335,7 +335,7 @@
 	ASSERT (tn > ODD_DOUBLEFACTORIAL_TABLE_LIMIT + 1);
 	do {
 	  factors[j++] = ODD_DOUBLEFACTORIAL_TABLE_MAX;
-	  mp_limb_t diff = tn - ODD_DOUBLEFACTORIAL_TABLE_LIMIT & -CNST_LIMB (2);
+	  mp_limb_t diff = (tn - ODD_DOUBLEFACTORIAL_TABLE_LIMIT) & -CNST_LIMB (2);
 	  if ((diff & 2) != 0)
 	    {
 	      FACTOR_LIST_STORE (ODD_DOUBLEFACTORIAL_TABLE_LIMIT + diff, prod, max_prod, factors, j);


More information about the gmp-commit mailing list