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 49d01994b85774fcab01c060526132923e2ae8e5 Author: Dana Jacobsen <d...@acm.org> Date: Thu Jan 9 18:24:32 2014 -0800 small performance increase for next_prime --- lib/Math/Prime/Util/PrimeIterator.pm | 18 ++++++++---------- util.c | 8 +++++--- xt/primality-proofs.pl | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/Math/Prime/Util/PrimeIterator.pm b/lib/Math/Prime/Util/PrimeIterator.pm index d778299..4573c34 100644 --- a/lib/Math/Prime/Util/PrimeIterator.pm +++ b/lib/Math/Prime/Util/PrimeIterator.pm @@ -36,9 +36,9 @@ sub __iter__ { sub value { ${$_[0]}; } sub next { - my $self = shift; - $$self = next_prime($$self); - return $self; + #my $self = shift; $$self = next_prime($$self); return $self; + ${$_[0]} = next_prime(${$_[0]}); + return $_[0]; } sub prev { my $self = shift; @@ -47,9 +47,9 @@ sub prev { return $self; } sub iterate { - my $self = shift; - my $p = $$self; - $$self = next_prime($p); + #my $self = shift; my $p = $$self; $$self = next_prime($p); return $p; + my $p = ${$_[0]}; + ${$_[0]} = next_prime(${$_[0]}); return $p; } @@ -65,14 +65,12 @@ sub rewind { } sub peek { - my $self = shift; - return next_prime($$self); + return next_prime(${$_[0]}); } # Some methods to match Math::NumSeq sub tell_i { - my $self = shift; - return prime_count($$self); + return prime_count(${$_[0]}); } sub pred { my($self, $n) = @_; diff --git a/util.c b/util.c index b31d587..611fb94 100644 --- a/util.c +++ b/util.c @@ -280,11 +280,13 @@ UV _XS_next_prime(UV n) m = n - d*30; /* Move forward one, knowing we may not be on the wheel */ if (m == 29) { d++; m = 1; } else { m = nextwheel30[m]; } - while (!_is_prime7(d*30+m)) { + n = d*30+m; + while (!_is_prime7(n)) { /* Move forward one, knowing we are on the wheel */ - m = nextwheel30[m]; if (m == 1) d++; + n += wheeladvance30[m]; + m = nextwheel30[m]; } - return(d*30+m); + return(n); } diff --git a/xt/primality-proofs.pl b/xt/primality-proofs.pl index a1f081f..16daeda 100755 --- a/xt/primality-proofs.pl +++ b/xt/primality-proofs.pl @@ -4,6 +4,9 @@ use strict; use Math::Prime::Util ':all'; use Math::BigInt lib=>"GMP"; +if (!Math::Prime::Util::prime_get_config->{gmp}) { + print "\nYou should install Math::Prime::Util::GMP.\n\n"; +} $|++; print "random prime proofs: 50, 100, 200, 300, 400 +/- 50 digits\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