[libmath-prime-util-perl] 09/14: Speed up rsqufof a little, use for 19 dig semiprimes

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


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

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

commit 4229dfeacfea3065b2f7d89e185268ee9f55e8cf
Author: Dana Jacobsen <dana at acm.org>
Date:   Sun Mar 17 01:08:42 2013 -0700

    Speed up rsqufof a little, use for 19 dig semiprimes
---
 TODO     |  5 -----
 factor.c | 11 ++++++-----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/TODO b/TODO
index b0be486..87284ba 100644
--- a/TODO
+++ b/TODO
@@ -11,9 +11,6 @@
 
 - Is the current PP.pm setup the way we want to do it?
 
-- Faster SQUFOF.  We're using the faster racing SQUFOF now, but it could still
-  use some tuning.
-
 - Move .c / .h files into separate directory.
   version does it in a painful way.  Something simpler to be had?
 
@@ -34,8 +31,6 @@
 
 - More efficient Mertens.  The current version has poor growth.
 
-- Keep speeding up factoring for very large values.
-
 - More efficient totient segment.  Do we really need primes to n/2?
 
 - Implement S2 calculation for LMO prime count.
diff --git a/factor.c b/factor.c
index 44f36bd..db91e4c 100644
--- a/factor.c
+++ b/factor.c
@@ -55,7 +55,7 @@ int factor(UV n, UV *factors)
         if (verbose) { if (split_success) printf("pbrent 1:  %"UVuf" %"UVuf"\n", tofac_stack[ntofac], tofac_stack[ntofac+1]); else printf("pbrent 0\n"); }
       }
       /* SQUFOF with these parameters gets 99.9% of everything left */
-      if (!split_success && n < (UV_MAX>>3)) {
+      if (!split_success && n < (UV_MAX>>2)) {
         split_success = racing_squfof_factor(n,tofac_stack+ntofac, sq_rounds)-1;
         if (verbose) printf("rsqufof %d\n", split_success);
       }
@@ -223,7 +223,7 @@ int trial_factor(UV n, UV *factors, UV maxtrial)
  *
  * Some simple solutions:
  *
- *     return ( ((m&2)!= 0) || ((m&7)==5) || ((m&11) == 8) )  ?  0  :  1;
+ *     return ( ((n&2)!= 0) || ((n&7)==5) || ((n&11) == 8) )  ?  0  :  1;
  *
  * or:
  *
@@ -244,7 +244,7 @@ int trial_factor(UV n, UV *factors, UV maxtrial)
  */
 static int is_perfect_square(UV n, UV* sqrtn)
 {
-  UV m;  /* lm */
+  UV m;
   m = n & 127;
   if ((m*0x8bc40d7d) & (m*0xa1e2f5d1) & 0x14020a)  return 0;
   /* 82% of non-squares rejected here */
@@ -273,8 +273,9 @@ static int is_perfect_square(UV n, UV* sqrtn)
   m = lm % 11;
   if ((m*0xabf1a3a7) & (m*0x2612bf93) & 0x45854000) return 0;
   /* 99.92% of non-squares are rejected now */
-#else
-  /* It may be faster to skip these */
+#endif
+#if 0
+  /* This could save time on some platforms, but not on x86 */
   m = n % 63;
   if ((m*0x3d491df7) & (m*0xc824a9f9) & 0x10f14008) return 0;
 #endif

-- 
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