This is an automated email from the git hooks/post-receive script. ppm-guest pushed a commit to annotated tag v0.36 in repository libmath-prime-util-perl.
commit c6a03f46645ddcc20af739f43d40b79445edf4d5 Author: Dana Jacobsen <d...@acm.org> Date: Thu Jan 9 15:02:58 2014 -0800 Use new clz/ctz/log2floor --- aks.c | 8 +------- factor.c | 9 ++------- util.c | 8 +++----- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/aks.c b/aks.c index 2201e76..5ab49f5 100644 --- a/aks.c +++ b/aks.c @@ -27,17 +27,11 @@ #include "ptypes.h" #include "aks.h" #define FUNC_isqrt 1 +#define FUNC_log2floor 1 #include "util.h" #include "cache.h" #include "mulmod.h" -static UV log2floor(UV n) { - UV log2n = 0; - while (n >>= 1) - log2n++; - return log2n; -} - /* Bach and Sorenson (1993) would be better */ static int is_perfect_power(UV n) { UV b, last; diff --git a/factor.c b/factor.c index d679550..bbb8931 100644 --- a/factor.c +++ b/factor.c @@ -12,6 +12,7 @@ #define FUNC_isqrt 1 #define FUNC_gcd_ui 1 #define FUNC_is_perfect_square 1 +#define FUNC_clz 1 #include "util.h" /* factor will do trial division through this prime number, must be in table */ @@ -677,13 +678,7 @@ static void pp1_pow(UV *cX, unsigned long exp, UV n) UV X0 = *cX; UV X = *cX; UV Y = mulsubmod(X, X, 2, n); - unsigned long bit; - { - unsigned long v = exp; - unsigned long b = 1; - while (v >>= 1) b++; - bit = 1UL << (b-2); - } + unsigned long bit = 1UL << (clz(exp)-1); while (bit) { UV T = mulsubmod(X, Y, X0, n); if ( exp & bit ) { diff --git a/util.c b/util.c index ab7291c..8d555c9 100644 --- a/util.c +++ b/util.c @@ -65,6 +65,7 @@ #include "ptypes.h" #define FUNC_isqrt 1 #define FUNC_lcm_ui 1 +#define FUNC_ctz 1 #include "util.h" #include "sieve.h" #include "primality.h" @@ -888,11 +889,8 @@ IV mertens(UV n) { } -static int padic2(UV n) { /* How many times does 2 divide n? */ - UV p = 0; - while (n && n % 2 == 0) { n >>= 1; p++; } - return p; -} +/* How many times does 2 divide n? */ +#define padic2(n) ctz(n) #define IS_MOD8_3OR5(x) (((x)&7)==3 || ((x)&7)==5) static int kronecker_uu_sign(UV a, UV b, int s) { -- 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