[Gmp-commit] /var/hg/gmp: 5 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Thu Sep 3 19:43:33 UTC 2015
details: /var/hg/gmp/rev/82b6624481e1
changeset: 16814:82b6624481e1
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Sep 03 21:33:07 2015 +0200
description:
Copyright year
details: /var/hg/gmp/rev/992a514c9b38
changeset: 16815:992a514c9b38
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Sep 03 21:34:24 2015 +0200
description:
tests/mpq/t-cmp_z.c (sizes_test): New function, testing different sizes.
details: /var/hg/gmp/rev/eb5887de57c5
changeset: 16816:eb5887de57c5
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Sep 03 21:40:16 2015 +0200
description:
mpn_bsqrt: swap tp and sp roles (untested, unused...)
details: /var/hg/gmp/rev/2b36ea3faf16
changeset: 16817:2b36ea3faf16
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Sep 03 21:41:33 2015 +0200
description:
mpz/sqrt.c: Use MPZ_NEWALLOC.
details: /var/hg/gmp/rev/250ef73fd806
changeset: 16818:250ef73fd806
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Thu Sep 03 21:41:39 2015 +0200
description:
ChangeLog
diffstat:
ChangeLog | 4 +++
mpn/generic/bsqrt.c | 6 ++--
mpz/sqrt.c | 2 +-
tests/mpq/t-cmp_z.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/mpz/t-fac_ui.c | 2 +-
5 files changed, 63 insertions(+), 5 deletions(-)
diffs (125 lines):
diff -r ab02d29d71d5 -r 250ef73fd806 ChangeLog
--- a/ChangeLog Thu Sep 03 20:17:15 2015 +0200
+++ b/ChangeLog Thu Sep 03 21:41:39 2015 +0200
@@ -1,3 +1,7 @@
+2015-09-03 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * tests/mpq/t-cmp_z.c (sizes_test): New function, tests sizes.
+
2015-09-03 Torbjörn Granlund <torbjorng at google.com>
* acinclude.m4 (GMP_C_HIDDEN_ALIAS): New.
diff -r ab02d29d71d5 -r 250ef73fd806 mpn/generic/bsqrt.c
--- a/mpn/generic/bsqrt.c Thu Sep 03 20:17:15 2015 +0200
+++ b/mpn/generic/bsqrt.c Thu Sep 03 21:41:39 2015 +0200
@@ -1,6 +1,6 @@
/* mpn_bsqrt, a^{1/2} (mod 2^n).
-Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
+Copyright 2009, 2010, 2012, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -43,6 +43,6 @@
n = nb / GMP_NUMB_BITS;
sp = tp + n;
- mpn_bsqrtinv (sp, ap, nb, tp);
- mpn_mullo_n (rp, sp, ap, n);
+ mpn_bsqrtinv (tp, ap, nb, sp);
+ mpn_mullo_n (rp, tp, ap, n);
}
diff -r ab02d29d71d5 -r 250ef73fd806 mpz/sqrt.c
--- a/mpz/sqrt.c Thu Sep 03 20:17:15 2015 +0200
+++ b/mpz/sqrt.c Thu Sep 03 21:41:39 2015 +0200
@@ -70,7 +70,7 @@
}
else
{
- root_ptr = MPZ_REALLOC (root, root_size);
+ root_ptr = MPZ_NEWALLOC (root, root_size);
mpn_sqrtrem (root_ptr, NULL, op_ptr, op_size);
}
diff -r ab02d29d71d5 -r 250ef73fd806 tests/mpq/t-cmp_z.c
--- a/tests/mpq/t-cmp_z.c Thu Sep 03 20:17:15 2015 +0200
+++ b/tests/mpq/t-cmp_z.c Thu Sep 03 21:41:39 2015 +0200
@@ -44,6 +44,58 @@
#define SIZE 8 /* increasing this lowers the probability of finding an error */
#endif
+#ifndef MAXN
+#define MAXN 5 /* increasing this impatcs on total timing */
+#endif
+
+void
+sizes_test (int m)
+{
+ mpq_t a;
+ mpz_t b;
+ int i, j, k, s;
+ int cc, ccref;
+
+ mpq_init (a);
+ mpz_init (b);
+
+ for (i = 0; i <= MAXN ; ++i)
+ {
+ mpz_setbit (DEN (a), i*m); /* \sum_0^i 2^(i*m) */
+ for (j = 0; j <= MAXN; ++j)
+ {
+ mpz_set_ui (NUM (a), 0);
+ mpz_setbit (NUM (a), j*m); /* 2^(j*m) */
+ for (k = 0; k <= MAXN; ++k)
+ {
+ mpz_set_ui (b, 0);
+ mpz_setbit (b, k*m); /* 2^(k*m) */
+ if (i == 0) /* Denominator is 1, compare the two exponents */
+ ccref = (j>k)-(j<k);
+ else
+ ccref = j-i > k ? 1 : -1;
+ for (s = 1; s >= -1; s -= 2)
+ {
+ cc = mpq_cmp_z (a, b);
+
+ if (ccref != SGN (cc))
+ {
+ fprintf (stderr, "i=%i, j=%i, k=%i, m=%i, s=%i\n; ccref= %i, cc= %i\n", i, j, k, m, s, ccref, cc);
+ abort ();
+ }
+
+ mpq_neg (a, a);
+ mpz_neg (b, b);
+ ccref = - ccref;
+ }
+ }
+ }
+ }
+
+ mpq_clear (a);
+ mpz_clear (b);
+}
+
int
main (int argc, char **argv)
{
@@ -64,6 +116,8 @@
for (i = 0; i < reps; i++)
{
+ if (i % 8192 == 0)
+ sizes_test (urandom () % (i + 1) + 1);
size = urandom () % SIZE - SIZE/2;
mpz_random2 (NUM (a), size);
do
diff -r ab02d29d71d5 -r 250ef73fd806 tests/mpz/t-fac_ui.c
--- a/tests/mpz/t-fac_ui.c Thu Sep 03 20:17:15 2015 +0200
+++ b/tests/mpz/t-fac_ui.c Thu Sep 03 21:41:39 2015 +0200
@@ -1,6 +1,6 @@
/* Exercise mpz_fac_ui and mpz_2fac_ui.
-Copyright 2000-2002, 2012 Free Software Foundation, Inc.
+Copyright 2000-2002, 2012, 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
More information about the gmp-commit
mailing list