[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Forwarded patch for modular exponentiation support (GMP powm)
From: |
Kevin Ryde |
Subject: |
Re: Forwarded patch for modular exponentiation support (GMP powm) |
Date: |
Wed, 11 Feb 2004 11:02:45 +1000 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) |
Eric Hanchrow <address@hidden> writes:
>
> See if the attached patch has attained sufficient grooviness.
Please direct all guile devel matters to the guile-devel list, not to
me. If you're having trouble posting directly you might be able to go
through the gmane.org mail<->news gateway.
> And by
> the way: does the function `coerce_to_big' bother you? It bothers me,
> because it seems necessary to me, and yet there isn't anything like it
> already. That makes me wonder why I feel it's necessary, whereas
> everyone else got along fine without it; I figure I'm overlooking
> something.
Usually an inum is handled by separate code and one of the gmp "_ui"
functions. And an inline mpz_t temporary when there's no _ui
function.
> + /* if the exponent K is negative, and we simply call mpz_powm, we
> + might well get a divide-by-zero exception.
... when an inverse 1/n mod m doesn't exist (or is not unique) ...
> Since those are hard
> + to handle, we'll do the inversion ourselves -- because that way
> + we get a simple failure code, which is easy to handle. */
> +
> + if (-1 == mpz_sgn(k_tmp))
> + {
> + needs_inverting = 1;
You can do the inversion before the powm call, ie. call it with 1/n
and abs(k). Might be a touch simpler.
> + mpz_powm (SCM_I_BIG_MPZ (result),
> + n_tmp,
> + k_tmp,
> + m_tmp);
You can use the result destination for one of the temporaries, to save
an mpz_init, if it doesn't get too messy.
- Re: Forwarded patch for modular exponentiation support (GMP powm), Kevin Ryde, 2004/02/09
- Re: Forwarded patch for modular exponentiation support (GMP powm), Kevin Ryde, 2004/02/09
- Message not available
- Re: Forwarded patch for modular exponentiation support (GMP powm),
Kevin Ryde <=
- Re: Forwarded patch for modular exponentiation support (GMP powm), Eric Hanchrow, 2004/02/11
- Re: Forwarded patch for modular exponentiation support (GMP powm), Kevin Ryde, 2004/02/11
- Re: Forwarded patch for modular exponentiation support (GMP powm), Eric Hanchrow, 2004/02/11
- Re: Forwarded patch for modular exponentiation support (GMP powm), Kevin Ryde, 2004/02/13
- Re: Forwarded patch for modular exponentiation support (GMP powm), Eric Hanchrow, 2004/02/14
- Re: Forwarded patch for modular exponentiation support (GMP powm), Kevin Ryde, 2004/02/15