]> git.ipfire.org Git - thirdparty/coreutils.git/commit
factor: switch from mp to single when doable
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 4 Jun 2025 17:12:29 +0000 (10:12 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 00:12:39 +0000 (17:12 -0700)
commit831623ba6683d8a8254b0ebcb1ee98191729a190
tree24fffc8604d63041101dc75d58859a5b8f0f6eaa
parent845f3a6158be04d9cfa30db14635c2cd471312e7
factor: switch from mp to single when doable

This significantly improves performance when a number exceeds
2**(W_TYPE_SIZE - 1) and is the product of a prime less than
FIRST_OMITTED_PRIME and another prime less than 2**(W_TYPE_SIZE - 1).
On my platform, for example, it doubled the speed of factoring
4999 * (2**128 - 159).
* src/factor.c (mp_size, mp_finish_in_single): New functions.
(mp_factor_using_division, mp_factor_using_pollard_rho):
Finish using single precision when possible.
* tests/factor/factor.pl (lt-5000-times-128-bit): New test.
src/factor.c
tests/factor/factor.pl