Perl (XS) module implementing prime number utilities, including sieves
Perl C XS Other
Permalink
Failed to load latest commit information.
bench
bin
examples Add new times on more recent machines Feb 11, 2018
inc/Devel Newest ppport and checklib Nov 8, 2017
lib forfactored uses complete read-only return array, saves quite a bit o… Feb 14, 2018
t Tests added for forfactored and forsquarefree Feb 12, 2018
xt Some big circular primes were added, limit the test amount Jan 9, 2018
.gitignore git should ignore entropy .o file Sep 11, 2017
.travis.yml Remove Math::MPFR in favor of our GMP backend Nov 29, 2017
Changes
LICENSE Bump version and year for release Jan 3, 2016
MANIFEST
Makefile.PL Bump version Dec 2, 2017
README Bump version Dec 2, 2017
TODO Refactor of factor loop Feb 21, 2018
XS.xs Use factor_one in sieve_range, still not sieving but better than full… Feb 28, 2018
aks.c
aks.h
cache.c New sieve Jul 28, 2017
cache.h
chacha.c Add correct argument for 32-bit use Sep 17, 2017
chacha.h Move CSPRNG to per-thread context and remove locks Sep 15, 2017
constants.h Add is_ramanujan_prime Apr 24, 2015
cpanfile
csprng.c Remove ISAAC, both C and Perl Nov 7, 2017
csprng.h
entropy.c Fallback entropy using timers Sep 6, 2017
entropy.h Move entropy_bytes, srand, csrand to XS Aug 24, 2017
factor.c Refactor of factor loop Feb 21, 2018
factor.h Add internal factor_one. Use cube root sieve in forfactored / forsqua… Feb 14, 2018
lehmer.c
lehmer.h Internal: Rename _XS_*_pi functions Apr 20, 2017
lmo.c Internal: Rename _XS_*_pi functions Apr 20, 2017
lmo.h Internal: Rename _XS_*_pi functions Apr 20, 2017
montmath.h Split out 63-bit and 64-bit mulredc Oct 13, 2017
mulmod.h Don't force memory access for mulmod asm. Faster and smaller. Oct 15, 2017
multicall.h Add forprimes multicall May 21, 2013
ppport.h
primality.c
primality.h Split off 32-bit single-base MR to new function Nov 7, 2017
prime_count_tables.h Fix incorrect prime_count(a,b) for a=3..7 Nov 20, 2017
prime_nth_count.c Comments in prime_nth_count and BENCH_SEGCOUNT changes segment prime … Feb 8, 2018
prime_nth_count.h
ptypes.h Look for __SIZEOF_128__ regardless of GNUC and architecture Dec 2, 2017
ramanujan_primes.c Update ramanujan upper/lower tables for prime_count update Dec 1, 2017
ramanujan_primes.h
random_prime.c Move CSPRNG to per-thread context and remove locks Sep 15, 2017
random_prime.h
sieve.c Fix overflow on huge sieves Jan 31, 2018
sieve.h Refactor some sieve code, make a segment partial sieve for later use Dec 1, 2017
sieve_cluster.c
sieve_cluster.h
threadlock.h Move some thread logic to its own include file Apr 3, 2017
util.c
util.h Untie prime_nth_count and lmo from rest of code Nov 9, 2017

README

Math::Prime::Util version 0.70

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::Tiny 1.002 or later.


COPYRIGHT AND LICENCE

Copyright (C) 2011-2017 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.