query: nearest integer divide
Torbjorn Granlund
tege@swox.com
24 Mar 2003 11:59:21 +0100
[Let's try again. Last reply had some typos that made it hard to
understand.]
keith.briggs@bt.com writes:
1. mpz_ui_pow_ui(temp,2,p-1);
mpz_add(y,x,temp);
mpz_tdiv_q_2exp(y,y,p);
It would save a lot of time to perform that mpz_ui_pow_ui with
mpz_mul_2exp instead. That would bring time down from O(M(2^p)) to
O(2^p), where M(n) is the time for multiplying two n-bit numbers.
(If your x is computed for the sole purpose of getting this
nearest integer, you might be able to save a great amount of time
by not computing the full precision of x, and instead just some
upper part of it.)
--
Torbjörn