summaryrefslogtreecommitdiff
path: root/mpz/2fac_ui.c
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2012-04-30 15:56:55 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2012-04-30 15:56:55 +0200
commit06b7f8273f049592f27e5b99cf6c66e09cbaa96a (patch)
treede30b3d10e5fdce5b95f33ad70ec76e8fb0c8152 /mpz/2fac_ui.c
parentbc6504b555aceaf03e5964405fea3a96ef880e7c (diff)
downloadgmp-06b7f8273f049592f27e5b99cf6c66e09cbaa96a.tar.gz
Share some tables among combinatoric functions.
Diffstat (limited to 'mpz/2fac_ui.c')
-rw-r--r--mpz/2fac_ui.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/mpz/2fac_ui.c b/mpz/2fac_ui.c
index b1606bfbd..ba719e1c8 100644
--- a/mpz/2fac_ui.c
+++ b/mpz/2fac_ui.c
@@ -50,10 +50,8 @@ mpz_2fac_ui (mpz_ptr x, unsigned long n)
mpz_oddfac_1 (x, n >> 1, 0);
mpz_mul_2exp (x, x, count);
} else { /* n is odd */
- static const mp_limb_t tabled[] = { ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE };
-
- if (n < 2 * numberof (tabled)) {
- PTR (x)[0] = tabled[n >> 1];
+ if (n <= ODD_DOUBLEFACTORIAL_TABLE_LIMIT) {
+ PTR (x)[0] = __gmp_odd2fac_table[n >> 1];
SIZ (x) = 1;
} else if (BELOW_THRESHOLD (n, FAC_2DSC_THRESHOLD)) { /* odd basecase, */
mp_limb_t *factors, prod, max_prod, j;
@@ -63,12 +61,12 @@ mpz_2fac_ui (mpz_ptr x, unsigned long n)
TMP_SMARK;
factors = TMP_SALLOC_LIMBS (1 + n / (2 * FACTORS_PER_LIMB));
- factors[0] = tabled[numberof (tabled) - 1];
+ factors[0] = ODD_DOUBLEFACTORIAL_TABLE_MAX;
j = 1;
prod = n;
max_prod = GMP_NUMB_MAX / FAC_2DSC_THRESHOLD;
- while ((n -= 2) >= numberof (tabled) * 2 + 1)
+ while ((n -= 2) > ODD_DOUBLEFACTORIAL_TABLE_LIMIT)
FACTOR_LIST_STORE (n, prod, max_prod, factors, j);
factors[j++] = prod;