This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.41
in repository libmath-prime-util-perl.

commit f0ac1b24922f1b6dfb4fa1f00a3833aa708f1270
Author: Dana Jacobsen <d...@acm.org>
Date:   Tue Apr 29 14:43:45 2014 -0700

    croak with sane message when lucas_sequence given n < 2
---
 TODO                   | 2 --
 lib/Math/Prime/Util.pm | 1 +
 primality.c            | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index cc53f13..f8132c7 100644
--- a/TODO
+++ b/TODO
@@ -72,5 +72,3 @@
 - We don't use legendre_phi for other functions any more, but it'd be nice
   to speed it up using some ideas from the Ohana 2011 SAGE branch.  For example
   (10**13,10**5) takes 2.5x longer, albeit with 6x less memory.
-
-- lucas_sequence with n = 0 or 1
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 987df4b..40ea2f2 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -626,6 +626,7 @@ sub _generic_factor_exp {
 sub lucas_sequence {
   my($n, $P, $Q, $k) = @_;
   _validate_num($n) || _validate_positive_integer($n);
+  croak("Invalid input to lucas_sequence:  modulus n must be > 1") if $n <= 1;
   _validate_num($k) || _validate_positive_integer($k);
   { my $testP = (!defined $P || $P >= 0) ? $P : -$P;
     _validate_num($testP) || _validate_positive_integer($testP); }
diff --git a/primality.c b/primality.c
index 29804df..0f9b221 100644
--- a/primality.c
+++ b/primality.c
@@ -320,6 +320,7 @@ void lucas_seq(UV* Uret, UV* Vret, UV* Qkret, UV n, IV P, 
IV Q, UV k)
 {
   UV U, V, b, Dmod, Qmod, Pmod, Qk;
 
+  MPUassert(n > 1, "lucas_sequence:  modulus n must be > 1");
   if (k == 0) {
     *Uret = 0;
     *Vret = 2;

-- 
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

Reply via email to