Would someone mind elaborating the explanation in the manual?

Sisyphus kalinabears at iinet.net.au
Sun Oct 26 10:13:10 CET 2003


Brian Hurt wrote:

> 
> This is a speed up because compared to doing a long mod long, doing a 
> mpz_t mod long is expensive.  The above code is almost 3x as fast as the 
> naive implementation:
> 
> int foo(mpz_t x) {
>     if ((mpz_fdiv_ui(x, 23ul) == 0ul) || (mpz_fdiv_ui(x, 29ul) == 0ul)
>         || (mpz_fdiv_ui(x, 31ul) == 0ul)) 
>     {
>         return 1;
>     } else {
>         return 0;
>     }
> }
> 

But if you wanted to see if x was divisible by either 23, 29, or 32 I 
think you would use mpz_divisible_ui() instead ?

I don't know how the speeds compare in that case.

Cheers,
Rob


-- 
Any emails containing attachments will be deleted from my ISP's mail 
server before I even get to see them. If you wish to email me an 
attachment, please provide advance warning so that I can make the 
necessary arrangements.



More information about the gmp-discuss mailing list