diff options
author | tege <tege@gmplib.org> | 2006-04-27 18:30:32 +0200 |
---|---|---|
committer | tege <tege@gmplib.org> | 2006-04-27 18:30:32 +0200 |
commit | 2a819fcaac8485a4abb9d9a4148ec610b79ce879 (patch) | |
tree | 4fc8d1392978e26f8d80d6be84528026494624cf /mpz | |
parent | 9506fbe71529e1b9a61b3f443f0629e4d08e8b81 (diff) | |
download | gmp-2a819fcaac8485a4abb9d9a4148ec610b79ce879.tar.gz |
Call mpz_tdiv_q for large operands.
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/divexact.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mpz/divexact.c b/mpz/divexact.c index 6ef3a6725..baf524faf 100644 --- a/mpz/divexact.c +++ b/mpz/divexact.c @@ -1,7 +1,7 @@ /* mpz_divexact -- finds quotient when known that quot * den == num && den != 0. -Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2005 Free -Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006 +Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -87,6 +87,13 @@ mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den) DIVIDE_BY_ZERO; } + /* Avoid quadratic behaviour, but do it conservatively. */ + if (qsize > 1500) + { + mpz_tdiv_q (quot, num, den); + return; + } + TMP_MARK; /* QUOT <-- NUM/2^r, T <-- DEN/2^r where = r number of twos in DEN. */ |