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

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

commit b16de00abad773a9cf7a578993bf3d0d023da43e
Author: Dana Jacobsen <d...@acm.org>
Date:   Wed Jan 22 10:49:41 2014 -0800

    More movement to PP front end
---
 lib/Math/Prime/Util.pm      |  26 ---------
 lib/Math/Prime/Util/PP.pm   |  31 ++---------
 lib/Math/Prime/Util/PPFE.pm | 129 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 52 deletions(-)

diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index 74bc698..91ca2a8 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -67,13 +67,11 @@ BEGIN {
   # We could alternately use Config's $Config{uvsize} for MAXBITS
   use constant OLD_PERL_VERSION=> $] < 5.008;
   use constant MPU_MAXBITS     => (~0 == 4294967295) ? 32 : 64;
-  use constant MPU_64BIT       => MPU_MAXBITS == 64;
   use constant MPU_32BIT       => MPU_MAXBITS == 32;
   use constant MPU_MAXPARAM    => MPU_32BIT ? 4294967295 : 
18446744073709551615;
   use constant MPU_MAXDIGITS   => MPU_32BIT ?         10 : 20;
   use constant MPU_MAXPRIME    => MPU_32BIT ? 4294967291 : 
18446744073709551557;
   use constant MPU_MAXPRIMEIDX => MPU_32BIT ?  203280221 :   
425656284035217743;
-  use constant MPU_MAXNATIVE   => OLD_PERL_VERSION ? 999999999999999 : ~0;
   use constant UVPACKLET       => MPU_32BIT ?        'L' : 'Q';
 
   eval {
@@ -94,41 +92,17 @@ BEGIN {
     # Load PP front end code
     require Math::Prime::Util::PPFE;
 
-    *_validate_num = \&Math::Prime::Util::PP::_validate_num;
-    *is_lucas_pseudoprime=\&Math::Prime::Util::PP::is_lucas_pseudoprime;
-    
*is_strong_lucas_pseudoprime=\&Math::Prime::Util::PP::is_strong_lucas_pseudoprime;
-    
*is_extra_strong_lucas_pseudoprime=\&Math::Prime::Util::PP::is_extra_strong_lucas_pseudoprime;
-    
*is_almost_extra_strong_lucas_pseudoprime=\&Math::Prime::Util::PP::is_almost_extra_strong_lucas_pseudoprime;
-    
*is_frobenius_underwood_pseudoprime=\&Math::Prime::Util::PP::is_frobenius_underwood_pseudoprime;
-    *is_aks_prime  =\&Math::Prime::Util::PP::is_aks_prime;
     *next_prime    = \&Math::Prime::Util::_generic_next_prime;
     *prev_prime    = \&Math::Prime::Util::_generic_prev_prime;
     *exp_mangoldt  = \&Math::Prime::Util::_generic_exp_mangoldt;
     *prime_count   = \&Math::Prime::Util::_generic_prime_count;
     *divisor_sum   = \&Math::Prime::Util::_generic_divisor_sum;
-    *legendre_phi  = \&Math::Prime::Util::PP::legendre_phi;
-    *gcd           = \&Math::Prime::Util::PP::gcd;
-    *lcm           = \&Math::Prime::Util::PP::lcm;
     *factor        = \&Math::Prime::Util::_generic_factor;
     *factor_exp    = \&Math::Prime::Util::_generic_factor_exp;
     *divisors      = \&Math::Prime::Util::_generic_divisors;
     *forprimes     = sub (&$;$) { _generic_forprimes(@_); }; ## no critic 
qw(ProhibitSubroutinePrototypes)
     *forcomposites = sub (&$;$) { _generic_forcomposites(@_); }; ## no critic 
qw(ProhibitSubroutinePrototypes)
     *fordivisors   = sub (&$) { _generic_fordivisors(@_); }; ## no critic 
qw(ProhibitSubroutinePrototypes)
-
-    *_prime_memfreeall = \&Math::Prime::Util::PP::_prime_memfreeall;
-    *prime_memfree  = \&Math::Prime::Util::PP::prime_memfree;
-    *prime_precalc  = \&Math::Prime::Util::PP::prime_precalc;
-
-    # These probably shouldn't even be aliased, as they're not public
-    *trial_factor   = \&Math::Prime::Util::PP::trial_factor;
-    *fermat_factor  = \&Math::Prime::Util::PP::fermat_factor;
-    *holf_factor    = \&Math::Prime::Util::PP::holf_factor;
-    *squfof_factor  = \&Math::Prime::Util::PP::squfof_factor;
-    *pbrent_factor  = \&Math::Prime::Util::PP::pbrent_factor;
-    *prho_factor    = \&Math::Prime::Util::PP::prho_factor;
-    *pminus1_factor = \&Math::Prime::Util::PP::pminus1_factor;
-    *pplus1_factor  = \&Math::Prime::Util::PP::pminus1_factor;   # TODO: 
implement PP p+1.
   };
 
   # aliases for deprecated names.  Will eventually be removed.
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index 0bc11d9..4317ad8 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -1822,8 +1822,6 @@ sub lucas_sequence {
 
 sub is_lucas_pseudoprime {
   my($n) = @_;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
 
   return 0+($n >= 2) if $n < 4;
   return 0 if ($n % 2) == 0 || _is_perfect_square($n);
@@ -1838,8 +1836,6 @@ sub is_lucas_pseudoprime {
 
 sub is_strong_lucas_pseudoprime {
   my($n) = @_;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
 
   return 0+($n >= 2) if $n < 4;
   return 0 if ($n % 2) == 0 || _is_perfect_square($n);
@@ -1869,8 +1865,6 @@ sub is_strong_lucas_pseudoprime {
 
 sub is_extra_strong_lucas_pseudoprime {
   my($n) = @_;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
 
   return 0+($n >= 2) if $n < 4;
   return 0 if ($n % 2) == 0 || _is_perfect_square($n);
@@ -1901,13 +1895,7 @@ sub is_extra_strong_lucas_pseudoprime {
 
 sub is_almost_extra_strong_lucas_pseudoprime {
   my($n, $increment) = @_;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
-  if (defined $increment) {
-    _validate_positive_integer($increment, 1, 256);
-  } else {
-    $increment = 1;
-  }
+  $increment = 1 unless defined $increment;
 
   return 0+($n >= 2) if $n < 4;
   return 0 if ($n % 2) == 0 || _is_perfect_square($n);
@@ -1946,8 +1934,6 @@ sub is_almost_extra_strong_lucas_pseudoprime {
 
 sub is_frobenius_underwood_pseudoprime {
   my($n) = @_;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
   return 0+($n >= 2) if $n < 4;
   return 0 if ($n % 2) == 0 || _is_perfect_square($n);
 
@@ -2064,11 +2050,7 @@ sub _test_anr {
 
 sub is_aks_prime {
   my $n = shift;
-  return 0 if defined $n && int($n) < 0;
-  _validate_positive_integer($n);
-
-  return 0 if $n < 2;
-  return 0 if _is_perfect_power($n);
+  return 0 if $n < 2 || _is_perfect_power($n);
 
   my($log2n, $limit);
   if ($n > 2**48) {
@@ -2133,6 +2115,9 @@ sub _basic_factor {
     while ( !($_[0] % 3) ) { push @factors, 3;  $_[0] = int($_[0] / 3); }
     while ( !($_[0] % 5) ) { push @factors, 5;  $_[0] = int($_[0] / 5); }
   } else {
+    # Without this, the bdivs will try to convert the results to BigFloat
+    # and lose precision.
+    $_[0]->upgrade(undef) if ref($_[0]) && $_[0]->upgrade();
     if (!Math::BigInt::bgcd($_[0], B_PRIM235)->is_one) {
       while ( $_[0]->is_even)   { push @factors, 2;  $_[0]->brsft(BONE); }
       foreach my $div (3, 5) {
@@ -2327,7 +2312,6 @@ sub squfof_factor { trial_factor(@_) }
 
 sub prho_factor {
   my($n, $rounds, $pa) = @_;
-  _validate_positive_integer($n);
   $rounds = 4*1024*1024 unless defined $rounds;
   $pa = 3 unless defined $pa;
 
@@ -2397,7 +2381,6 @@ sub prho_factor {
 
 sub pbrent_factor {
   my($n, $rounds, $pa) = @_;
-  _validate_positive_integer($n);
   $rounds = 4*1024*1024 unless defined $rounds;
   $pa = 3 unless defined $pa;
 
@@ -2478,7 +2461,6 @@ sub pbrent_factor {
 
 sub pminus1_factor {
   my($n, $B1, $B2) = @_;
-  _validate_positive_integer($n);
 
   my @factors = _basic_factor($n);
   return @factors if $n < 4;
@@ -2627,7 +2609,6 @@ sub pminus1_factor {
 
 sub holf_factor {
   my($n, $rounds, $startrounds) = @_;
-  _validate_positive_integer($n);
   $rounds = 64*1024*1024 unless defined $rounds;
   $startrounds = 1 unless defined $startrounds;
   $startrounds = 1 if $startrounds < 1;
@@ -2674,7 +2655,6 @@ sub holf_factor {
 
 sub fermat_factor {
   my($n, $rounds) = @_;
-  _validate_positive_integer($n);
   $rounds = 64*1024*1024 unless defined $rounds;
 
   my @factors = _basic_factor($n);
@@ -2724,7 +2704,6 @@ sub fermat_factor {
 
 sub ecm_factor {
   my($n, $B1, $B2, $ncurves) = @_;
-  _validate_positive_integer($n);
 
   my @factors = _basic_factor($n);
   return @factors if $n < 4;
diff --git a/lib/Math/Prime/Util/PPFE.pm b/lib/Math/Prime/Util/PPFE.pm
index bf0ea9a..98ed907 100644
--- a/lib/Math/Prime/Util/PPFE.pm
+++ b/lib/Math/Prime/Util/PPFE.pm
@@ -6,6 +6,10 @@ use warnings;
 use Math::Prime::Util::PP;
 
 *_validate_num = \&Math::Prime::Util::PP::_validate_num;
+*_prime_memfreeall = \&Math::Prime::Util::PP::_prime_memfreeall;
+*prime_memfree  = \&Math::Prime::Util::PP::prime_memfree;
+*prime_precalc  = \&Math::Prime::Util::PP::prime_precalc;
+
 
 sub mertens {
   my($n) = @_;
@@ -87,6 +91,7 @@ sub prime_count_approx {
   return Math::Prime::Util::PP::prime_count_approx($n);
 }
   
+
 sub is_prime {
   my($n) = @_;
   return 0 if defined $n && int($n) < 0;
@@ -113,6 +118,45 @@ sub is_strong_pseudoprime {
   croak "No bases given to miller_rabin" unless @bases;
   return Math::Prime::Util::PP::is_strong_pseudoprime($n, @bases);
 }
+sub is_lucas_pseudoprime {
+  my($n) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::is_lucas_pseudoprime($n);
+}
+sub is_strong_lucas_pseudoprime {
+  my($n) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::is_strong_lucas_pseudoprime($n);
+}
+sub is_extra_strong_lucas_pseudoprime {
+  my($n) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::is_extra_strong_lucas_pseudoprime($n);
+}
+sub is_almost_extra_strong_lucas_pseudoprime {
+  my($n, $increment) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  if (defined $increment) { _validate_positive_integer($increment, 1, 256);
+  } else                  { $increment = 1; }
+  return Math::Prime::Util::PP::is_almost_extra_strong_lucas_pseudoprime($n, 
$increment);
+}
+sub is_frobenius_underwood_pseudoprime {
+  my($n) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::is_frobenius_underwood_pseudoprime($n);
+}
+sub is_aks_prime {
+  my($n) = @_;
+  return 0 if defined $n && int($n) < 0;
+  _validate_positive_integer($n);
+  return Math::Prime::Util::PP::is_aks_prime($n);
+}
+
 
 sub kronecker {
   my($a, $b) = @_;
@@ -146,4 +190,89 @@ sub znprimroot {
   return Math::Prime::Util::PP::znprimroot($n);
 }
 
+sub trial_factor {
+  my($n, $maxlim) = @_;
+  _validate_positive_integer($n);
+  if (defined $maxlim) {
+    _validate_positive_integer($maxlim);
+    return Math::Prime::Util::PP::trial_factor($n, $maxlim);
+  }
+  return Math::Prime::Util::PP::trial_factor($n);
+}
+sub fermat_factor {
+  my($n, $rounds) = @_;
+  _validate_positive_integer($n);
+  if (defined $rounds) {
+    _validate_positive_integer($rounds);
+    return Math::Prime::Util::PP::fermat_factor($n, $rounds);
+  }
+  return Math::Prime::Util::PP::fermat_factor($n);
+}
+sub holf_factor {
+  my($n, $rounds) = @_;
+  _validate_positive_integer($n);
+  if (defined $rounds) {
+    _validate_positive_integer($rounds);
+    return Math::Prime::Util::PP::holf_factor($n, $rounds);
+  }
+  return Math::Prime::Util::PP::holf_factor($n);
+}
+sub squfof_factor {
+  my($n, $rounds) = @_;
+  _validate_positive_integer($n);
+  if (defined $rounds) {
+    _validate_positive_integer($rounds);
+    return Math::Prime::Util::PP::squfof_factor($n, $rounds);
+  }
+  return Math::Prime::Util::PP::squfof_factor($n);
+}
+sub pbrent_factor {
+  my($n, $rounds, $pa) = @_;
+  _validate_positive_integer($n);
+  if (defined $rounds) { _validate_positive_integer($rounds);
+  } else               { $rounds = 4*1024*1024; }
+  if (defined $pa    ) { _validate_positive_integer($pa);
+  } else               { $pa = 3; }
+  return Math::Prime::Util::PP::pbrent_factor($n, $rounds, $pa);
+}
+sub prho_factor {
+  my($n, $rounds, $pa) = @_;
+  _validate_positive_integer($n);
+  if (defined $rounds) { _validate_positive_integer($rounds);
+  } else               { $rounds = 4*1024*1024; }
+  if (defined $pa    ) { _validate_positive_integer($pa);
+  } else               { $pa = 3; }
+  return Math::Prime::Util::PP::prho_factor($n, $rounds, $pa);
+}
+sub pminus1_factor {
+  my($n, $B1, $B2) = @_;
+  _validate_positive_integer($n);
+  _validate_positive_integer($B1) if defined $B1;
+  _validate_positive_integer($B2) if defined $B2;
+  Math::Prime::Util::PP::pminus1_factor($n, $B1, $B2);
+}
+*pplus1_factor = \&pminus1_factor;
+sub ecm_factor {
+  my($n, $B1, $B2, $ncurves) = @_;
+  _validate_positive_integer($n);
+  _validate_positive_integer($B1) if defined $B1;
+  _validate_positive_integer($B2) if defined $B2;
+  _validate_positive_integer($ncurves) if defined $ncurves;
+  Math::Prime::Util::PP::ecm_factor($n, $B1, $B2, $ncurves);
+}
+
+sub gcd {
+  return Math::Prime::Util::PP::gcd(@_);
+}
+sub lcm {
+  return Math::Prime::Util::PP::lcm(@_);
+}
+
+sub legendre_phi {
+  my($x, $a) = @_;
+  _validate_positive_integer($x);
+  _validate_positive_integer($a);
+  return Math::Prime::Util::PP::legendre_phi($x, $a);
+}
+
 1;

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