diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2024-09-11 00:29:27 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2024-09-11 00:29:27 +0200 |
| commit | 0257f0b3c61f203f64c3817dfe19a08f6191517c (patch) | |
| tree | 820d5c1ed1830bad5ee8f1498d9134ca4359393b /test/other | |
| parent | facc5da35282ef30e5111cdc04942d118f4ae0c5 (diff) | |
moved stuff
Diffstat (limited to 'test/other')
| -rw-r--r-- | test/other/recover.cpp | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/test/other/recover.cpp b/test/other/recover.cpp deleted file mode 100644 index 72853e5..0000000 --- a/test/other/recover.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "../util.h" -#include <other/recover.cpp> -#include <math/shortModInv.cpp> - -void stress_test() { - ll queries = 0; - timer t; - for (int i = 0; i < 500; i++) { - ll p = Random::prime<ll>(10000); - for (ll j = 0; 2*j*j < p; j++) { - for (ll b = 1; 2*b*b < p; b++) { - if (gcd(j, b) != 1) continue; - for (ll a : {-j, j}) { - ll c = a * multInv(b, p); - - t.start(); - auto [x, y] = recover(c, p); - t.stop(); - - if (a != x || b != y) cerr << "got: " << x << "/" << y << ", expected: " << a << "/" << b << FAIL; - queries++; - } - } - } - for (ll c = 0; c < p; c++) { - t.start(); - auto [x, y] = recover(c, p); - t.stop(); - - if (y < 0) continue; - if (y == 0) cerr << "error: y=0" << FAIL; - ll got = (((x * multInv(y, p)) % p) + p) % p; - if (got != c) cerr << "got: " << got << ", expected: " << c << FAIL; - queries++; - } - } - cerr << "tested random queries: " << queries << endl; - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms" << endl; -} - -int main() { - stress_test(); -} |
