[libmath-prime-util-perl] 19/23: Update for release, and standardize infinity processing

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


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

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

commit d719bbe594289b4a186d5f4c31f8bfaa752dab3b
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Nov 29 15:56:34 2012 -0800

    Update for release, and standardize infinity processing
---
 Changes                           |  2 +-
 README                            |  2 +-
 lib/Math/Prime/Util.pm            | 29 +++++++++++++++--------------
 lib/Math/Prime/Util/MemFree.pm    |  4 ++--
 lib/Math/Prime/Util/PP.pm         | 20 ++++++++++++--------
 lib/Math/Prime/Util/PrimeArray.pm |  4 ++--
 6 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/Changes b/Changes
index 390ef11..f061020 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
 Revision history for Perl extension Math::Prime::Util.
 
-0.14  ?? November 2012
+0.14  29 November 2012
 
     - Compilation and test issues:
           Fix compilation on NetBSD
diff --git a/README b/README
index f6bdd86..c529e8a 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Math::Prime::Util version 0.13
+Math::Prime::Util version 0.14
 
 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/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index f8fe583..d701af4 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -5,7 +5,7 @@ use Carp qw/croak confess carp/;
 
 BEGIN {
   $Math::Prime::Util::AUTHORITY = 'cpan:DANAJ';
-  $Math::Prime::Util::VERSION = '0.13';
+  $Math::Prime::Util::VERSION = '0.14';
 }
 
 # parent is cleaner, and in the Perl 5.10.1 / 5.12.0 core, but not earlier.
@@ -117,6 +117,11 @@ $_Config{'verbose'} = 0;
 my $_XS_MAXVAL = $_Config{'xs'}  ?  $_Config{'maxparam'}  :  -1;
 my $_HAVE_GMP = $_Config{'gmp'};
 
+# Infinity in Perl is rather O/S specific.
+our $_Infinity = 0+'inf';
+$_Infinity = 20**20**20 if 65535 > $_Infinity;   # E.g. Windows
+our $_Neg_Infinity = -$_Infinity;
+
 # Notes on how we're dealing with big integers:
 #
 #  1) if (ref($n) eq 'Math::BigInt')
@@ -146,7 +151,7 @@ sub prime_get_config {
 
   $config{'precalc_to'} = ($_Config{'xs'})
                         ? _get_prime_cache_size()
-                        : Math::Prime::Util::PP::_get_prime_cache_size;
+                        : Math::Prime::Util::PP::_get_prime_cache_size();
 
   return \%config;
 }
@@ -1429,9 +1434,9 @@ sub RiemannR {
 
 sub ExponentialIntegral {
   my($n) = @_;
-  return 0+'-inf' if $n == 0;
-  return 0        if $n == (0 + '-inf');
-  return 0+'inf'  if $n == (0 + 'inf');
+  return $_Neg_Infinity if $n == 0;
+  return 0              if $n == $_Neg_Infinity;
+  return $_Infinity     if $n == $_Infinity;
 
   return Math::Prime::Util::PP::ExponentialIntegral($n) if defined $bignum::VERSION || ref($n) eq 'Math::BigFloat';
   return Math::Prime::Util::PP::ExponentialIntegral($n) if !$_Config{'xs'};
@@ -1440,20 +1445,16 @@ sub ExponentialIntegral {
 
 sub LogarithmicIntegral {
   my($n) = @_;
-  return 0 if $n == 0;
-  return 0+'-inf' if $n == 1;
-  return 0+'inf'  if $n == (0 + 'inf');
+  return 0              if $n == 0;
+  return $_Neg_Infinity if $n == 1;
+  return $_Infinity     if $n == $_Infinity;
   croak("Invalid input to LogarithmicIntegral:  x must be >= 0") if $n <= 0;
 
   if ( defined $bignum::VERSION || ref($n) eq 'Math::BigFloat' ) {
     return Math::BigFloat->binf('-') if $n == 1;
     return Math::BigFloat->new('1.045163780117492784844588889194613136522615578151201575832909144075013205210359530172717405626383356306') if $n == 2;
   } else {
-    if ($n == 1) {
-      my $neg_infinity = 0+'-inf';
-      return (-9)**9**9 if $neg_infinity == 0;
-      return $neg_infinity;
-    }
+    return $_Neg_Infinity if $n == 1;
     return 1.045163780117492784844588889194613136522615578151 if $n == 2;
   }
   return Math::Prime::Util::PP::LogarithmicIntegral($n)
@@ -1484,7 +1485,7 @@ Math::Prime::Util - Utilities related to prime numbers, including fast sieves an
 
 =head1 VERSION
 
-Version 0.13
+Version 0.14
 
 
 =head1 SYNOPSIS
diff --git a/lib/Math/Prime/Util/MemFree.pm b/lib/Math/Prime/Util/MemFree.pm
index 3d37386..f7465a6 100644
--- a/lib/Math/Prime/Util/MemFree.pm
+++ b/lib/Math/Prime/Util/MemFree.pm
@@ -4,7 +4,7 @@ use warnings;
 
 BEGIN {
   $Math::Prime::Util::MemFree::AUTHORITY = 'cpan:DANAJ';
-  $Math::Prime::Util::MemFree::VERSION = '0.12';
+  $Math::Prime::Util::MemFree::VERSION = '0.14';
 }
 
 use base qw( Exporter );
@@ -44,7 +44,7 @@ Math::Prime::Util::MemFree - An auto-free object for Math::Prime::Util
 
 =head1 VERSION
 
-Version 0.12
+Version 0.14
 
 
 =head1 SYNOPSIS
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index ba1f96d..c105a13 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.13';
+  $Math::Prime::Util::PP::VERSION = '0.14';
 }
 
 # The Pure Perl versions of all the Math::Prime::Util routines.
@@ -35,6 +35,10 @@ my $_half_word = (~0 == 18446744073709551615) ? 4294967296 :    # 64-bit
                  (~0 ==           4294967295) ?      65536 :    # 32-bit
                  (~0 ==                   -1) ?   1000**10 :    # bignum
                                                          0 ;    # No idea
+# Infinity in Perl is rather O/S specific.
+our $_Infinity = 0+'inf';
+$_Infinity = 20**20**20 if 65535 > $_Infinity;   # E.g. Windows
+our $_Neg_Infinity = -$_Infinity;
 
 my $_precalc_size = 0;
 sub prime_precalc {
@@ -1429,9 +1433,9 @@ my $_const_li2 = 1.045163780117492784844588889194613136522615578151;
 
 sub ExponentialIntegral {
   my($x, $tol) = @_;
-  return 0+'-inf' if $x == 0;
-  return 0        if $x == (0 + '-inf');
-  return 0+'inf'  if $x == (0 + 'inf');
+  return $_Neg_Infinity if $x == 0;
+  return 0              if $x == $_Neg_Infinity;
+  return $_Infinity     if $x == $_Infinity;
   $tol = 1e-16 unless defined $tol;
   my $sum = 0.0;
   my($y, $t);
@@ -1507,9 +1511,9 @@ sub ExponentialIntegral {
 
 sub LogarithmicIntegral {
   my($x) = @_;
-  return 0 if $x == 0;
-  return 0+'-inf' if $x == 1;
-  return 0+'inf'  if $x == (0 + 'inf');
+  return 0              if $x == 0;
+  return $_Neg_Infinity if $x == 1;
+  return $_Infinity     if $x == $_Infinity;
   return $_const_li2 if $x == 2;
   croak "Invalid input to LogarithmicIntegral:  x must be > 0" if $x <= 0;
 
@@ -1682,7 +1686,7 @@ Math::Prime::Util::PP - Pure Perl version of Math::Prime::Util
 
 =head1 VERSION
 
-Version 0.13
+Version 0.14
 
 
 =head1 SYNOPSIS
diff --git a/lib/Math/Prime/Util/PrimeArray.pm b/lib/Math/Prime/Util/PrimeArray.pm
index f5e7395..a8002ed 100644
--- a/lib/Math/Prime/Util/PrimeArray.pm
+++ b/lib/Math/Prime/Util/PrimeArray.pm
@@ -4,7 +4,7 @@ use warnings;
 
 BEGIN {
   $Math::Prime::Util::PrimeArray::AUTHORITY = 'cpan:DANAJ';
-  $Math::Prime::Util::PrimeArray::VERSION = '0.12';
+  $Math::Prime::Util::PrimeArray::VERSION = '0.14';
 }
 
 # parent is cleaner, and in the Perl 5.10.1 / 5.12.0 core, but not earlier.
@@ -109,7 +109,7 @@ Math::Prime::Util::PrimeArray - A tied array for primes
 
 =head1 VERSION
 
-Version 0.12
+Version 0.14
 
 
 =head1 SYNOPSIS

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