|go ahead... be a heretic|
Re^5: Algorithm for cancelling common factors between two lists of multiplicandsby QM (Parson)
|on Aug 10, 2005 at 22:46 UTC||Need Help??|
Here's a benchmark for Math::Big::Factors wheels of orders 5-7:
and for factors_wheel of numbers near 32 bits, using an order 7 wheel:
Note that 4294967291 is prime, 4294967293 has 2 large factors, and 4294967295 has 5 factors, the largest of which is 2**16+1.
For 4294967291, and wheel orders 5-7:
In all fairness, I should probably mention that I've customized my own version of Math::Big::Factors to Memoize results where possible, and to reduce the calls to Math::BigInt::new() for constants.
Note that factors_wheel creates a new wheel every time (what a shame), instead of requiring a wheel reference be passed in. Caching wheel goes a little way in correcting this, without changing the interface.
You might also consider avoiding the use of Math::BigInt where possible, as you don't need numbers that big.
Now, back to the question at hand. For numbers near 2**32, factoring a prime number seems to take 150 times longer than creating the order 7 wheel. Creating the order 6 wheel is considerably faster, and so is the factoring based on that wheel.
I'm not sure where the breakpoint is for order 7 wheels. A casual search hints that it is very large.