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 e0742a9a7ec77b1930b4679bb0706234beb93c99
Author: Dana Jacobsen <d...@acm.org>
Date:   Wed Dec 11 22:46:10 2013 -0800

    Add some 5.6.2 workarounds
---
 Changes                                       |  8 +++++
 MANIFEST                                      |  1 +
 lib/Math/Prime/Util.pm                        |  2 +-
 lib/Math/Prime/Util/PP.pm                     |  6 ++--
 xt/{primecount-many.t => primecount-approx.t} | 49 ++++++++++++++-------------
 xt/primecount-many.t                          | 41 ++++++++++++++--------
 6 files changed, 64 insertions(+), 43 deletions(-)

diff --git a/Changes b/Changes
index be82890..5767301 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,13 @@
 Revision history for Perl module Math::Prime::Util
 
+0.36  2013-12
+
+    - Some 5.6.2-is-broken workarounds.
+
+    - Some LMO edge cases:  small numbers that only show up if a #define is
+      changed, and counts > 18440000000000000000.  Tested through 2^64-1 now.
+
+
 0.35  2013-12-08
 
     [API Changes]
diff --git a/MANIFEST b/MANIFEST
index aa254c6..2f77ac4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -108,6 +108,7 @@ xt/make-script-test-data.pl
 xt/measure_zeta_accuracy.pl
 xt/pari-totient-moebius.pl
 xt/nthprime.t
+xt/primecount-approx.t
 xt/primecount-many.t
 xt/primes-edgecases.pl
 xt/rwh_primecount.py
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index b0df220..8687dc3 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -1198,7 +1198,7 @@ sub consecutive_integer_lcm {
   _validate_num($n) || _validate_positive_integer($n);
   return 0 if $n < 1;
 
-  my $max = ($_Config{'maxbits'} == 32) ? 22 : ($] < 5.008) ? 43 : 46;
+  my $max = ($_Config{'maxbits'} == 32) ? 22 : ($] < 5.008) ? 37 : 46;
 
   if ($_HAVE_GMP && defined &Math::Prime::Util::GMP::consecutive_integer_lcm) {
     my $clcm = Math::Prime::Util::GMP::consecutive_integer_lcm($n);
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index f7ef715..2de4bda 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -395,9 +395,9 @@ sub next_prime {
 
   return $_prime_next_small[$n] if $n <= $#_prime_next_small;
 
-  if (ref($n) ne 'Math::BigInt' &&
-      $n >= ((_PP_prime_maxbits == 32) ? 4294967291 : 18446744073709551557)) {
-    $n = Math::BigInt->new(''.$n);
+  if (ref($n) ne 'Math::BigInt' && $n >= 4294967291) {
+    $n = Math::BigInt->new(''.$_[0])
+       if _PP_prime_maxbits == 32 || $n >= 18446744073709551557;
   }
 
   # Be careful trying to do:
diff --git a/xt/primecount-many.t b/xt/primecount-approx.t
similarity index 77%
copy from xt/primecount-many.t
copy to xt/primecount-approx.t
index c93b617..5bd6976 100644
--- a/xt/primecount-many.t
+++ b/xt/primecount-approx.t
@@ -104,27 +104,34 @@ my %pivals = (
  2305843009213693952 =>  55890484045084135,
  4611686018427387904 => 109932807585469973,
  9223372036854775808 => 216289611853439384,
+# From http://trac.sagemath.org/ticket/7539 plus sieving
+ 11000000000000000000 => 256890014776557326,
+ 12000000000000000000 => 279675001309887227,
+ 13000000000000000000 => 302416755645383081,
+ 14000000000000000000 => 325118755759814408,
+ 15000000000000000000 => 347783970566657581,
+ 16000000000000000000 => 370414963651223281,
+ 17000000000000000000 => 393013970558176111,
+ 18000000000000000000 => 415582957615112220,
+ 18400000000000000000 => 424602543873663577,
+ 18440000000000000000 => 425504257754137607,
+ 18446700000000000000 => 425655290520421050,
+ 18446740000000000000 => 425656192205366999,
+ 18446744000000000000 => 425656282373661946,
+ 18446744030000000000 => 425656283049924141,
+ 18446744040000000000 => 425656283275356419,
+ 18446744050000000000 => 425656283500787632,
+ 18446744070000000000 => 425656283951611098,
+ 18446744073000000000 => 425656284019227775,
+ 18446744073700000000 => 425656284035002496,
+ 18446744073709000000 => 425656284035205391,
+ 18446744073709550000 => 425656284035217706,
+ 18446744073709551000 => 425656284035217730,
+ 18446744073709551615 => 425656284035217743,
 );
 
-plan tests => 5 + 4*scalar(keys %pivals);
+plan tests => 3*scalar(keys %pivals);
 
-# Test prime counts using sampling
-diag "Sampling small prime counts, should take < 1 minute";
-{
-  my $countstr;
-  $countstr = join(" ", map { prime_count($_) } 1 .. 100000);
-  is(sha256_hex($countstr), 
"cdbc5c94a927d0d9481cb26b3d3e60c0617a4be65ce9db3075c0363c7a81ef52", "prime 
counts 1..10^5");
-  $countstr = join(" ", map { prime_count(100*$_ + ($_%101)) } 1000 .. 100000);
-  is(sha256_hex($countstr), 
"73a0b71dedff9611e06fd57e52b88c8afd7f86b5351e4950b2dd5c1d68845b6e", "prime 
counts 10^5..10^7 (sample 100)");
-  $countstr = join(" ", map { prime_count(10000*$_ + ($_%9973)) } 1000 .. 
10000);
-  is(sha256_hex($countstr), 
"d73736c54362136aa0a48bab44b55004b2e63e0d1d03a6cbe1aab42c6a579d0c", "prime 
counts 10^7..10^8 (sample 10k)");
-  $countstr = join(" ", map { prime_count(500000*$_ + 250837 + $_) } 200 .. 
2000);
-  is(sha256_hex($countstr), 
"00a580b2f52b661f065f5ce49bd2aeacb3b169d8903cf824b65731441e40f0b9", "prime 
counts 10^8..10^9 (sample 500k)");
-  $countstr = join(" ", map { prime_count(10000000*$_ + 250837 + $_) } 100 .. 
1000);
-  is(sha256_hex($countstr), 
"9fd78debf4b510ee6d230cabf314ebef5eb253ee63d5df658e45414613f7b8c2", "prime 
counts 10^9..10^10 (sample 10M)");
-}
-
-diag "Approximations and limits, should be a few seconds";
 foreach my $n (sort {$a <=> $b} keys %pivals) {
   my $pin = $pivals{$n};
   cmp_ok( prime_count_upper($n), '>=', $pin, "Pi($n) <= upper estimate" );
@@ -137,9 +144,3 @@ foreach my $n (sort {$a <=> $b} keys %pivals) {
                     : 0.2;
   cmp_ok( abs($pin - $approx) * (100.0 / $percent_limit), '<=', $pin, 
"prime_count_approx($n) within $percent_limit\% of Pi($n)");
 }
-
-diag "Prime counts, will take a very long time";
-foreach my $n (sort {$a <=> $b} keys %pivals) {
-  my $pin = $pivals{$n};
-  is( prime_count($n), $pin, "Pi($n) = $pin" );
-}
diff --git a/xt/primecount-many.t b/xt/primecount-many.t
index c93b617..5d68460 100644
--- a/xt/primecount-many.t
+++ b/xt/primecount-many.t
@@ -104,9 +104,34 @@ my %pivals = (
  2305843009213693952 =>  55890484045084135,
  4611686018427387904 => 109932807585469973,
  9223372036854775808 => 216289611853439384,
+# From http://trac.sagemath.org/ticket/7539 plus sieving
+# 11000000000000000000 => 256890014776557326,
+# 12000000000000000000 => 279675001309887227,
+# 13000000000000000000 => 302416755645383081,
+# 14000000000000000000 => 325118755759814408,
+# 15000000000000000000 => 347783970566657581,
+# 16000000000000000000 => 370414963651223281,
+# 17000000000000000000 => 393013970558176111,
+# 18000000000000000000 => 415582957615112220,
+# 18400000000000000000 => 424602543873663577,
+18440000000000000000 => 425504257754137607,   # verified
+18446700000000000000 => 425655290520421050,   # verified
+# 18446740000000000000 => 425656192205366999,
+# 18446744000000000000 => 425656282373661946,
+# 18446744030000000000 => 425656283049924141,
+# 18446744040000000000 => 425656283275356419,
+# 18446744050000000000 => 425656283500787632,
+# 18446744070000000000 => 425656283951611098,
+# 18446744073000000000 => 425656284019227775,   # verified
+# 18446744073700000000 => 425656284035002496,   # verified
+# 18446744073709000000 => 425656284035205391,   # verified
+# 18446744073709550000 => 425656284035217706,   # verified
+# 18446744073709551000 => 425656284035217730,
+18446744073709551615 => 425656284035217743,   # verified
+#
 );
 
-plan tests => 5 + 4*scalar(keys %pivals);
+plan tests => 5 + scalar(keys %pivals);
 
 # Test prime counts using sampling
 diag "Sampling small prime counts, should take < 1 minute";
@@ -124,20 +149,6 @@ diag "Sampling small prime counts, should take < 1 minute";
   is(sha256_hex($countstr), 
"9fd78debf4b510ee6d230cabf314ebef5eb253ee63d5df658e45414613f7b8c2", "prime 
counts 10^9..10^10 (sample 10M)");
 }
 
-diag "Approximations and limits, should be a few seconds";
-foreach my $n (sort {$a <=> $b} keys %pivals) {
-  my $pin = $pivals{$n};
-  cmp_ok( prime_count_upper($n), '>=', $pin, "Pi($n) <= upper estimate" );
-  cmp_ok( prime_count_lower($n), '<=', $pin, "Pi($n) >= lower estimate" );
-  my $approx = prime_count_approx($n);
-  my $percent_limit = ($n > 1000000000000) ? 0.00005
-                    : ($n >   10000000000) ? 0.0002
-                    : ($n >     100000000) ? 0.002
-                    : ($n >       1000000) ? 0.02
-                    : 0.2;
-  cmp_ok( abs($pin - $approx) * (100.0 / $percent_limit), '<=', $pin, 
"prime_count_approx($n) within $percent_limit\% of Pi($n)");
-}
-
 diag "Prime counts, will take a very long time";
 foreach my $n (sort {$a <=> $b} keys %pivals) {
   my $pin = $pivals{$n};

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