diff options
author | tege <tege@gmplib.org> | 1997-07-25 19:14:17 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 1997-07-25 19:14:17 +0200 |
commit | 419364d49f82f767e38bd5fa91c6cbd5ef0107ef (patch) | |
tree | 6d0dfb0cf88f1d8808b23b486cf6e84db7a77ff8 /mpz/gcdext.c | |
parent | ba13f2a5cacee76ceb83fa7a03ee93fb59e519cd (diff) | |
download | gmp-419364d49f82f767e38bd5fa91c6cbd5ef0107ef.tar.gz |
Get cofactor sign right for negative input operands.
Clean up code for computing tt.
Diffstat (limited to 'mpz/gcdext.c')
-rw-r--r-- | mpz/gcdext.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mpz/gcdext.c b/mpz/gcdext.c index 8b600a0f3..9c032b617 100644 --- a/mpz/gcdext.c +++ b/mpz/gcdext.c @@ -1,7 +1,7 @@ /* mpz_gcdext(g, s, t, a, b) -- Set G to gcd(a, b), and S and T such that g = as + bt. -Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -114,19 +114,20 @@ mpz_gcdext (g, s, t, a, b) } sp = PTR (ss); MPN_COPY (sp, tmp_sp, ssize); - SIZ (ss) = tmp_ssize >= 0 ? ssize : -ssize; + SIZ (ss) = (tmp_ssize ^ SIZ (u)) >= 0 ? ssize : -ssize; if (tt != NULL) { - mpz_t x; - MPZ_TMP_INIT (x, ssize + usize + 1); - - mpz_mul (x, ss, u); - mpz_sub (x, g, x); if (SIZ (v) == 0) SIZ (tt) = 0; else - mpz_tdiv_q (tt, x, v); + { + mpz_t x; + MPZ_TMP_INIT (x, ssize + usize + 1); + mpz_mul (x, ss, u); + mpz_sub (x, g, x); + mpz_tdiv_q (tt, x, v); + } } TMP_FREE (marker); |