mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
The safegcd (Bernstein-Yang divsteps) algorithm is faster than Fermat in C due to native 128-bit integer support, but on JVM the 128-bit arithmetic overhead via multiplyHigh + carry tracking in the inner loop (12 rounds × matrix multiply on 5 limbs) is slower than the Fermat addition chain (255 sqr + 15 mul of optimized field ops). Benchmark showed 8.3x vs native (was 5.0x with Fermat), confirming that the per-operation constant factor matters more than algorithmic complexity for this problem size on JVM. https://claude.ai/code/session_01BhU63WUe9AhikZxRdw3Lpg