You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few tricks that may speed up the Lucas test:
Crandall & Pomerance1, after Algorithm 3.6.7 (Lucas chain), provide some ways to reduce the general (P, Q) Lucas sequence to (P', 1) which may eliminate some multiplications.
Baillie et al2, in Eqs 13-18, give an alternative way to calculate the Lucas sequence to what we use, which generates U_k in addition to V_k, which means we don't need to calculate U_k via modular inverse. It does require more multiplications though. Need to test if it leads to the performance improvement.
Footnotes
R. Crandall, C. Pomerance, "Prime numbers: a computational perspective",
2nd ed., Springer (2005) (ISBN: 0-387-25282-7, 978-0387-25282-7) ↩
R. Baillie, A. Fiori, S. S. Wagstaff,
"Strengthening the Baillie-PSW primality test",
Math. Comp. 90 1931-1955 (2021),
DOI: 10.1090/mcom/3616↩
The text was updated successfully, but these errors were encountered:
The second item does not seem to be particularly useful; the single modular inverse we perform to check for U = 0 is fast enough, and dividing by 2 in Montgomery space (which is required to employ the Baillie et all approach) is quite inconvenient.
The first item does not seem to be useful for most of the checks we perform, since it seems that we can only switch back from (P', 1) sequence to (P, Q) for the 2d-th element (where n + 1 = d * 2^s), while we need it for the d-th element.
That said, it would work for the Lucas-V check, but in that case we will have to have a separate lucas_test() function specifically for Lucas-V, while now it's just a few lines in the main lucas_test(). If Lucas-V ever becomes the preferred check in presets, it will be worth doing.
There are a few tricks that may speed up the Lucas test:
(P, Q)
Lucas sequence to(P', 1)
which may eliminate some multiplications.U_k
in addition toV_k
, which means we don't need to calculateU_k
via modular inverse. It does require more multiplications though. Need to test if it leads to the performance improvement.Footnotes
R. Crandall, C. Pomerance, "Prime numbers: a computational perspective",
2nd ed., Springer (2005) (ISBN: 0-387-25282-7, 978-0387-25282-7) ↩
R. Baillie, A. Fiori, S. S. Wagstaff,
"Strengthening the Baillie-PSW primality test",
Math. Comp. 90 1931-1955 (2021),
DOI: 10.1090/mcom/3616 ↩
The text was updated successfully, but these errors were encountered: