Exact division

Niels Möller nisse at lysator.liu.se
Thu Dec 10 15:19:18 CET 2009

Torbjorn Granlund <tg at gmplib.org> writes:

> I suggest that we do something like this in generic/divexact.c:
> #if 1
> Code from generic/gcdext.c:divexact
> #else
> Existing generic/dvexact.c code
> #endif

Should be easy enough. The code from gcdext.c doesn't have an
itch/scratch interface. I could add a dummy scratch parameter, but maybe
it's no problem to eliminate that argument from the interface, and
reintroduce it later, whenever the bidirectional code is enabled?

(There are also some other interface questions for this function, like
whether or not it should be allowed to destroy n (like the low-level
division functions), and whether or not qp = np should be allowed).

> Then we could make mpz_divexact call mpn_divexact for a nice performance
> boost.

Other potential users are mpz_gcdext, and whatever function it is in mpq
which is responsible for normalization of fractions.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list