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

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

commit d605825e71a6eebe4d8661555dc90946deb89215
Author: Dana Jacobsen <d...@acm.org>
Date:   Thu May 1 17:17:25 2014 -0700

    Full trial divide of small factor inputs
---
 Changes  | 3 +++
 factor.c | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Changes b/Changes
index d0017d3..5b377b2 100644
--- a/Changes
+++ b/Changes
@@ -13,6 +13,9 @@ Revision history for Perl module Math::Prime::Util
       changes in the Montgomery math section -- an improvement to mont_prod64
       and using a new modular inverse from W. Izykowski based on Arazi (1994).
 
+    - factoring small inputs (n < 20M) is ~10% faster, which speeds up some
+      misc functions (e.g. euler_phi, divisor_sum) for small inputs.
+
     - Small improvement to twin_prime_count_approx and nth_twin_prime_approx.
 
     - Better AKS testing in xt/primality-aks.pl.
diff --git a/factor.c b/factor.c
index 29c3c7f..5e4c35a 100644
--- a/factor.c
+++ b/factor.c
@@ -16,9 +16,6 @@
 #define FUNC_clz 1
 #include "util.h"
 
-/* factor will do trial division through this prime index, must be in table */
-#define TRIAL_TO_PRIME 84
-
 /*
  * You need to remember to use UV for unsigned and IV for signed types that
  * are large enough to hold our data.
@@ -67,7 +64,8 @@ int factor(UV n, UV *factors)
 
     if (f*f <= n) {
       UV sp = 3;
-      while (++sp < TRIAL_TO_PRIME) {
+      UV const lastsp = (n < 20000000)  ?  NPRIMES_SMALL-1  :  83;
+      while (++sp < lastsp) {
         f = primes_small[sp];
         if (f*f > n) break;
         while ( (n%f) == 0 ) {

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to