3 ms·
I was reading about an implementation of Barrett reduction recently: https://en.wikipedia.org/wiki/Barrett_reduction https://en.wikipedia.org/wiki/Barrett_redu
by uyt 6y ago
I was reading about an implementation of Barrett reduction recently:
https://en.wikipedia.org/wiki/Barrett_reduction https://en.wikipedia.org/wiki/Barrett_reduction
Specifically one that uses 80-bit long double for calculating `(__int128_t)a * b % M` from this github:
https://github.com/kth-competitive-programming/kactl/blob/master/content/number-theory/ModMulLL.h https://github.com/kth-competitive-programming/kactl/blob/ma...
But how do you test the correctness of such code? You can't just stress test all possible product of 64 bit numbers!
In the end you still gotta go back to good old fashion proofs:
https://github.com/kth-competitive-programming/kactl/blob/master/doc/modmul-proof.pdf https://github.com/kth-competitive-programming/kactl/blob/ma...