primorial(negative)

Marco Bodrato bodrato at mail.dm.unipi.it
Thu Nov 12 07:56:43 UTC 2015


Ciao,

Il Mar, 10 Novembre 2015 7:39 am, Marc Glisse ha scritto:
> 2) (probably more from the C side) The last time I wanted primorial(n), I
> also wanted the corresponding list of primes. Using mpz_nextprime is not
> the same thing, and since primorial already computes the list anyway, I
> don't really feel like re-implementing a sieve...

Currently, primorial uses a sieve, that stores a bit-array. Then it
computes an array of factors (not primes, but products of primes fitting
into a limb), and finally it computes the product (overwriting the
bit-array in the process).
With a strict meaning, it never stores the "list of primes".

Of course we might give a public interface to the process
sieve-up-to-given-limit and then loop-on-sieved-primes.
Not easy, because currently the sieving process is implemented by a
function, but the looping phase is handled by specialised macros...
Moreover we may need a new opaque type gmp_primesieve_t... and which type
should we use for those primes? unsigned long? mp_limb_t (the type
currently used internally)? mpz_t?

Suggestions for the interface?

Regards,
m
-- 
http://bodrato.it/



More information about the gmp-discuss mailing list