[libmath-prime-util-perl] 03/35: Lucas sequence should return a bigint if arg is a bigint

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:50:01 UTC 2015


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

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

commit 62d0d75fef0bdcb535dffc90723e78bd77ab825e
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Oct 17 18:36:39 2013 -0700

    Lucas sequence should return a bigint if arg is a bigint
---
 Changes                |  6 ++++++
 TODO                   | 19 ++++++++++++++-----
 lib/Math/Prime/Util.pm |  7 ++++---
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/Changes b/Changes
index 65e2993..65af7f2 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,11 @@
 Revision history for Perl module Math::Prime::Util
 
+0.33  2013-10
+
+    [MISC]
+
+    - Lucas sequence called with bigints will return bigint objects.
+
 0.32  2013-10-13
 
     [ADDED]
diff --git a/TODO b/TODO
index 9072e39..b22d5d5 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,13 @@
+- Testing requirements after changes:
+
+  - Test all functions return either native or bigints.  Functions that
+    return raw MPU::GMP results will return strings, which isn't right.
+
+  - Valgrind, coverage
+
+  - compile with -O2 -g -Wall -Wextra -Wdeclaration-after-statement -fsigned-char
+
 
-- segment sieve should itself use a segment for its primes.
-  Today we'd need sqrt(2^64) max = 140MB.  Segmenting would yield under 1MB.
 
 - Add test to check maxbits in compiled library vs. Perl
 
@@ -15,9 +22,6 @@
 
 - Test all routines for numbers on word-size boundary, or ranges that cross.
 
-- Test all functions return either native or bigints.  Functions that return
-  raw MPU::GMP results will return strings, which isn't right.
-
 - An assembler version of mulmod for i386 would be _really_ helpful for
   all the non-x86-64 Intel machines.
 
@@ -31,6 +35,9 @@
    - LMO prime count
    - QS factoring
 
+- segment sieve should itself use a segment for its primes.
+  Today we'd need sqrt(2^64) max = 140MB.  Segmenting would yield under 1MB.
+
 - Figure out a way to make the internal FOR_EACH_PRIME macros use a segmented
   sieve.
 
@@ -49,3 +56,5 @@
   API (small factors, isprime, then call main code) and main code (just the
   algorithm).  The PP code isn't doing that, which means we're doing lots of
   extra primality checks, which aren't cheap in PP.
+
+- high level routine for factor_exp.  Use factor_exp internally
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index c553cef..cedf2c4 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -2031,9 +2031,10 @@ sub lucas_sequence {
   return _XS_lucas_sequence($n, $P, $Q, $k)
     if ref($_[0]) ne 'Math::BigInt' && $n <= $_XS_MAXVAL
     && ref($_[3]) ne 'Math::BigInt' && $k <= $_XS_MAXVAL;
-  return Math::Prime::Util::GMP::lucas_sequence($n, $P, $Q, $k)
-    if $_HAVE_GMP
-    && defined &Math::Prime::Util::GMP::lucas_sequence;
+  if ($_HAVE_GMP && defined &Math::Prime::Util::GMP::lucas_sequence) {
+    return map { ($_ > ~0) ? $n->copy->bzero->badd(''.$_) : $_ }
+           Math::Prime::Util::GMP::lucas_sequence($n, $P, $Q, $k);
+  }
   return Math::Prime::Util::PP::lucas_sequence($n, $P, $Q, $k);
 }
 

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