diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2024-09-11 10:39:00 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2024-09-11 10:39:00 +0200 |
| commit | a898bac55c6cd7c51fef5e6735aa3a316a18da7b (patch) | |
| tree | 85d2bd63b303e3e6f140fbff52c0d0472d247623 /test/math/linearRecurrenceSlowMul.cpp | |
| parent | d0bf16e2f4a30b9a5260578fb5583950c149e425 (diff) | |
change tests
Diffstat (limited to 'test/math/linearRecurrenceSlowMul.cpp')
| -rw-r--r-- | test/math/linearRecurrenceSlowMul.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/test/math/linearRecurrenceSlowMul.cpp b/test/math/linearRecurrenceSlowMul.cpp deleted file mode 100644 index 205e584..0000000 --- a/test/math/linearRecurrenceSlowMul.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "../util.h" - -constexpr ll mod = 998244353; -vector<ll> mul(const vector<ll> &a, const vector<ll> &b){ - vector<ll> c(sz(a) + sz(b) - 1); - for(int i = 0; i < sz(a); i++){ - for(int j = 0; j < sz(b); j++){ - c[i+j] += a[i]*b[j] % mod; - } - } - for(ll &x : c) x %= mod; - return c; -} - -#include <math/linearRecurrence.cpp> - -struct RandomRecurence { - vector<ll> f, c, cache; - RandomRecurence(int n) : f(Random::integers<ll>(n, 0, mod)), c(Random::integers<ll>(n, 0, mod)), cache(f) {} - - ll operator()(ll k){ - while (sz(cache) <= k) { - ll cur = 0; - for (ll i = 0; i < sz(c); i++) { - cur += (c[i] * cache[sz(cache) - i - 1]) % mod; - } - cur %= mod; - cache.push_back(cur); - } - return cache[k]; - } -}; - -void stress_test() { - int queries = 0; - for (int i = 0; i < 10'000; i++) { - int n = Random::integer<int>(1, 10); - RandomRecurence f(n); - for (int j = 0; j < 100; j++) { - ll k = Random::integer<ll>(0, 1000); - - ll got = kthTerm(f.f, f.c, k); - ll expected = f(k); - - if (got != expected) cerr << "got: " << got << ", expected: " << expected << FAIL; - queries++; - } - } - cerr << "tested random queries: " << queries << endl; -} - -constexpr int N = 1'000; -void performance_test() { - timer t; - RandomRecurence f(N); - t.start(); - hash_t hash = kthTerm(f.f, f.c, 1e18); - t.stop(); - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; -} - -int main() { - stress_test(); - performance_test(); -} - |
