![]() |
|
|
#1 |
|
Aug 2002
Buenos Aires, Argentina
2×683 Posts |
Please correct me if I'm wrong, because I have not programmed FFT.
The main loop of LL proceeds by squaring the number and subtracting 2 mod 2p-1. The square is done by peforming two transforms, a convolution and an inverse transform using IBDWT. I think that by using Fermat tests (in base 3 for example), where only exponentiations are needed, we could eliminate the need for transforms and inverse transforms. So only convolutions are done in the main loop which are a lot faster. Then we could perform LL only for the pseudoprimes (a tiny fraction of the tests). Is this approach correct? |
|
|
|
|
|
#2 | ||
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
1C3516 Posts |
I'm assuming you mean this: http://en.wikipedia.org/wiki/Fermat_primality_test
Note two things: First, you must take a^(x-1), where x itself is 2^p-1 for large p. Not a smart idea. Second: How do you do an exponentiation? Quote:
The LL test with FFT muls has complexity O(p2 × log p × log log p), which is about the same as the same as the Fermat test once you substitute log n~p (and the LLT is deterministic). You do exponentiation with lots of squaring and multiplication. After all, exponentiation is repeated multiplications by definition, and the LL test is already down to the relatively cheap p-2 squarings per test. Quote:
(I'm not confident of this last part, but it's possible that the LL test can be derived from the Fermat test with base 2 or something, and some of the specific algorithms for exponentiation.) PS "only convolutions" is meaningless with respect to multiplication without doing a transform. It's like saying 6235*4865 == 6*4 2*8 3*6 5*5 == 24 16 18 25 == (with carrying) 25805, which is patently not the actual product of 30333275. Last fiddled with by Dubslow on 2012-08-13 at 13:38 |
||
|
|
|
|
|
#3 |
|
Aug 2002
Buenos Aires, Argentina
25268 Posts |
My idea is to perform one transform at the beginning, then perform the convolutions for each loop and then the inverse transform at the end. I do not want to reduce the number of multiplications but the timing for each multiplication.
Since multiple convolutions will generate very big numbers, we could separate the exponent from the mantissa. Edit: I do not know if this approach would work because of floating point approximation errors. Maybe we could do inverse and direct transforms every few iterations. Last fiddled with by alpertron on 2012-08-13 at 14:25 |
|
|
|
|
|
#4 |
|
Jun 2003
2·3·7·112 Posts |
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gcc optimization/intrinsics | R.D. Silverman | Factoring | 12 | 2015-09-15 08:51 |
| Program optimization | henryzz | Programming | 17 | 2012-09-26 13:21 |
| Size optimization | Sleepy | Msieve | 14 | 2011-10-20 10:27 |
| NFS Optimization | R.D. Silverman | Factoring | 91 | 2010-01-24 20:48 |
| ASM Optimization | Cyclamen Persicum | Hardware | 4 | 2004-05-26 07:51 |