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 | |
| parent | d0bf16e2f4a30b9a5260578fb5583950c149e425 (diff) | |
change tests
Diffstat (limited to 'test/math')
| -rw-r--r-- | test/math/linearRecurrence.cpp | 15 | ||||
| -rw-r--r-- | test/math/linearRecurrence.cpp.awk | 4 | ||||
| -rw-r--r-- | test/math/linearRecurrenceNTT.cpp (renamed from test/math/linearRecurrenceSlowMul.cpp) | 25 | ||||
| -rw-r--r-- | test/math/linearRecurrenceOld.cpp (renamed from test/math/linearRecurenceOld.cpp) | 0 |
4 files changed, 22 insertions, 22 deletions
diff --git a/test/math/linearRecurrence.cpp b/test/math/linearRecurrence.cpp index 50e98a0..f0ebe76 100644 --- a/test/math/linearRecurrence.cpp +++ b/test/math/linearRecurrence.cpp @@ -1,9 +1,12 @@ #include "../util.h" -#include <math/modPowIterativ.cpp> -#include <math/transforms/ntt.cpp> -#include <math/transforms/multiplyNTT.cpp> +vector<ll> mul(const vector<ll>& a, const vector<ll>& b); #include <math/linearRecurrence.cpp> +vector<ll> mul(const vector<ll>& a, const vector<ll>& b) { + return mulSlow(a, b); +} + + 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) {} @@ -23,7 +26,7 @@ struct RandomRecurence { void stress_test() { int queries = 0; - for (int i = 0; i < 1'000; i++) { + 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++) { @@ -39,14 +42,14 @@ void stress_test() { cerr << "tested random queries: " << queries << endl; } -constexpr int N = 100'000; +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 > 8000) cerr << "too slow: " << t.time << FAIL; + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; } diff --git a/test/math/linearRecurrence.cpp.awk b/test/math/linearRecurrence.cpp.awk new file mode 100644 index 0000000..902fd4b --- /dev/null +++ b/test/math/linearRecurrence.cpp.awk @@ -0,0 +1,4 @@ +/vector<ll> mul/ { + sub(/mul/, "mulSlow") +} +{ print } diff --git a/test/math/linearRecurrenceSlowMul.cpp b/test/math/linearRecurrenceNTT.cpp index 205e584..e03c27e 100644 --- a/test/math/linearRecurrenceSlowMul.cpp +++ b/test/math/linearRecurrenceNTT.cpp @@ -1,18 +1,11 @@ #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/modPowIterativ.cpp> +#include <math/transforms/ntt.cpp> +#include <math/transforms/multiplyNTT.cpp> +#define mod mod2 #include <math/linearRecurrence.cpp> +#undef mod +static_assert(mod == mod2); struct RandomRecurence { vector<ll> f, c, cache; @@ -33,7 +26,7 @@ struct RandomRecurence { void stress_test() { int queries = 0; - for (int i = 0; i < 10'000; i++) { + for (int i = 0; i < 1'000; i++) { int n = Random::integer<int>(1, 10); RandomRecurence f(n); for (int j = 0; j < 100; j++) { @@ -49,14 +42,14 @@ void stress_test() { cerr << "tested random queries: " << queries << endl; } -constexpr int N = 1'000; +constexpr int N = 100'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; + if (t.time > 8000) cerr << "too slow: " << t.time << FAIL; cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; } diff --git a/test/math/linearRecurenceOld.cpp b/test/math/linearRecurrenceOld.cpp index dab2256..dab2256 100644 --- a/test/math/linearRecurenceOld.cpp +++ b/test/math/linearRecurrenceOld.cpp |
