Reapply modulo helpers and inline fast remainders
This commit is contained in:
1 parent
5db0c4fa95
commit
ca866ffc5b
43 files changed
+982
-134
No files matched your search
@@ -51,7 +51,7 @@ public class MersenneNumberLucasLehmerGpuTester
|
||||
// Early rejections aligned with incremental/order sieves, but safe for small p:
|
||||
// - If 3 | p and p != 3, then 7 | M_p -> composite.
|
||||
// - If p ≡ 1 (mod 4) and p shares a factor with (p-1), reject fast.
|
||||
if ((exponent % 3UL) == 0UL && exponent != 3UL)
|
||||
if (exponent % 3UL == 0UL && exponent != 3UL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -548,7 +548,7 @@ public class MersenneNumberLucasLehmerGpuTester
|
||||
}
|
||||
}
|
||||
|
||||
int topBits = (int)(exponent % 128UL);
|
||||
int topBits = (int)exponent.Mod128();
|
||||
if (topBits == 0)
|
||||
{
|
||||
topBits = 128;
|
||||
@@ -672,7 +672,7 @@ public class MersenneNumberLucasLehmerGpuTester
|
||||
}
|
||||
}
|
||||
|
||||
int topBits = (int)(exponent % 128UL);
|
||||
int topBits = (int)exponent.Mod128();
|
||||
if (topBits == 0)
|
||||
{
|
||||
topBits = 128;
|
||||
@@ -803,7 +803,7 @@ public class MersenneNumberLucasLehmerGpuTester
|
||||
vLow.Add(vHigh);
|
||||
|
||||
// Mask to keep only p low bits and fold the carry bits (v >> p)
|
||||
int topBits = (int)(p % 128UL);
|
||||
int topBits = (int)p.Mod128();
|
||||
if (topBits == 0)
|
||||
{
|
||||
topBits = 128;
|
||||
|
||||
@@ -27,10 +27,10 @@ public class MersenneNumberOrderGpuTester(GpuKernelType kernelType, bool useGpuO
|
||||
var foundBuffer = accelerator.Allocate1D<int>(1);
|
||||
UInt128 exponent128 = exponent;
|
||||
exponent128.Mod10_8_5_3(out ulong exponentMod10, out ulong exponentMod8, out ulong exponentMod5, out ulong exponentMod3);
|
||||
ulong step10 = (exponentMod10 << 1).Mod10();
|
||||
ulong step10 = (exponentMod10 << 1) % 10UL;
|
||||
ulong step8 = (exponentMod8 << 1) & 7UL;
|
||||
ulong step3 = (exponentMod3 << 1) % 3UL;
|
||||
ulong step5 = (exponentMod5 << 1) % 5UL;
|
||||
ulong step3 = (exponentMod3 << 1) % 3UL;
|
||||
ulong step5 = (exponentMod5 << 1) % 5UL;
|
||||
try
|
||||
{
|
||||
UInt128 remaining;
|
||||
|
||||
Reference in new issue
Block a user