Perl (XS) module implementing prime number utilities, including sieves
Perl C C++ XS Python
Latest commit 56a1b0a Oct 31, 2016 @danaj Use GMP LambertW if possible
Permalink
Failed to load latest commit information.
bench Update some old benchmarks Aug 31, 2016
bin Use GMP sieve_twin_primes function Aug 28, 2015
examples Comments for AKS. Turn off PFGW by default for example gap verify Jun 15, 2016
inc/Devel Bump Devel::CheckLib version May 21, 2016
lib Use GMP LambertW if possible Oct 31, 2016
t Fix PP is_power with -1 Oct 13, 2016
xt Add prime count table creation script Aug 30, 2016
.gitignore Simple prime cluster sieve Sep 27, 2015
.travis.yml Try a different travis config for GMP Dec 19, 2015
Changes Use GMP LambertW if possible Oct 31, 2016
LICENSE Bump version and year for release Jan 3, 2016
MANIFEST Add prime count table creation script Aug 30, 2016
Makefile.PL Update todo and GMP recommended version Oct 10, 2016
README Update for release Jul 24, 2016
TODO Update todo and GMP recommended version Oct 10, 2016
XS.xs Fix RiemannZeta PP post-process of GMP result Oct 27, 2016
aks.c Small tuning change Aug 30, 2016
aks.h Add Khashin's Frobenius test Jun 14, 2015
cache.c For memfree, just return if mutexes are not init. Jun 1, 2015
cache.h Standalone compilation Oct 27, 2014
constants.h Add is_ramanujan_prime Apr 24, 2015
cpanfile Updae Exporter version Jul 19, 2015
factor.c Updates from testing Sep 16, 2016
factor.h znlog updates; prev_prime(2) and nth_prime(0) return undef; is_quasi_… Apr 18, 2016
lehmer.c UL -> UVCONST Oct 5, 2015
lehmer.h Don't compile Legendre/Meissel/Lehmer/LMOS prime counts by default Dec 31, 2013
lmo.c Fix vecprod negative overflow. Work around bigint/int() bug. Speedup … Aug 30, 2016
lmo.h Don't compile Legendre/Meissel/Lehmer/LMOS prime counts by default Dec 31, 2013
montmath.h Add missing include Sep 16, 2016
mulmod.h Minor changes to make Montgomery code less tied to primality code Aug 31, 2016
multicall.h Add forprimes multicall May 21, 2013
ppport.h Update ppport.h Sep 5, 2015
primality.c Minor changes to make Montgomery code less tied to primality code Aug 31, 2016
primality.h Minor changes to make Montgomery code less tied to primality code Aug 31, 2016
prime_count_tables.h Redo prime count tables. Move to header file. Add Lah numbers. Aug 30, 2016
ptypes.h Minor changes to make Montgomery code less tied to primality code Aug 31, 2016
sieve.c Minor changes to make Montgomery code less tied to primality code Aug 31, 2016
sieve.h Simple prime cluster sieve Sep 27, 2015
sieve_cluster.c Allocation changes for cluster sieve Apr 18, 2016
sieve_cluster.h Fast cluster sieve Sep 28, 2015
util.c Fix RiemannZeta PP post-process of GMP result Oct 27, 2016
util.h Redo prime count tables. Move to header file. Add Lah numbers. Aug 30, 2016

README

Math::Prime::Util version 0.59

A module for number theory in Perl.  This includes prime sieving, primality
tests, primality proofs, integer factoring, counts / bounds / approximations
for primes, nth primes, and twin primes, random prime generation,
and much more.

The default sieving and factoring are intended to be the fastest on CPAN.
Current measurements show it is faster than:
  Math::Prime::XS
  Math::Prime::FastSieve
  Math::Factor::XS
  Math::Big
  Math::Big::Factors
  Math::Factoring
  Math::Primality
  Math::Prime::TiedArray
  Crypt::Primes
  Math::ModInt::ChineseRemainder
For non-bignums, it is typically faster than Math::Pari (and doesn't
require Pari to be installed).  With Math::Prime::Util::GMP installed
it is usually faster than Math::Pari for bigints.


SYNOPSIS

  use Math::Prime::Util qw/primes/;

  # Get a big array reference of many primes
  my $aref = primes( 100_000_000 );

  # All the primes between 5k and 10k inclusive in a regular array
  my @primes = @{ primes( 5_000, 10_000 ) };

See the POD module documentation for examples and more information on all the
methods included.


INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

You will need a C compiler compatible with the compiler used to build Perl.
Since the routines are meant to be used from Perl, the data types will match
the ones used with the Perl you are installing for.  This means a 32-bit Perl
running on a 64-bit machine will result in a 32-bit library.


DEPENDENCIES

Perl 5.6.2 or later (5.8 or later is preferred).

Bytes::Random::Secure 0.23 or later.


COPYRIGHT AND LICENCE

Copyright (C) 2011-2016 by Dana Jacobsen <dana@acm.org>

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