diff --git a/doc/gmp.texi b/doc/gmp.texi index 60c2634..bebd82e 100644 --- a/doc/gmp.texi +++ b/doc/gmp.texi @@ -3548,12 +3548,17 @@ Determine whether @var{n} is prime. Return 2 if @var{n} is definitely prime, return 1 if @var{n} is probably prime (without being certain), or return 0 if @var{n} is definitely non-prime. -This function performs some trial divisions, then @var{reps} Miller-Rabin -probabilistic primality tests. A higher @var{reps} value will reduce the -chances of a non-prime being identified as ``probably prime''. A composite -number will be identified as a prime with a probability of less than -@m{4^{-reps},4^(-@var{reps})}. Reasonable values of @var{reps} are between 15 -and 50. +This function performs some trial divisions, a Baillie–PSW probable prime +test, then @var{reps-24} Miller-Rabin probabilistic primality tests. A +higher @var{reps} value will reduce the chances of a non-prime being +identified as ``probably prime''. A composite number will be identified as a +prime with a probability of less than @m{4^{-reps},4^(-@var{reps})}. +Reasonable values of @var{reps} are between 15 and 50. + +GMP versions up to and including 6.1.2 did not use the Baillie-PSW +primality test. In those older versions of GMP, this function performed +@var{reps} Miller-Rabin tests. + @end deftypefun @deftypefun void mpz_nextprime (mpz_t @var{rop}, const mpz_t @var{op}) diff --git a/mpz/millerrabin.c b/mpz/millerrabin.c index 2d06fe4..41121dd 100644 --- a/mpz/millerrabin.c +++ b/mpz/millerrabin.c @@ -1,9 +1,10 @@ -/* mpz_millerrabin(n,reps) -- An implementation of the probabilistic primality - test found in Knuth's Seminumerical Algorithms book. If the function - mpz_millerrabin() returns 0 then n is not prime. If it returns 1, then n is - 'probably' prime. The probability of a false positive is (1/4)**reps, where - reps is the number of internal passes of the probabilistic algorithm. Knuth - indicates that 25 passes are reasonable. +/* mpz_millerrabin(n,reps) -- + An implementation of the probabilistic primality test found in Knuth's + Seminumerical Algorithms book. If the function mpz_probab_prime_p() + returns 0 then n is not prime. If it returns 1, then n is 'probably' + prime. The probability of a false positive is (1/4)**reps, + where reps is the number of internal passes of the + probabilistic algorithm. Knuth indicates that 25 passes are reasonable. THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN