Math-Prime-Util
view release on metacpan or search on metacpan
- Reworked some factoring code.
- Remove ISAAC (Perl and C) since we use ChaCha.
- Each thread allocs a new const array again instead of sharing.
0.68 2017-10-19
[API Changes]
- forcomb with one argument iterates over the power set, so k=0..n
instead of k=n. The previous behavior was undocumented. The new
behavior matches Pari/GP (forsubset) and Perl6 (combinations).
[ADDED]
- factorialmod(n,m) n! mod m calculated efficiently
- is_fundamental(d) true if d a fundamental discriminant
[FUNCTIONALITY AND PERFORMANCE]
- Unknown bigint classes no longer return two values after objectify.
Thanks to Daniel Èuteu for finding this.
- Using lastfor inside a formultiperm works correctly now.
- randperm a little faster for k < n cases, and can handle big n
values without running out of memory as long as k << n.
E.g. 5000 random native ints without dups: @r = randperm(~0,5000);
- forpart with primes pulls min/max values in for a small speedup.
- forderange 10-20% faster.
- hammingweight for bigints 3-8x faster.
- Add Math::GMPq and Math::AnyNum as possible bigint classes. Inputs
of these types will be relied on to stringify correctly, and if this
results in an integer string, to intify correctly. This should give
a large speedup for these types.
- Factoring native integers is 1.2x - 2x faster. This is due to a
number of changes.
- Add Lehman factoring core. Since this is not exported or used by
default, the API for factor_lehman may change.
- All new Montgomery math. Uses mulredc asm from Ben Buhrow.
Faster and smaller. Most primality and factoring code 10% faster.
- Speedup for factoring by running more Pollard-Rho-Brent, revising
SQUFOF, updating HOLF, updating recipe.
0.67 2017-09-23
[ADDED]
- lastfor stops forprimes (etc.) iterations
- is_square(n) returns 1 if n is a perfect square
- is_polygonal(n,k) returns 1 if n is a k-gonal number
[FUNCTIONALITY AND PERFORMANCE]
- shuffle prototype is @ instead of ;@, so matches List::Util.
- On Perl 5.8 and earlier we will call PP instead of trying
direct-to-GMP. Works around a bug in XS trying to turn the
result into an object where 5.8.7 and earlier gets lost.
- We create more const integers, which speeds up common uses of
permutations.
- CSPRNG now stores context per-thread rather than using a single
mutex-protected context. This speeds up anything using random
numbers a fair amount, especially with threaded Perls.
- With the above two optimizations, randperm(144) is 2.5x faster.
- threading test has threaded srand/irand test added back in, showing
context is per-thread. Each thread gets its own sequence and calls
to srand/csrand and using randomness doesn't impact other threads.
0.66 2017-09-12
[ADDED]
- random_semiprime random n-bit semiprime (even split)
- random_unrestricted_semiprime random n-bit semiprime
- forderange { ... } n derangements iterator
- numtoperm(n,k) returns kth permutation of n elems
- permtonum([...]) returns rank of permutation array ref
- randperm(n[,k]) random permutation of n elements
- shuffle(...) random permutation of an array
[FUNCTIONALITY AND PERFORMANCE]
- Rewrite sieve marking based on Kim Walisch's new simple mod-30 sieve.
Similar in many ways to my old code, but this is simpler and faster.
- is_pseudoprime, is_euler_pseudoprime, is_strong_pseudoprime changed to
better handle the unusual case of base >= n.
- Speedup for is_carmichael.
- is_frobenius_underwood_pseudoprime checks for jacobi == 0. Faster.
- Updated Montgomery inverse from Robert Gerbicz.
- Tighter nth prime bounds for large inputs from Axler 2017-06.
Redo Ramanujan bounds since they're based on nth prime bounds.
- chinese objectifies result (i.e. big results are bigints).
- Internal support for Baillie-Wagstaff (pg 1402) extra Lucas tests.
- More standardized Lucas parameter selection. Like other tests and the
1980 paper, checks jacobi(D) in the loop, not gcd(D).
( run in 0.663 second using v1.01-cache-2.11-cpan-71847e10f99 )