Trial-division interface

Niels Möller nisse at lysator.liu.se
Fri Apr 9 15:04:45 CEST 2010


Torbjorn Granlund <tg at gmplib.org> writes:

> *If* we are going to return it *somehow*, then it is better to make it
> the function return value instead if having it go thought an unsigned
> int pointer.

Do you agree that computing the factor should be optional? (If it should
be computed always, then the interface can be simplified a bit). If you
still want to put it in the return value when it is desired, then I
guess you'd prefer something like

  unsigned long
  mpz_trial_div(const mpz_t n, unsigned long prime_bound,
                int I_really_want_to_know_the_factor);

where the final flag value says if a truth value is good enough or if the
caller wants the actual factor. Or simply two separate functions?

> I was talking about the static size table, not a growable table, i.e. a
> table that might be compiled and stored as part of libgmp.{a,so}.

I see.

> Managing growable prime tables in a thread-safe way without locks is
> probably doable, but I haven't thought about it.

I guess one can do the general read-copy-update thing (assuming only
that you can overwrite a pointer variable atomically). Then, if I
understand it correctly, the difficult part is going to be the decision
on when to deallocate the older short version of the table.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list