[libmath-prime-util-perl] 14/29: Remove dead code
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 b7d411ef41537832b4ade8890881784353103995
Author: Dana Jacobsen <dana at acm.org>
Date: Wed May 15 13:02:50 2013 -0700
Remove dead code
---
factor.c | 24 +-----------------------
factor.h | 3 +++
sieve.c | 1 +
sieve.h | 6 ++++--
util.c | 41 ++---------------------------------------
util.h | 1 -
6 files changed, 11 insertions(+), 65 deletions(-)
diff --git a/factor.c b/factor.c
index fd1a40f..4f2fc89 100644
--- a/factor.c
+++ b/factor.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <math.h>
+#define FUNC_gcd_ui
#include "ptypes.h"
#include "factor.h"
#include "util.h"
@@ -359,7 +360,6 @@ int _XS_is_prob_prime(UV n)
bases[0] = 2; bases[1] = 7; bases[2] = 61; nbases = 3;
}
#else
-#if 1
/* Better bases from http://miller-rabin.appspot.com/, 10 Mar 2013 */
if (n < UVCONST(341531)) {
bases[0] = UVCONST(9345883071009581737);
@@ -396,28 +396,6 @@ int _XS_is_prob_prime(UV n)
bases[6] = UVCONST( 1795265022 );
nbases = 7;
}
-#else
- /* Classic bases */
- if (n < UVCONST(9080191)) {
- bases[0] = 31; bases[1] = 73; nbases = 2;
- } else if (n < UVCONST(4759123141)) {
- bases[0] = 2; bases[1] = 7; bases[2] = 61; nbases = 3;
- } else if (n < UVCONST(21652684502221)) {
- bases[0] = 2; bases[1] = 1215; bases[2] = 34862; bases[3] = 574237825;
- nbases = 4;
- } else if (n < UVCONST(341550071728321)) {
- bases[0] = 2; bases[1] = 3; bases[2] = 5; bases[3] = 7; bases[4] = 11;
- bases[5] = 13; bases[6] = 17; nbases = 7;
- } else if (n < UVCONST(3825123056546413051)) {
- bases[0] = 2; bases[1] = 3; bases[2] = 5; bases[3] = 7; bases[4] = 11;
- bases[5] = 13; bases[6] = 17; bases[7] = 19; bases[8] = 23; nbases = 9;
- } else {
- bases[0] = 2; bases[1] = 3; bases[2] = 5; bases[3] = 7; bases[4] = 11;
- bases[5] = 13; bases[6] = 17; bases[7] = 19; bases[8] = 23; bases[9] = 29;
- bases[10]= 31; bases[11]= 37;
- nbases = 12;
- }
-#endif
#endif
prob_prime = _XS_miller_rabin(n, bases, nbases);
return 2*prob_prime;
diff --git a/factor.h b/factor.h
index f8919a7..77608c5 100644
--- a/factor.h
+++ b/factor.h
@@ -25,9 +25,11 @@ extern int pminus1_factor(UV n, UV *factors, UV B1, UV B2);
extern int _XS_miller_rabin(UV n, const UV *bases, int nbases);
extern int _XS_is_prob_prime(UV n);
+extern int _XS_is_prime_tom(UV n, int t);
extern UV _XS_divisor_sum(UV n);
+#ifdef FUNC_gcd_ui
static UV gcd_ui(UV x, UV y) {
UV t;
if (y < x) { t = x; x = y; y = t; }
@@ -36,5 +38,6 @@ static UV gcd_ui(UV x, UV y) {
}
return x;
}
+#endif
#endif
diff --git a/sieve.c b/sieve.c
index 618fd21..a8dae1a 100644
--- a/sieve.c
+++ b/sieve.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <math.h>
+#define FUNC_next_prime_in_sieve
#include "sieve.h"
#include "ptypes.h"
#include "cache.h"
diff --git a/sieve.h b/sieve.h
index 6dca024..4dddde0 100644
--- a/sieve.h
+++ b/sieve.h
@@ -27,7 +27,7 @@ static const unsigned char distancewheel30[30] =
static const unsigned char wheeladvance30[30] =
{0,6,0,0,0,0,0,4,0,0,0,2,0,4,0,0,0,2,0,4,0,0,0,6,0,0,0,0,0,2};
-#if 0
+#ifdef FUNC_is_prime_in_sieve
static int is_prime_in_sieve(const unsigned char* sieve, UV p) {
UV d = p/30;
UV m = p - d*30;
@@ -36,6 +36,7 @@ static int is_prime_in_sieve(const unsigned char* sieve, UV p) {
}
#endif
+#ifdef FUNC_next_prime_in_sieve
/* Warning -- can go off the end of the sieve */
static UV next_prime_in_sieve(const unsigned char* sieve, UV p) {
UV d, m;
@@ -49,7 +50,8 @@ static UV next_prime_in_sieve(const unsigned char* sieve, UV p) {
} while (sieve[d] & masktab30[m]);
return(d*30+m);
}
-#if 0
+#endif
+#ifdef FUNC_prev_prime_in_sieve
static UV prev_prime_in_sieve(const unsigned char* sieve, UV p) {
UV d, m;
if (p <= 7)
diff --git a/util.c b/util.c
index c7c3505..88c33f5 100644
--- a/util.c
+++ b/util.c
@@ -85,25 +85,6 @@ static UV count_zero_bits(const unsigned char* m, UV nbytes)
}
-/* Does trial division, assuming x not divisible by 2, 3, or 5 */
-static int _is_trial_prime7(UV n)
-{
- UV limit, i;
- limit = isqrt(n);
- i = 7;
- while (1) { /* trial division, skipping multiples of 2/3/5 */
- if (i > limit) break; if ((n % i) == 0) return 0; i += 4;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 2;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 4;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 2;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 4;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 6;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 2;
- if (i > limit) break; if ((n % i) == 0) return 0; i += 6;
- }
- return 2;
-}
-
/* Does trial division or prob tests, assuming x not divisible by 2, 3, or 5 */
static int _is_prime7(UV n)
{
@@ -194,24 +175,6 @@ int _XS_is_prime(UV n)
}
-UV next_trial_prime(UV n)
-{
- UV d,m;
-
- if (n < 7)
- return (n < 2) ? 2 : (n < 3) ? 3 : (n < 5) ? 5 : 7;
-
- d = n/30;
- m = n - d*30;
- /* Move forward one, knowing we may not be on the wheel */
- if (m == 29) { d++; m = 1; } else { m = nextwheel30[m]; }
- while (!_is_trial_prime7(d*30+m)) {
- m = nextwheel30[m]; if (m == 1) d++;
- }
- return(d*30+m);
-}
-
-
UV _XS_next_prime(UV n)
{
UV d, m;
@@ -800,8 +763,8 @@ char* _moebius_range(UV lo, UV hi)
for (i = lo; i <= hi; i++) {
IV a = A[i-lo];
if (a != 0)
- mu[i-lo] = (a != i && -a != i) ? (a<0) - (a>0)
- : (a>0) - (a<0);
+ mu[i-lo] = (a != (IV)i && -a != (IV)i) ? (a<0) - (a>0)
+ : (a>0) - (a<0);
}
Safefree(A);
#endif
diff --git a/util.h b/util.h
index b9d966b..9807ffb 100644
--- a/util.h
+++ b/util.h
@@ -7,7 +7,6 @@ extern int _XS_get_verbose(void);
extern void _XS_set_verbose(int v);
extern int _XS_is_prime(UV x);
-extern UV next_trial_prime(UV x);
extern UV _XS_next_prime(UV x);
extern UV _XS_prev_prime(UV x);
--
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