[Gmp-commit] /home/hgfiles/gmp: Require odd and positive argument to refmpz_j...
mercurial at gmplib.org
mercurial at gmplib.org
Thu Feb 25 20:53:31 CET 2010
details: /home/hgfiles/gmp/rev/3ef83d7fa64f
changeset: 13447:3ef83d7fa64f
user: Niels M?ller <nisse at lysator.liu.se>
date: Thu Feb 25 20:53:26 2010 +0100
description:
Require odd and positive argument to refmpz_jacobi.
diffstat:
ChangeLog | 5 +++++
tests/devel/try.c | 18 ++++++++++++------
tests/refmpz.c | 9 ++++-----
3 files changed, 21 insertions(+), 11 deletions(-)
diffs (77 lines):
diff -r 31be64b87c70 -r 3ef83d7fa64f ChangeLog
--- a/ChangeLog Thu Feb 25 19:26:01 2010 +0100
+++ b/ChangeLog Thu Feb 25 20:53:26 2010 +0100
@@ -1,5 +1,10 @@
2010-02-25 Niels Möller <nisse at lysator.liu.se>
+ * tests/devel/try.c (param_init, call): Don't pass negative values
+ for the second argument to mpz_jacobi and refmpz_jacobi.
+
+ * tests/refmpz.c (refmpz_jacobi): Require that b is odd and positive.
+
* tests/devel/try.c (param_init): Support mpz_legendre.
(choice_array): Added mpz_kronecker (apparently forgotten) and
mpz_legendre.
diff -r 31be64b87c70 -r 3ef83d7fa64f tests/devel/try.c
--- a/tests/devel/try.c Thu Feb 25 19:26:01 2010 +0100
+++ b/tests/devel/try.c Thu Feb 25 20:53:26 2010 +0100
@@ -1072,13 +1072,19 @@
p->src[1] = 1;
p->data = DATA_SRC1_ODD;
p->size2 = 1;
+ p->carry = CARRY_BIT;
+ p->carry_sign = 1;
+ REFERENCE (refmpz_jacobi);
+
+ p = ¶m[TYPE_MPZ_KRONECKER];
+ p->retval = 1;
+ p->src[0] = 1;
+ p->size = SIZE_ALLOW_ZERO;
+ p->src[1] = 1;
+ p->data = 0;
+ p->size2 = 1;
p->carry = CARRY_4;
p->carry_sign = 1;
- REFERENCE (refmpz_jacobi);
-
- p = ¶m[TYPE_MPZ_KRONECKER];
- COPY (TYPE_MPZ_JACOBI);
- p->data = 0; /* clear inherited DATA_SRC1_ODD */
REFERENCE (refmpz_kronecker);
@@ -2275,6 +2281,7 @@
break;
case TYPE_MPZ_LEGENDRE:
+ case TYPE_MPZ_JACOBI:
{
mpz_t a, b;
PTR(a) = e->s[0].p; SIZ(a) = (carry==0 ? size : -size);
@@ -2282,7 +2289,6 @@
e->retval = CALLING_CONVENTIONS (function) (a, b);
}
break;
- case TYPE_MPZ_JACOBI:
case TYPE_MPZ_KRONECKER:
{
mpz_t a, b;
diff -r 31be64b87c70 -r 3ef83d7fa64f tests/refmpz.c
--- a/tests/refmpz.c Thu Feb 25 19:26:01 2010 +0100
+++ b/tests/refmpz.c Thu Feb 25 20:53:26 2010 +0100
@@ -184,11 +184,10 @@
int
refmpz_jacobi (mpz_srcptr a, mpz_srcptr b)
{
- mpz_t b_odd;
- mpz_init_set (b_odd, b);
- if (mpz_sgn (b_odd) != 0)
- mpz_fdiv_q_2exp (b_odd, b_odd, mpz_scan1 (b_odd, 0L));
- return refmpz_kronecker (a, b_odd);
+ ASSERT_ALWAYS (mpz_sgn (b) > 0);
+ ASSERT_ALWAYS (mpz_odd_p (b));
+
+ return refmpz_kronecker (a, b);
}
/* Legendre symbol via powm. p must be an odd prime. */
More information about the gmp-commit
mailing list