[Gmp-commit] /var/hg/gmp: 4 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Wed Jan 2 04:04:35 CET 2013
details: /var/hg/gmp/rev/6c0b0e280c60
changeset: 15227:6c0b0e280c60
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Jan 02 03:57:16 2013 +0100
description:
tests/mpz/bit.c: Wider testing for mpz_combit.
details: /var/hg/gmp/rev/b7be4fc48f74
changeset: 15228:b7be4fc48f74
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Jan 02 03:57:41 2013 +0100
description:
tests/mpz/logic.c: Check the -2^n case.
details: /var/hg/gmp/rev/fd831dd28d11
changeset: 15229:fd831dd28d11
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Jan 02 03:58:12 2013 +0100
description:
mpz/ior.c: Fixed an allocation bug in the -2^n case.
details: /var/hg/gmp/rev/b6bb9ca37ae0
changeset: 15230:b6bb9ca37ae0
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Jan 02 04:04:07 2013 +0100
description:
Changelog
diffstat:
ChangeLog | 7 +++++++
mpz/ior.c | 2 +-
tests/mpz/bit.c | 18 ++++++++++++++----
tests/mpz/logic.c | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 5 deletions(-)
diffs (125 lines):
diff -r eb121660202e -r b6bb9ca37ae0 ChangeLog
--- a/ChangeLog Mon Dec 31 01:02:22 2012 +0100
+++ b/ChangeLog Wed Jan 02 04:04:07 2013 +0100
@@ -1,3 +1,10 @@
+2013-01-02 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * tests/mpz/bit.c: Wider testing for mpz_combit.
+ * tests/mpz/logic.c: Check the -2^n case.
+
+ * mpz/ior.c: Fixed an allocation bug in the -2^n case.
+
2012-12-31 Torbjorn Granlund <tege at gmplib.org>
* mpn/generic/get_d.c: Minor reorg, add vax D code.
diff -r eb121660202e -r b6bb9ca37ae0 mpz/ior.c
--- a/mpz/ior.c Mon Dec 31 01:02:22 2012 +0100
+++ b/mpz/ior.c Wed Jan 02 04:04:07 2013 +0100
@@ -120,7 +120,7 @@
if (res_size != 0)
{
- res_ptr = MPZ_REALLOC (res, res_size);
+ res_ptr = MPZ_REALLOC (res, res_size + 1);
/* Second loop computes the real result. */
mpn_and_n (res_ptr, op1_ptr, op2_ptr, res_size);
diff -r eb121660202e -r b6bb9ca37ae0 tests/mpz/bit.c
--- a/tests/mpz/bit.c Mon Dec 31 01:02:22 2012 +0100
+++ b/tests/mpz/bit.c Wed Jan 02 04:04:07 2013 +0100
@@ -226,7 +226,7 @@
{
for (offset = (limb==0 ? 0 : -2); offset <= 2; offset++)
{
- for (initial = 0; initial >= -1; initial--)
+ for (initial = 1; initial >= -1; initial--)
{
mpz_set_si (x, (long) initial);
@@ -318,7 +318,7 @@
mpz_set (s2, x);
bit2 = mpz_tstbit (x, bitindex);
- mpz_setbit (x, bitindex);
+ mpz_combit (x, bitindex);
MPZ_CHECK_FORMAT (x);
mpz_set (s3, x);
@@ -346,16 +346,26 @@
if (mpz_cmp (s2, s3) == 0)
abort ();
+ mpz_combit (x, bitindex);
+ MPZ_CHECK_FORMAT (x);
+ if (mpz_cmp (s2, x) != 0)
+ abort ();
+
+ mpz_clrbit (x, bitindex);
+ MPZ_CHECK_FORMAT (x);
+ if (mpz_cmp (s2, x) != 0)
+ abort ();
+
mpz_ui_pow_ui (m, 2L, bitindex);
MPZ_CHECK_FORMAT (m);
- mpz_ior (x, s2, m);
+ mpz_ior (x, s0, m);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (x, s3) != 0)
abort ();
mpz_com (m, m);
MPZ_CHECK_FORMAT (m);
- mpz_and (x, s1, m);
+ mpz_and (x, s0, m);
MPZ_CHECK_FORMAT (x);
if (mpz_cmp (x, s2) != 0)
abort ();
diff -r eb121660202e -r b6bb9ca37ae0 tests/mpz/logic.c
--- a/tests/mpz/logic.c Mon Dec 31 01:02:22 2012 +0100
+++ b/tests/mpz/logic.c Wed Jan 02 04:04:07 2013 +0100
@@ -55,6 +55,45 @@
mpz_init (t2);
mpz_init (t3);
+ mpz_set_si (x, -1);
+ mpz_set_ui (y, 0);
+ for (i = 0; i < 300; i++)
+ {
+ mpz_mul_2exp (x, x, 1);
+
+ mpz_and (r1, x, x);
+ MPZ_CHECK_FORMAT (r1);
+ if (mpz_cmp (r1, x) != 0)
+ dump_abort ();
+
+ mpz_ior (r2, x, x);
+ MPZ_CHECK_FORMAT (r2);
+ if (mpz_cmp (r2, x) != 0)
+ dump_abort ();
+
+ mpz_xor (t1, x, x);
+ MPZ_CHECK_FORMAT (t1);
+ if (mpz_cmp_si (t1, 0) != 0)
+ dump_abort ();
+
+ mpz_ior (t1, x, y);
+ MPZ_CHECK_FORMAT (t1);
+ if (mpz_cmp (t1, x) != 0)
+ dump_abort ();
+
+ mpz_xor (t2, x, y);
+ MPZ_CHECK_FORMAT (t2);
+ if (mpz_cmp (t2, x) != 0)
+ dump_abort ();
+
+ mpz_com (t2, x);
+ MPZ_CHECK_FORMAT (t2);
+ mpz_xor (t3, t2, x);
+ MPZ_CHECK_FORMAT (t3);
+ if (mpz_cmp_si (t3, -1) != 0)
+ dump_abort ();
+ }
+
for (i = 0; i < reps; i++)
{
mpz_urandomb (bs, rands, 32);
More information about the gmp-commit
mailing list