[libmath-prime-util-perl] 12/29: Small speedup for composites in is_prob_prime/is_prime

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:48:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.27
in repository libmath-prime-util-perl.

commit 7cb7982530656366a82db02d69c7c559624d8b0a
Author: Dana Jacobsen <dana at acm.org>
Date:   Tue May 14 12:48:37 2013 -0700

    Small speedup for composites in is_prob_prime/is_prime
---
 factor.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/factor.c b/factor.c
index 6d0962a..fd1a40f 100644
--- a/factor.c
+++ b/factor.c
@@ -345,12 +345,12 @@ int _XS_is_prob_prime(UV n)
   int nbases;
   int prob_prime;
 
-  if ( (n == 2) || (n == 3) || (n == 5) || (n == 7) )
-    return 2;
-  if ( (n<2) || ((n% 2)==0) || ((n% 3)==0) || ((n% 5)==0) || ((n% 7)==0) )
-    return 0;
-  if (n < 121)
-    return 2;
+  if (n == 2 || n == 3 || n == 5)           return 2;
+  if (n < 2 || !(n%2) || !(n%3) || !(n%5))  return 0;
+  if (n <   49) /* 7*7 */                   return 2;
+  if (!(n% 7) || !(n%11) || !(n%13) || !(n%17) || !(n%19) || !(n%23)) return 0;
+  if (!(n%29) || !(n%31) || !(n%37) || !(n%41) || !(n%43) || !(n%47)) return 0;
+  if (n < 2809) /* 53*53 */                 return 2;
 
 #if BITS_PER_WORD == 32
   if (n < UVCONST(9080191)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list