Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Math::Prime::Util::GMP 0.03

    Download button

    No screenshots available
    Downloads: 85  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Dana Jacobsen | More programs
    Perl Artistic License / FREE
    July 16th, 2012, 23:58 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Math::Prime::Util::GMP description

    Utilities related to prime numbers and factoring, using GMP

    Math::Prime::Util::GMP is a set of utilities related to prime numbers, using GMP. This includes primality tests, getting primes in a range, and factoring.

    While it certainly can be used directly, the main purpose of this module is for Math::Prime::Util. That module will automatically load this if it is installed, greatly speeding up many of its operations on big numbers.

    Inputs and outputs for big numbers are via strings, so you do not need to use a bigint package in your program. However if you do use bigint, Perl will automatically convert input for you, so you do not have to stringify your numbers. This output however will be returned as either Perl scalars or strings. Math::Prime::Util tries to reconvert all strings back into the callers bigint type if possible.

    SYNOPSIS

     use Math::Prime::Util::GMP ':all';
     my $n = "115792089237316195423570985008687907853269984665640564039457584007913129639937";

     # This doesn't impact the operation of the module at all, but does let you
     # enter big number arguments directly as well as enter (e.g.): 2**2048 + 1.
     use bigint;

     # is_prob_prime returns 0 for composite, 2 for prime, and 1 for maybe prime
     say "$n is ", qw(composite prob_prime def_prime)[is_prob_prime($n)];

     # is_prime currently is the same -- a BPSW test is used.
     say "$n is prime" if is_prime($n);

     # Run a series of Miller-Rabin tests
     say "$n is a prime or spsp-2/7/61" if is_strong_pseudoprime($n, 2, 7, 61);

     # See if $n is a strong Lucas-Selfridge pseudoprime
     say "$n is a prime or slpsp" if is_strong_lucas_pseudoprime($n);

     # Return array reference to primes in a range.
     my $aref = primes( 10 ** 200, 10 ** 200 + 10000 );

     $next = next_prime($n); # next prime > n

     $prev = prev_prime($n); # previous prime < n
     
     # Find prime factors of big numbers
     @factors = factor(5465610891074107968111136514192945634873647594456118359804135903459867604844945580205745718497);

     # Finer control over factoring.
     # These stop after finding one factor or exceeding their limit.
     @factors = prho_factor($n);
     @factors = pbrent_factor($n);
     @factors = pminus1_factor($n);
     @factors = holf_factor($n);
     @factors = squfof_factor($n);



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    prime numbers | Perl module | Perl | GMP | prime

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM