[libmath-prime-util-perl] 32/72: Perl 5.6 fixes
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:49:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.32
in repository libmath-prime-util-perl.
commit bb687ce4d12f3c44cf87a23370240c2b73c30338
Author: Dana Jacobsen <dana at acm.org>
Date: Tue Sep 17 11:28:59 2013 -0700
Perl 5.6 fixes
---
Changes | 2 +-
README | 2 +-
bin/factor.pl | 1 +
bin/primes.pl | 2 ++
lib/Math/Prime/Util.pm | 13 ++++++++-----
lib/Math/Prime/Util/PP.pm | 4 ++--
t/81-bignum.t | 11 +++++++----
7 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/Changes b/Changes
index 4c161d3..c389969 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
Revision history for Perl module Math::Prime::Util
-0.32 2013-08
+0.32 2013-09
[Functions Added]
- is_proven_prime
diff --git a/README b/README
index 0501b68..e230a11 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Math::Prime::Util version 0.31
+Math::Prime::Util version 0.32
A set of utilities related to prime numbers. These include multiple sieving
methods, is_prime, prime_count, nth_prime, approximations and bounds for
diff --git a/bin/factor.pl b/bin/factor.pl
index 9fe1e0d..6fca37b 100755
--- a/bin/factor.pl
+++ b/bin/factor.pl
@@ -34,6 +34,7 @@ prime_set_config(verbose => 3) if exists $opts{'verbose'};
if (@ARGV) {
foreach my $n (@ARGV) {
+ $n =~ s/\s*$//; $n =~ s/^\s*//;
$n = eval_expr($n) unless $n =~ /^\d+$/;
print "$n: ", join(" ", factor($n)), "\n";
}
diff --git a/bin/primes.pl b/bin/primes.pl
index e188254..f574a98 100755
--- a/bin/primes.pl
+++ b/bin/primes.pl
@@ -119,6 +119,8 @@ die_usage() unless @ARGV == 2;
my ($start, $end) = @ARGV;
# Allow some expression evaluation on the input, but don't just eval it.
$end = "($start)$end" if $end =~ /^\+/;
+$start =~ s/\s*$//; $start =~ s/^\s*//;
+$end =~ s/\s*$//; $end =~ s/^\s*//;
$start = eval_expr($start) unless $start =~ /^\d+$/;
$end = eval_expr($end ) unless $end =~ /^\d+$/;
die "$start isn't a positive integer" if $start =~ tr/0123456789//c;
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 0411681..ea1177b 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -6,7 +6,7 @@ use Bytes::Random::Secure;
BEGIN {
$Math::Prime::Util::AUTHORITY = 'cpan:DANAJ';
- $Math::Prime::Util::VERSION = '0.31';
+ $Math::Prime::Util::VERSION = '0.32';
}
# parent is cleaner, and in the Perl 5.10.1 / 5.12.0 core, but not earlier.
@@ -837,7 +837,7 @@ sub primes {
my($bits) = @_;
_validate_num($bits, 2) || _validate_positive_integer($bits, 2);
- croak "Large random primes not supported on old Perl"
+ croak "Mid-size random primes not supported on broken old Perl"
if $] < 5.008 && $bits > 49
&& $_Config{'maxbits'} > 32 && $bits <= $_Config{'maxbits'};
if ($bits > $_Config{'maxbits'}) {
@@ -867,6 +867,7 @@ sub primes {
if (1 && $bits > 64) {
my $irandf = _get_rand_func();
my $l = ($_Config{'maxbits'} > 32 && $bits > 79) ? 63 : 31;
+ $l = 49 if $l == 63 && $] < 5.008; # Fix for broken Perl 5.6
$l = $bits-2 if $bits-2 < $l;
my $arange = (1 << $l) - 1; # 2^$l-1
my $brange = Math::BigInt->new(2)->bpow($bits-$l-2)->bdec();
@@ -1493,8 +1494,9 @@ sub _generic_forprimes (&$;$) { ## no critic qw(ProhibitSubroutinePrototypes)
_validate_num($end) || _validate_positive_integer($end);
# It's possible we're here just because the arguments were bigints < 2^64
# TODO: make a function to convert native size bigints to UVs, and let the
- # XS functions call that, so we don't do these loop-de-loops.
- if (!ref($beg) && !ref($end) && $beg <= $_XS_MAXVAL && $end <= $_XS_MAXVAL) {
+ # XS functions call that, so we don't do these loop-de-loops. This
+ # also has nasty coupling with the XS implementation.
+ if (!ref($beg) && !ref($end) && $beg <= $_XS_MAXVAL && $end <= $_XS_MAXVAL && $] >= 5.007) {
return forprimes( \&$sub, $beg, $end);
}
$beg = 2 if $beg < 2;
@@ -1609,6 +1611,7 @@ sub znorder {
eval { require Math::BigInt; Math::BigInt->import(try=>'GMP,Pari'); 1; }
or do { croak "Cannot load Math::BigInt"; };
}
+ # Sadly, Calc/FastCalc are horrendously slow for this function.
return if Math::BigInt::bgcd($a, $n) > 1;
# Method 1: check all a^k 1 .. $n-1.
# Naive and terrible slow.
@@ -2425,7 +2428,7 @@ Math::Prime::Util - Utilities related to prime numbers, including fast sieves an
=head1 VERSION
-Version 0.31
+Version 0.32
=head1 SYNOPSIS
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index e4e1ba5..957d6f1 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -5,7 +5,7 @@ use Carp qw/carp croak confess/;
BEGIN {
$Math::Prime::Util::PP::AUTHORITY = 'cpan:DANAJ';
- $Math::Prime::Util::PP::VERSION = '0.30';
+ $Math::Prime::Util::PP::VERSION = '0.32';
}
# The Pure Perl versions of all the Math::Prime::Util routines.
@@ -2508,7 +2508,7 @@ Math::Prime::Util::PP - Pure Perl version of Math::Prime::Util
=head1 VERSION
-Version 0.29
+Version 0.32
=head1 SYNOPSIS
diff --git a/t/81-bignum.t b/t/81-bignum.t
index a422b3d..77fe482 100644
--- a/t/81-bignum.t
+++ b/t/81-bignum.t
@@ -75,7 +75,7 @@ plan tests => 0
+ 6*2*$extra # more PC tests
+ scalar(keys %factors)
+ scalar(keys %allfactors)
- + 6 # moebius, euler_phi, jordan totient
+ + 7 # moebius, euler_phi, jordan totient, divsum, znorder
+ 15 # random primes
+ 0;
@@ -220,9 +220,12 @@ SKIP: {
# Done wrong, the following will have a bunch of extra zeros.
my $hundredfac = Math::BigInt->new(100)->bfac;
is( divisor_sum($hundredfac), 774026292208877355243820142464115597282472420387824628823543695735957009720184359087194959566149232506852422409529601312686157396490982598473425595924480000000, "Divisor sum of 100!" );
- is( znorder(82734587234,927208363107752634625923555185111613055040823736157),
- 4360156780036190093445833597286118936800,
- "znorder" );
+ # Calc/FastCalc are slugs with this function, so tone things down.
+ #is( znorder(82734587234,927208363107752634625923555185111613055040823736157),
+ # 4360156780036190093445833597286118936800,
+ # "znorder" );
+ is(znorder(8267,927208363107752634625923),2843344277735759285436,"znorder 1");
+ is(znorder(902,827208363107752634625947),undef,"znorder 2");
}
###############################################################################
--
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