two possible coding porjects

Karl Hasselström
Mon, 4 Aug 2003 19:59:08 +0200

Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2003-08-03 19:36:25 -0500, wrote:

> So, given that the gmp homepage lists as a future feature - New
> user-visible mod and division routines for invariant divisors.
> comma, what is the plan for these routines? I have an algorithm that
> does one heck of a lot of GCD and mod against a very large invariant
> divisor.

For mpz, the plan is to have something like this (in addition to the
old API, of course):

    mpz_t a, b, q;
    mpz_cool_new_preinversion_type_t inv_a;
    mpz_preinv_divisor (inv_a, a, 4711);
    for (i =3D 0; i < 4711; i++)
        mpz_div_preinv (q, b, a, inv_a); /* q =3D b/a */

That is, you call a function that may or may not preinvert your
divisor depending on how big it is, how many operations you'll do,
etc. and then you call a division function that makes use of that
inverse if it was indeed computed. (If the inversion function decided
that preinversion wasn't worth the trouble, inv_a would effectively be
a null pointer, but as an mpz user you don't have to care. The penalty
of trying and failing to get a preinverse, as oppsoed to using the old
division functions, should be negligible, so there'll be no reason not
to use these new functions whenever you'll divide by the same number
two or more times (well, that's the plan anyway :-).)

mpn functions will have to manage their preinverted inverses
themselves, though of course there'll be a clean and stable API there

Karl Hasselstr=F6m,

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.2 (GNU/Linux)