[libmath-prime-util-perl] 04/17: Minor tweaks
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:47:13 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.21
in repository libmath-prime-util-perl.
commit 11034f859af76e14fd2c21946f52956e9cb96c5a
Author: Dana Jacobsen <dana at acm.org>
Date: Sun Feb 17 14:33:11 2013 -0800
Minor tweaks
---
Changes | 4 +---
bin/primes.pl | 3 ++-
examples/make-script-test-data.pl | 2 +-
examples/test-primes-script.pl | 2 +-
lib/Math/Prime/Util.pm | 5 ++---
5 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/Changes b/Changes
index cb1b56d..91720de 100644
--- a/Changes
+++ b/Changes
@@ -2,9 +2,7 @@ Revision history for Perl extension Math::Prime::Util.
0.21 ? February 2012
- - primes.pl changes:
- - add circular and Panaitopol primes
- - big Pillai primes speedup by not using bigints if not necessary
+ - primes.pl: Add circular and Panaitopol primes, speedup Pillai primes.
0.20 3 February 2012
diff --git a/bin/primes.pl b/bin/primes.pl
index 7dceaff..a34283e 100755
--- a/bin/primes.pl
+++ b/bin/primes.pl
@@ -332,7 +332,8 @@ sub lucky_primes {
} while ($index <= $#lucky);
}
# Then restrict to primes to get A031157.
- grep { $_ >= $start && is_prime($_) } @lucky;
+ shift @lucky while $lucky[0] < $start;
+ grep { is_prime($_) } @lucky;
}
# This is not a general palindromic digit function!
diff --git a/examples/make-script-test-data.pl b/examples/make-script-test-data.pl
index 4bcfe7c..d72f463 100755
--- a/examples/make-script-test-data.pl
+++ b/examples/make-script-test-data.pl
@@ -3,7 +3,7 @@ use strict;
use warnings;
use File::Spec::Functions;
use FindBin;
-use bigint;
+use bigint try => 'GMP';
use Data::BitStream::XS;
use Math::Prime::Util qw/is_prime/;
$|++;
diff --git a/examples/test-primes-script.pl b/examples/test-primes-script.pl
index 052b6af..3ad7c6d 100755
--- a/examples/test-primes-script.pl
+++ b/examples/test-primes-script.pl
@@ -4,7 +4,7 @@ use warnings;
use File::Spec::Functions;
use FindBin;
use Time::HiRes qw(gettimeofday tv_interval);
-use bigint;
+use bigint try => 'GMP';
use Data::BitStream::XS;
$|++; #flush the output buffer after every write() or print() function
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 6a69bcc..3a9c197 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -578,8 +578,7 @@ sub primes {
# If the range is reasonably small, generate using simple Monte Carlo
# method (aka the 'trivial' method). Completely uniform.
- if ($oddrange < ~0) {
- $oddrange = int($oddrange->bstr) if ref($oddrange) eq 'Math::BigInt';
+ if ($oddrange < $_Config{'maxparam'}) {
my $loop_limit = 2000 * 1000; # To protect against broken rand
if ($low > 11) {
while ($loop_limit-- > 0) {
@@ -2944,7 +2943,7 @@ Project Euler, problem 21 (Amicable numbers):
use Math::Prime::Util qw/divisor_sum/;
sub dsum { my $n = shift; divisor_sum($n, sub {$_[0]}) - $n; }
my $sum = 0;
- foreach my $a (1..10000) {
+ foreach my $a (1..10000) {
my $b = dsum($a);
$sum += $a + $b if $b > $a && dsum($b) == $a;
}
--
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