[libmath-prime-util-perl] 14/72: Use MPU::GMP::pn_primorial if possible
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:49:36 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 19d92dd6984ff07628c47e6f11964e020d81396c
Author: Dana Jacobsen <dana at acm.org>
Date: Thu Aug 22 14:13:56 2013 -0700
Use MPU::GMP::pn_primorial if possible
---
Changes | 2 ++
lib/Math/Prime/Util.pm | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Changes b/Changes
index 2a72264..b64d8a8 100644
--- a/Changes
+++ b/Changes
@@ -10,6 +10,8 @@ Revision history for Perl module Math::Prime::Util
- random_nbit_prime now uses Fouque and Tibouchi A1. Slightly better
uniformity and typically a bit faster.
+ - Use MPU::GMP::pn_primorial if we have it.
+
0.31 2013-08-07
- Change proof certificate documentation to reflect the new text format.
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index dc83004..7399339 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -1156,7 +1156,18 @@ sub primorial {
sub pn_primorial {
my($n) = @_;
- return primorial(nth_prime($n));
+ return primorial(nth_prime($n))
+ unless $_HAVE_GMP && defined &Math::Prime::Util::GMP::pn_primorial;
+
+ _validate_num($n) || _validate_positive_integer($n);
+ my $pn = Math::Prime::Util::GMP::pn_primorial($n);
+ return int($pn) if $n < (($_Config{'maxbits'} == 32) ? 10 : 16);
+ return $_[0]->copy->bzero->badd($pn) if ref($_[0]) eq 'Math::BigInt';
+ if (!defined $Math::BigInt::VERSION) {
+ eval { require Math::BigInt; Math::BigInt->import(try=>'GMP,Pari'); 1; }
+ or do { croak "Cannot load Math::BigInt"; };
+ }
+ return Math::BigInt->new("$pn");
}
sub consecutive_integer_lcm {
--
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