[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Tue Feb 12 16:44:11 CET 2013
details: /var/hg/gmp/rev/12889e7bf040
changeset: 15405:12889e7bf040
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Feb 12 16:25:59 2013 +0100
description:
mpn/generic/brootinv.c: Micro-optimisation.
details: /var/hg/gmp/rev/55cb7482ddf1
changeset: 15406:55cb7482ddf1
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Feb 12 16:43:55 2013 +0100
description:
mpf/set_str.c: Don't chech base==0 when base is strictly positive.
details: /var/hg/gmp/rev/26b6c6d4f7a5
changeset: 15407:26b6c6d4f7a5
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Tue Feb 12 16:44:04 2013 +0100
description:
ChangeLog
diffstat:
ChangeLog | 4 ++++
mpf/set_str.c | 4 ++--
mpn/generic/brootinv.c | 22 ++++++++++------------
3 files changed, 16 insertions(+), 14 deletions(-)
diffs (80 lines):
diff -r c09b54202499 -r 26b6c6d4f7a5 ChangeLog
--- a/ChangeLog Tue Feb 12 15:42:11 2013 +0100
+++ b/ChangeLog Tue Feb 12 16:44:04 2013 +0100
@@ -17,6 +17,10 @@
* mpz/urandomb.c: Likewise.
* mpn/generic/random2.c: Likewise.
+ * mpn/generic/brootinv.c: Micro-optimisation.
+
+ * mpf/set_str.c: Don't chech base==0 when base is strictly positive.
+
2013-02-10 Torbjorn Granlund <tege at gmplib.org>
* Version 5.1.1 released.
diff -r c09b54202499 -r 26b6c6d4f7a5 mpf/set_str.c
--- a/mpf/set_str.c Tue Feb 12 15:42:11 2013 +0100
+++ b/mpf/set_str.c Tue Feb 12 16:44:04 2013 +0100
@@ -160,13 +160,13 @@
}
/* Require at least one digit, possibly after an initial decimal point. */
- if (digit_value[c] >= (base == 0 ? 10 : base))
+ if (digit_value[c] >= base)
{
/* not a digit, must be a decimal point */
for (i = 0; i < pointlen; i++)
if (str[i] != point[i])
return -1;
- if (digit_value[(unsigned char) str[pointlen]] >= (base == 0 ? 10 : base))
+ if (digit_value[(unsigned char) str[pointlen]] >= base)
return -1;
}
diff -r c09b54202499 -r 26b6c6d4f7a5 mpn/generic/brootinv.c
--- a/mpn/generic/brootinv.c Tue Feb 12 15:42:11 2013 +0100
+++ b/mpn/generic/brootinv.c Tue Feb 12 16:44:04 2013 +0100
@@ -27,12 +27,11 @@
static mp_limb_t
powlimb (mp_limb_t a, mp_limb_t e)
{
- mp_limb_t r = 1;
- mp_limb_t s = a;
+ mp_limb_t r;
- for (r = 1, s = a; e > 0; e >>= 1, s *= s)
+ for (r = 1; e > 0; e >>= 1, a *= a)
if (e & 1)
- r *= s;
+ r *= a;
return r;
}
@@ -80,20 +79,19 @@
/* 4-bit initial approximation:
y%16 | 1 3 5 7 9 11 13 15,
- k%4 +-----------------------------
- 1 | 1 11 13 7 9 3 5 15
- 3 | 1 3 5 7 9 11 13 15
+ k%4 +-------------------------+k2%4
+ 1 | 1 11 13 7 9 3 5 15 | 2
+ 3 | 1 3 5 7 9 11 13 15 | 0
*/
y0 = yp[0];
- r0 = y0 ^ (((y0 << 1) ^ (y0 << 2)) & ~(k << 2) & 8); /* 4 bits */
+ r0 = y0 ^ (((y0 << 1) ^ (y0 << 2)) & (k2 << 2) & 8); /* 4 bits */
r0 = kinv * (k2 * r0 - y0 * powlimb(r0, k2 & 0x7f)); /* 8 bits */
- r0 = kinv * (k2 * r0 - y0 * powlimb(r0, k2 & 0xffff)); /* 16 bits */
- r0 = kinv * (k2 * r0 - y0 * powlimb(r0, k2)); /* 32 bits */
-#if GMP_NUMB_BITS > 32
+ r0 = kinv * (k2 * r0 - y0 * powlimb(r0, k2 & 0x7fff)); /* 16 bits */
+#if GMP_NUMB_BITS > 16
{
- unsigned prec = 32;
+ unsigned prec = 16;
do
{
r0 = kinv * (k2 * r0 - y0 * powlimb(r0, k2));
More information about the gmp-commit
mailing list