[libmath-prime-util-perl] 06/33: Adjust factor recipe, 3-5% faster for large inputs.

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


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

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

commit a17fe6b2c4a897a52ad15802e9d676f5eecc8f16
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Jan 17 16:11:41 2014 -0800

    Adjust factor recipe, 3-5% faster for large inputs.
---
 factor.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/factor.c b/factor.c
index 690e3f6..32ac323 100644
--- a/factor.c
+++ b/factor.c
@@ -93,7 +93,7 @@ int factor(UV n, UV *factors)
     while ( (n >= f*f) && (!_XS_is_prime(n)) ) {
       int split_success = 0;
       /* Adjust the number of rounds based on the number size */
-      UV const br_rounds = ((n>>29) < 100000) ?  1500 :  2000;
+      UV const br_rounds = ((n>>29) < 100000) ?  1500 :  4000;
       UV const sq_rounds =100000; /* 20k 91%, 40k 98%, 80k 99.9%, 120k 99.99% */
 
       /* 99.7% of 32-bit, 94% of 64-bit random inputs factored here */
@@ -107,21 +107,18 @@ int factor(UV n, UV *factors)
         if (verbose) printf("squfof %d\n", split_success);
       }
       /* At this point we should only have 16+ digit semiprimes. */
-      /* This p-1 gets about 2/3 of what makes it through the above */
       if (!split_success) {
-        split_success = pminus1_factor(n, tofac_stack+ntofac, 5000, 100000)-1;
+        split_success = pminus1_factor(n, tofac_stack+ntofac, 8000, 120000)-1;
         if (verbose) printf("pminus1 %d\n", split_success);
-      }
-      /* Some rounds of HOLF, good for close to perfect squares which are
-       * the worst case for the next step */
-      if (!split_success) {
-        split_success = holf_factor(n, tofac_stack+ntofac, 2000)-1;
-        if (verbose) printf("holf %d\n", split_success);
-      }
-      /* The catch-all.  Should factor anything. */
-      if (!split_success) {
-        split_success = prho_factor(n, tofac_stack+ntofac, 256*1024)-1;
-        if (verbose) printf("long prho %d\n", split_success);
+        /* Get the stragglers */
+        if (!split_success) {
+          split_success = prho_factor(n, tofac_stack+ntofac, 120000)-1;
+          if (verbose) printf("long prho %d\n", split_success);
+          if (!split_success) {
+            split_success = pbrent_factor(n, tofac_stack+ntofac, 500000, 7)-1;
+            if (verbose) printf("long pbrent %d\n", split_success);
+          }
+        }
       }
 
       if (split_success) {

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