[Gmp-commit] /var/hg/gmp: 3 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sat Jan 19 18:36:36 CET 2013
details: /var/hg/gmp/rev/a39b2455dc68
changeset: 15316:a39b2455dc68
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Jan 19 18:34:02 2013 +0100
description:
tests/mpz/t-remove.c: Test removal of 1.
details: /var/hg/gmp/rev/5d384c31d2b3
changeset: 15317:5d384c31d2b3
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Jan 19 18:34:16 2013 +0100
description:
ChangeLog
details: /var/hg/gmp/rev/c0fe7a57fa7d
changeset: 15318:c0fe7a57fa7d
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Sat Jan 19 18:35:42 2013 +0100
description:
Copyright year
diffstat:
ChangeLog | 2 ++
tests/mpz/t-remove.c | 48 +++++++++++++++++++++++++++++-------------------
2 files changed, 31 insertions(+), 19 deletions(-)
diffs (89 lines):
diff -r 40d2d0a50e2a -r c0fe7a57fa7d ChangeLog
--- a/ChangeLog Sat Jan 19 11:12:40 2013 +0100
+++ b/ChangeLog Sat Jan 19 18:35:42 2013 +0100
@@ -10,6 +10,8 @@
* tests/mpz/t-set_str.c: Check also failing conditions.
+ * tests/mpz/t-remove.c: Test removal of 1.
+
2013-01-18 Niels Möller <nisse at lysator.liu.se>
* mini-gmp/tests/t-str.c (test_small): New function, exercising
diff -r 40d2d0a50e2a -r c0fe7a57fa7d tests/mpz/t-remove.c
--- a/tests/mpz/t-remove.c Sat Jan 19 11:12:40 2013 +0100
+++ b/tests/mpz/t-remove.c Sat Jan 19 18:35:42 2013 +0100
@@ -1,7 +1,7 @@
/* Test mpz_remove.
-Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2009, 2012 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2009, 2012, 2013
+Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
@@ -54,13 +54,16 @@
mpz_urandomb (bs, rands, 32);
size_range = mpz_get_ui (bs) % 17 + 2; /* 0..524288 bit operands */
- do
- {
- mpz_urandomb (bs, rands, size_range);
- divisor_size = mpz_get_ui (bs);
- mpz_rrandomb (divisor, rands, divisor_size);
- }
- while (mpz_cmp_ui (divisor, 1) <= 0);
+ if (i == 0)
+ mpz_set_ui (divisor, 1);
+ else
+ do
+ {
+ mpz_urandomb (bs, rands, size_range);
+ divisor_size = mpz_get_ui (bs);
+ mpz_rrandomb (divisor, rands, divisor_size);
+ }
+ while (mpz_cmp_ui (divisor, 1) <= 0);
mpz_urandomb (bs, rands, size_range);
dividend_size = mpz_get_ui (bs) + divisor_size;
@@ -99,22 +102,29 @@
mpz_refremove (mpz_t dest, const mpz_t src, const mpz_t f)
{
unsigned long int pwr;
- mpz_t rem, x;
- mpz_init (rem);
- mpz_init (x);
+ pwr = 0;
mpz_set (dest, src);
- for (pwr = 0;; pwr++)
+ if (mpz_cmpabs_ui (f, 1) > 0)
{
- mpz_tdiv_qr (x, rem, dest, f);
- if (mpz_cmp_ui (rem, 0) != 0)
- break;
- mpz_set (dest, x);
+ mpz_t rem, x;
+
+ mpz_init (x);
+ mpz_init (rem);
+
+ for (;; pwr++)
+ {
+ mpz_tdiv_qr (x, rem, dest, f);
+ if (mpz_cmp_ui (rem, 0) != 0)
+ break;
+ mpz_swap (dest, x);
+ }
+
+ mpz_clear (x);
+ mpz_clear (rem);
}
- mpz_clear (x);
- mpz_clear (rem);
return pwr;
}
More information about the gmp-commit
mailing list