[libmath-prime-util-perl] 07/25: Changes for 32-bit
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:50:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.35
in repository libmath-prime-util-perl.
commit ab066b2247dfc011367f7e19b4b3f177ddffe4cf
Author: Dana Jacobsen <dana at acm.org>
Date: Fri Nov 22 18:07:56 2013 -0800
Changes for 32-bit
---
Changes | 6 ++++++
xt/test-bpsw.pl | 10 ++++++++--
xt/test-pcapprox.pl | 18 +++++++++---------
xt/test-primes-script2.pl | 2 +-
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/Changes b/Changes
index a950550..64c32ff 100644
--- a/Changes
+++ b/Changes
@@ -16,6 +16,12 @@ Revision history for Perl module Math::Prime::Util
is_prime("882249208105452588824618008529");
$a = euler_phi("801294088771394680000412");
+ [FUNCTIONALITY AND PERFORMANCE]
+
+ - Some fixes for 32-bit.
+
+ - prime_count_approx, upper, and lower return exact answers in more cases.
+
0.34 2013-11-19
diff --git a/xt/test-bpsw.pl b/xt/test-bpsw.pl
index 63a0a96..9f11a0c 100755
--- a/xt/test-bpsw.pl
+++ b/xt/test-bpsw.pl
@@ -72,18 +72,22 @@ foreach my $r (1 .. $nrandom) {
die "MR(2) failure for $n" unless Math::Prime::Util::is_strong_pseudoprime($n,2) == Math::Primality::is_strong_pseudoprime($n,2);
die "MR($rand_base) failure for $n" unless Math::Prime::Util::is_strong_pseudoprime($n,$rand_base) == Math::Primality::is_strong_pseudoprime($n,$rand_base);
die "SLPSP failure for $n" unless Math::Prime::Util::is_strong_lucas_pseudoprime($n) == Math::Primality::is_strong_lucas_pseudoprime($n);
- die "Prime failure for $n" unless (Math::Prime::Util::is_prime($n)?1:0) == Math::Primality::is_prime($n);
+ my $ip1 = Math::Primality::is_prime($n);
+ my $ip2 = Math::Prime::Util::is_prime($n);
+ die "Prime failure for $n ($ip1,$ip2)" unless !!$ip1 == !!$ip2;
print "." if ($r % 256) == 0;
}
print "\n";
+}
+if (1) {
use bigint try => 'GMP';
my $big_base = 2**64 + 1;
my $range = 2**1024 - 1;
my $end_base = $big_base + $range;
print "Testing random numbers from $big_base to $end_base\n";
-foreach my $r (1 .. int($nrandom/50)) {
+foreach my $r (1 .. int($nrandom/100)) {
my $n = $big_base + $rgen->($range);
my $rand_base = 2 + $rgen->($n-4);
die "MR(2) failure for $n" unless Math::Prime::Util::is_strong_pseudoprime($n,2) == Math::Primality::is_strong_pseudoprime("$n","2");
@@ -96,6 +100,8 @@ foreach my $r (1 .. int($nrandom/50)) {
print "\n";
}
+print "\nBenchmarks\n";
+
my $num_rns = 100;
my $len_rns = 100;
my $count = -1;
diff --git a/xt/test-pcapprox.pl b/xt/test-pcapprox.pl
index 0f10cef..3496bc5 100755
--- a/xt/test-pcapprox.pl
+++ b/xt/test-pcapprox.pl
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Math::Prime::Util qw/prime_count prime_count_approx prime_count_lower prime_count_upper LogarithmicIntegral RiemannR/;
+use Math::BigFloat;
$| = 1; # fast pipes
@@ -20,11 +21,11 @@ my %pivals = (
1000000000000 => 37607912018,
10000000000000 => 346065536839,
100000000000000 => 3204941750802,
- 1000000000000000 => 29844570422669,
- 10000000000000000 => 279238341033925,
- 100000000000000000 => 2623557157654233,
- 1000000000000000000 => 24739954287740860,
-10000000000000000000 => 234057667276344607,
+ '1000000000000000' => 29844570422669,
+ '10000000000000000' => 279238341033925,
+ '100000000000000000' => 2623557157654233,
+ '1000000000000000000' => 24739954287740860,
+'10000000000000000000' => 234057667276344607,
);
printf(" N %12s %12s %12s %12s\n", "pc_approx", "Li", "LiCor", "R");
@@ -53,10 +54,9 @@ print "\n";
printf(" N %12s %12s %12s %12s\n", "lower", "upper", "SchoenfeldL", "SchoenfeldU");
printf("----- %12s %12s %12s %12s\n", '-'x12,'-'x12,'-'x12,'-'x12);
foreach my $n (sort {$a<=>$b} keys %pivals) {
- my $pin = $pivals{$n};
- my $pcl = prime_count_lower($n);
- my $pcu = prime_count_upper($n);
- my ($scl,$scu) = stoll($n);
+ my ($pin, $pcl, $pcu, $scl, $scu) =
+ map { Math::BigFloat->new($_) }
+ ($pivals{$n}, prime_count_lower($n), prime_count_upper($n), stoll($n));
#printf "10^%2d %12d %12d\n", length($n)-1, $pin-$pcl, $pcu-$pin;
printf "10^%2d %12.7f %12.7f %12.7f %12.7f\n",
diff --git a/xt/test-primes-script2.pl b/xt/test-primes-script2.pl
index 5de579d..483150b 100755
--- a/xt/test-primes-script2.pl
+++ b/xt/test-primes-script2.pl
@@ -28,7 +28,7 @@ compare('Sophie Germain',
# 2) it supports bignums, which is required for Fib, Euclid, Lucas, etc.
compare('Palindromic',
- '10**11',
+ (~0 > 4294967295) ? '10**11' : '10**10',
"$FindBin::Bin/../bin/primes.pl --palin 1 LASTNUM",
q/perl -MMath::Prime::Util=is_prime -MMath::NumSeq::Palindromes -e 'my $seq = Math::NumSeq::Palindromes->new; while (1) { my $v = ($seq->next)[1]; last if $v > LASTNUM; print "$v\n" if is_prime($v); }'/);
--
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