Two 10-lines functions

Torbjorn Granlund tg at gmplib.org
Wed Jan 20 22:57:51 CET 2010


"gianrico.fini at terra.es" <gianrico.fini at terra.es> writes:

  Dear developers,
  
  I was challenged... the challenge was: write a 10-lines substitute for the 
  function mpn_mulmod_2expp1.

There is no function mpn_mulmod_2expp1 in any version of GMP.  (But an
early version of mpn_mulmod_bnm1 was called something like that.)

  It computes the product of xp and yp modulo 2^b+1. It assumes that xp and yp 
  have exactly b bits.

What does it mean that "xp has exactly b bits"?  That 2^(b-1) <= xp <
2^b?  It looks like your code does not handle any b value, or there
should be some shifting.

  This function is needed for a benchmark checking if some Fermat's numbers are 
  prime or not.

I'd suspect mpn_mul_fft might be directly applicable for that.  It has
existed in GMP since the dark ages...
  
I am not sure what do do with your contribution, and where it would fit
in.

-- 
Torbjörn


More information about the gmp-devel mailing list