Bill Allombert on Sun, 06 Oct 2024 15:41:35 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: is there a way to globally rely on ispseudoprime() for primality testing? |
On Thu, Oct 03, 2024 at 02:08:33PM -0400, Max Alekseyev wrote: > Thank you for the pointer to ispseudoprimepower. I was not able to locate > it with ??? > > ? ???isprimepower > isprimepower > > As for the global option, I do not have a particular instance to share. My > question is motivated by the *set-and-forget* approach - I do not want to > analyze for each function whether it uses isprime() is ispseudoprime(), but > just to specify my preference once and be sure that every function follows > it. It will allow, say, to run some preliminary code backboned > by ispseudoprime(), but then use the same code backboned by isprime() when > the primality certainty is important. > > For example, as far as I remember, nextprime() and prevprime() rely on > ispseudoprime(). However, following the logic with isprimepower() > / ispseudoprimepower() there should have been function nextpseudoprime() > and prevpseudoprime(). The function is called precprime() but your (an Ilya) point stands, it should have been named nextpseudoprime/precpseudoprime (and why not forprime/forpseudoprime). Before 2002, PARI has both functions isprime and ispseudoprime, but isprime did not actually do a proven primality test, just a stronger pseudoprimality test. Then Henri implemented the APR-CL primality proof, and we decided to have ispseudoprime use the stronger pseudoprimality test and isprime to use a proven test, which we hoped to be more in accordance with users expectationa. Unfortunately that slowed down a number of scripts that expected isprime to be fast. At this time, changing nextprime/precprime can cause more problems that it solves. Note that there is a default 'factor_proven' to have factor use isprime instead of ispseudoprime to validate factors. Maybe we could extend its effect. Cheers, Bill.