From: Kevin Ryde <user42@zip.com.au>
Cc: guile-devel@gnu.org
Subject: Re: Forwarded patch for modular exponentiation support (GMP powm)
Date: Wed, 11 Feb 2004 11:02:45 +1000 [thread overview]
Message-ID: <87hdxyctsa.fsf@zip.com.au> (raw)
In-Reply-To: <87llnah2hf.fsf@offby1.atm01.sea.blarg.net> (Eric Hanchrow's message of "Tue, 10 Feb 2004 16:41:16 -0800")
Eric Hanchrow <offby1@blarg.net> 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.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2004-02-11 1:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-28 17:22 Forwarded patch for modular exponentiation support (GMP powm) Rob Browning
2004-02-09 23:15 ` Kevin Ryde
2004-02-09 23:31 ` Kevin Ryde
[not found] ` <87llnah2hf.fsf@offby1.atm01.sea.blarg.net>
2004-02-11 1:02 ` Kevin Ryde [this message]
2004-02-11 7:00 ` Eric Hanchrow
2004-02-11 23:44 ` Kevin Ryde
2004-02-12 4:56 ` Eric Hanchrow
2004-02-14 0:23 ` Kevin Ryde
2004-02-15 0:04 ` Eric Hanchrow
2004-02-15 22:08 ` Kevin Ryde
2004-03-20 21:20 ` Marius Vollmer
2004-03-20 21:32 ` Kevin Ryde
2004-03-21 2:28 ` Marius Vollmer
2004-03-21 22:18 ` Kevin Ryde
2004-03-22 0:01 ` Eric Hanchrow
2004-03-22 0:37 ` Kevin Ryde
2004-03-25 0:02 ` Kevin Ryde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hdxyctsa.fsf@zip.com.au \
--to=user42@zip.com.au \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).