GNU.WIKI: The GNU/Linux Knowledge Base

  [HOME] [PHP Manual] [HowTo] [ABS] [MAN1] [MAN2] [MAN3] [MAN4] [MAN5] [MAN6] [MAN7] [MAN8] [MAN9]

  [0-9] [Aa] [Bb] [Cc] [Dd] [Ee] [Ff] [Gg] [Hh] [Ii] [Jj] [Kk] [Ll] [Mm] [Nn] [Oo] [Pp] [Qq] [Rr] [Ss] [Tt] [Uu] [Vv] [Ww] [Xx] [Yy] [Zz]


       Math::Prime::Util::PP - Pure Perl version of Math::Prime::Util


       Version 0.42


       The functionality is basically identical to Math::Prime::Util, as this
       module is just the Pure Perl implementation.  This documentation will
       only note differences.

         # Normally you would just import the functions you are using.
         # Nothing is exported by default.
         use Math::Prime::Util ':all';


       Pure Perl implementations of prime number utilities that are normally
       handled with XS or GMP.  Having the Perl implementations (1) provides
       examples, (2) allows the functions to run even if XS isn't available,
       and (3) gives big number support if Math::Prime::Util::GMP isn't
       available.  This is a subset of Math::Prime::Util's functionality.

       All routines should work with native integers or multi-precision
       numbers.  To enable big numbers, use bigint or bignum:

           use bigint;
           say prime_count_approx(1000000000000000000000000)'
           # says 18435599767347543283712

       This is still experimental, and some functions will be very slow.  The
       Math::Prime::Util::GMP module has much faster versions of many of these
       functions.  Alternately, Math::Pari has a lot of these types of


       Takes a single integer input and returns the Euler totient.

       Takes two values defining a range "low" to "high" and returns an array
       with the totient of each value in the range, inclusive.

       Takes a single integer input and returns the Moebius function.

       Takes two values defining a range "low" to "high" and returns an array
       with the Moebius function of each value in the range, inclusive.


       The SQUFOF and Fermat factoring algorithms are not implemented yet.

       Some of the prime methods use more memory than they should, as the
       segmented sieve is not properly used in "primes" and "prime_count".


       Performance compared to the XS/C code is quite poor for many
       operations.  Some operations that are relatively close for small and
       medium-size values:

         next_prime / prev_prime
         is_prime / is_prob_prime
         ExponentialIntegral / LogarithmicIntegral / RiemannR

       Operations that are slower include:

         random_prime / random_ndigit_prime
         factor / factor_exp / divisors

       Performance improvement in this code is still possible.  The prime
       sieve is over 2x faster than anything I was able to find online, but it
       is still has room for improvement.

       Math::Prime::Util::GMP offers "C+XS+GMP" support for most of the
       important functions, and will be vastly faster for most operations.  If
       you install that module, Math::Prime::Util will load it automatically,
       meaning you should not have to think about what code is actually being
       used (C, GMP, or Perl).

       Memory use will generally be higher for the PP code, and in some cases
       much higher.  Some of this may be addressed in a later release.

       For small values (e.g. primes and prime counts under 10M) most of this
       will not matter.





       Dana Jacobsen <>


       Copyright 2012-2014 by Dana Jacobsen <>

       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

  All copyrights belong to their respective owners. Other content (c) 2014-2018, GNU.WIKI. Please report site errors to
Page load time: 0.135 seconds. Last modified: November 04 2018 12:49:43.