Closed xanthe-cat closed 5 months ago
Maybe try saving the residue to a savefile and then checking it with the --check
option of my GIMPS status script. That would tell you if the full residue is somehow getting corrupted or if the Selfridge-Hurwitz residues are just being calculated incorrectly by Mlucas.
If it is the latter, the modular divide by 9 could change the size of the residue, so it could be that the res_SH()
function calculating the Selfridge-Hurwitz residues is not correctly taking that into consideration. Maybe check if the len
value being passed to the res_SH()
function is correct: https://github.com/primesearch/Mlucas/blob/18398583da19f270eed22a036c27d9b6beb9973d/src/Mlucas.c#L5968-L5975
I think I have solved it:
At the earlier point just after the modular division for Mersenne exponents, the arrtmp
array is j
in size, not i
.
At the later point during the call to the Suyama_CF_PRP()
we add a limb of the initial if
loop for Mersennes,
res_SH(ci,n,&itmp64,&Res35m1,&Res36m1);
The modular division ends up in ci
(rather than arrtmp
) in this part of the code, and since the Res64
is correct we use the itmp64
value instead.
A quick example to demonstrate, with $M_{130439}$ which is semiprime with a small factor $260879$. The
worktodo
line is:My customised Mlucas test build prints S–H residues before and after the final modular division step:
The Res64 values are correct, but the “After” Res35m1 and Res36m1 are not. For comparison, the output from cofact 0.74c:
Mlucas’ output from the Suyama call reports the Suyama (A) value but again only the Res64 is correctly calculated:
Again, to compare with cofact:
I tried looking at how the (A) residue is passed from the main Mlucas code to see why Mlucas reports zeroes for the Res35m1 and Res36m1 values but couldn’t make head or tail of fixing it.