diff options
Diffstat (limited to 'test/math')
48 files changed, 98 insertions, 82 deletions
diff --git a/test/math/berlekampMassey.cpp b/test/math/berlekampMassey.cpp index a9d5709..93832b0 100644 --- a/test/math/berlekampMassey.cpp +++ b/test/math/berlekampMassey.cpp @@ -63,6 +63,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/bigint.cpp b/test/math/bigint.cpp index 538d0dc..2d75343 100644 --- a/test/math/bigint.cpp +++ b/test/math/bigint.cpp @@ -35,9 +35,9 @@ struct modInt { constexpr ll MOD = 1'394'633'899; constexpr ll POOL = 8; -void stress_test() { +void stress_test(int LIM) { int queries = 0; - for (int tries = 0; tries < 1000; tries++) { + for (int tries = 0; tries < LIM; tries++) { vector<modInt<MOD>> expectedPool(POOL); vector<bigint> gotPool(POOL); for (int i = 0; i < POOL; i++) { @@ -117,6 +117,7 @@ void stress_test() { } int main() { - stress_test(); + stress_test(100); + if (!sanitize) stress_test(1000); } diff --git a/test/math/cycleDetection.cpp b/test/math/cycleDetection.cpp index 1694589..2ba3525 100644 --- a/test/math/cycleDetection.cpp +++ b/test/math/cycleDetection.cpp @@ -41,6 +41,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/discreteLogarithm.cpp b/test/math/discreteLogarithm.cpp index 0f9eecf..6e87e59 100644 --- a/test/math/discreteLogarithm.cpp +++ b/test/math/discreteLogarithm.cpp @@ -59,6 +59,6 @@ int main() { stress_test([](ll p){return sqrtl(p);}); stress_test([](ll p){return min<ll>(10, p - 1);}); stress_test([](ll p){return min<ll>(p - 1, sqrtl(p) + 100);}); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/discreteNthRoot.cpp b/test/math/discreteNthRoot.cpp index d595e6d..e64293c 100644 --- a/test/math/discreteNthRoot.cpp +++ b/test/math/discreteNthRoot.cpp @@ -73,6 +73,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/divSum.cpp b/test/math/divSum.cpp index 1f82387..a366e53 100644 --- a/test/math/divSum.cpp +++ b/test/math/divSum.cpp @@ -43,6 +43,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/divisors.cpp b/test/math/divisors.cpp index 2402d2a..4cc7e70 100644 --- a/test/math/divisors.cpp +++ b/test/math/divisors.cpp @@ -60,6 +60,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/extendedEuclid.cpp b/test/math/extendedEuclid.cpp index 597f722..07e4882 100644 --- a/test/math/extendedEuclid.cpp +++ b/test/math/extendedEuclid.cpp @@ -32,8 +32,10 @@ void stress_test() { queries++; } cerr << "tested random queries: " << queries << endl; - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms" << endl; + if (!sanitize) { + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; + cerr << "tested performance: " << t.time << "ms" << endl; + } } int main() { diff --git a/test/math/gauss.cpp b/test/math/gauss.cpp index eb8f641..21a5736 100644 --- a/test/math/gauss.cpp +++ b/test/math/gauss.cpp @@ -114,5 +114,5 @@ void performance_test() { int main() { test_tiny(); stress_test_inv(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/goldenSectionSearch.cpp b/test/math/goldenSectionSearch.cpp index 565a21c..ff2d067 100644 --- a/test/math/goldenSectionSearch.cpp +++ b/test/math/goldenSectionSearch.cpp @@ -69,6 +69,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/inversions.cpp b/test/math/inversions.cpp index fc825e4..86d87d0 100644 --- a/test/math/inversions.cpp +++ b/test/math/inversions.cpp @@ -37,6 +37,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/inversionsMerge.cpp b/test/math/inversionsMerge.cpp index 7d1b0d7..ab1c62e 100644 --- a/test/math/inversionsMerge.cpp +++ b/test/math/inversionsMerge.cpp @@ -41,6 +41,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/kthperm.cpp b/test/math/kthperm.cpp index 1b3e803..ca95699 100644 --- a/test/math/kthperm.cpp +++ b/test/math/kthperm.cpp @@ -1,9 +1,9 @@ #include "../util.h" #include <math/kthperm.cpp> -void stress_test() { +void stress_test(int LIM) { ll queries = 0; - for (ll i = 0; i < 10'000; i++) { + for (int i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); vector<ll> expected(n); iota(begin(expected), end(expected), 0); @@ -31,7 +31,8 @@ void performance_test() { } int main() { - stress_test(); - performance_test(); + stress_test(1'000); + if (!sanitize) stress_test(10'000); + if (!sanitize) performance_test(); } diff --git a/test/math/legendre.cpp b/test/math/legendre.cpp index f210b57..44f88c1 100644 --- a/test/math/legendre.cpp +++ b/test/math/legendre.cpp @@ -38,6 +38,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/lgsFp.cpp b/test/math/lgsFp.cpp index 376a067..d8967a0 100644 --- a/test/math/lgsFp.cpp +++ b/test/math/lgsFp.cpp @@ -108,5 +108,5 @@ void performance_test() { int main() { test_square(); stress_test_inv(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/linearCongruence.cpp b/test/math/linearCongruence.cpp index ba8eeac..fa01a06 100644 --- a/test/math/linearCongruence.cpp +++ b/test/math/linearCongruence.cpp @@ -48,6 +48,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/linearRecurrence.cpp b/test/math/linearRecurrence.cpp index 79607ac..a2ac01d 100644 --- a/test/math/linearRecurrence.cpp +++ b/test/math/linearRecurrence.cpp @@ -54,6 +54,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/linearRecurrenceNTT.cpp b/test/math/linearRecurrenceNTT.cpp index 922d965..f7615d6 100644 --- a/test/math/linearRecurrenceNTT.cpp +++ b/test/math/linearRecurrenceNTT.cpp @@ -55,6 +55,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/linearRecurrenceOld.cpp b/test/math/linearRecurrenceOld.cpp index 70609f0..b3d1611 100644 --- a/test/math/linearRecurrenceOld.cpp +++ b/test/math/linearRecurrenceOld.cpp @@ -49,6 +49,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/linearSieve.cpp b/test/math/linearSieve.cpp index 527e729..1a5286f 100644 --- a/test/math/linearSieve.cpp +++ b/test/math/linearSieve.cpp @@ -59,8 +59,10 @@ void performance_test() { sieve(); hash_t hash = ssize(primes); t.stop(); - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; + if (!sanitize) { + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; + cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; + } } int main() { diff --git a/test/math/longestIncreasingSubsequence.cpp b/test/math/longestIncreasingSubsequence.cpp index befee75..5bc3936 100644 --- a/test/math/longestIncreasingSubsequence.cpp +++ b/test/math/longestIncreasingSubsequence.cpp @@ -30,9 +30,9 @@ vector<int> naive(const vector<ll>& a) { return res; } -void stress_test() { +void stress_test(ll LIM) { ll queries = 0; - for (ll i = 0; i < 10'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 12); auto a = Random::integers<ll>(n, -10, 10); auto expected = naive<true>(a); @@ -40,7 +40,7 @@ void stress_test() { if (got != expected) cerr << "error: strict" << FAIL; queries += n; } - for (ll i = 0; i < 10'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 12); auto a = Random::integers<ll>(n, -10, 10); auto expected = naive<false>(a); @@ -70,6 +70,7 @@ void performance_test() { } int main() { - stress_test(); - performance_test(); + stress_test(1'000); + if (!sanitize) stress_test(10'000); + if (!sanitize) performance_test(); } diff --git a/test/math/matrixPower.cpp b/test/math/matrixPower.cpp index 169ff06..083dded 100644 --- a/test/math/matrixPower.cpp +++ b/test/math/matrixPower.cpp @@ -111,6 +111,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/millerRabin.base32.cpp b/test/math/millerRabin.base32.cpp index 8c2c79a..e9a4b57 100644 --- a/test/math/millerRabin.base32.cpp +++ b/test/math/millerRabin.base32.cpp @@ -132,6 +132,6 @@ void performance_test() { int main() { extra_tests(); stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/millerRabin.cpp b/test/math/millerRabin.cpp index 725b744..e7feba1 100644 --- a/test/math/millerRabin.cpp +++ b/test/math/millerRabin.cpp @@ -124,6 +124,6 @@ void performance_test() { int main() { extra_tests(); stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/minMod.cpp b/test/math/minMod.cpp index e49da11..39affb4 100644 --- a/test/math/minMod.cpp +++ b/test/math/minMod.cpp @@ -86,7 +86,7 @@ void performance_test_firstVal() { int main() { stress_test_minMod(); stress_test_firstVal(); - performance_test_minMod(); - performance_test_firstVal(); + if (!sanitize) performance_test_minMod(); + if (!sanitize) performance_test_firstVal(); } diff --git a/test/math/modMulIterativ.cpp b/test/math/modMulIterativ.cpp index 4f794c5..7783026 100644 --- a/test/math/modMulIterativ.cpp +++ b/test/math/modMulIterativ.cpp @@ -14,7 +14,7 @@ void stress_test() { k++; expected = (expected + a) % n; } while (k < 100); - queries += n; + queries++; } cerr << "tested queries: " << queries << endl; } @@ -28,7 +28,7 @@ void stress_test_large() { ll expected = (lll)a * b % n; auto got = mulMod(a, b, n); if (got != expected) cerr << "got: " << got << ", expected: " << expected << FAIL; - queries += n; + queries++; } cerr << "tested queries: " << queries << endl; } @@ -52,6 +52,6 @@ void performance_test() { int main() { stress_test(); stress_test_large(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/modPowIterativ.cpp b/test/math/modPowIterativ.cpp index 2cf0eb4..29ea4c5 100644 --- a/test/math/modPowIterativ.cpp +++ b/test/math/modPowIterativ.cpp @@ -37,6 +37,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/multInv.cpp b/test/math/multInv.cpp index 93763c5..a6c37a1 100644 --- a/test/math/multInv.cpp +++ b/test/math/multInv.cpp @@ -35,6 +35,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/permIndex.cpp b/test/math/permIndex.cpp index d68ba3a..2f19985 100644 --- a/test/math/permIndex.cpp +++ b/test/math/permIndex.cpp @@ -1,9 +1,9 @@ #include "../util.h" #include <math/permIndex.cpp> -void stress_test() { +void stress_test(int LIM) { ll queries = 0; - for (ll i = 0; i < 10'000; i++) { + for (int i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); vector<ll> cur(n); iota(begin(cur), end(cur), 0); @@ -32,7 +32,8 @@ void performance_test() { } int main() { - stress_test(); - performance_test(); + stress_test(1'000); + if (!sanitize) stress_test(10'000); + if (!sanitize) performance_test(); } diff --git a/test/math/piLegendre.cpp b/test/math/piLegendre.cpp index c3513bf..53c459c 100644 --- a/test/math/piLegendre.cpp +++ b/test/math/piLegendre.cpp @@ -34,7 +34,7 @@ void performance_test() { int main() { lehmer::init(); - performance_test(); + if (!sanitize) performance_test(); stress_test(); } diff --git a/test/math/piLehmer.cpp b/test/math/piLehmer.cpp index d84466f..bfc714f 100644 --- a/test/math/piLehmer.cpp +++ b/test/math/piLehmer.cpp @@ -36,7 +36,8 @@ void performance_test() { } int main() { - performance_test(); + if (!sanitize) performance_test(); + if (sanitize) lehmer::init(); stress_test(); } diff --git a/test/math/primeSieve.cpp b/test/math/primeSieve.cpp index 6bb63f6..52570e2 100644 --- a/test/math/primeSieve.cpp +++ b/test/math/primeSieve.cpp @@ -36,8 +36,10 @@ void performance_test() { primeSieve(); hash_t hash = ssize(primes); t.stop(); - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; + if (!sanitize) { + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; + cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; + } } int main() { diff --git a/test/math/recover.cpp b/test/math/recover.cpp index 6f89e5a..9b61653 100644 --- a/test/math/recover.cpp +++ b/test/math/recover.cpp @@ -35,8 +35,10 @@ void stress_test() { } } cerr << "tested random queries: " << queries << endl; - if (t.time > 500) cerr << "too slow: " << t.time << FAIL; - cerr << "tested performance: " << t.time << "ms" << endl; + if (!sanitize) { + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; + cerr << "tested performance: " << t.time << "ms" << endl; + } } int main() { diff --git a/test/math/rho.cpp b/test/math/rho.cpp index 941524b..9943a8c 100644 --- a/test/math/rho.cpp +++ b/test/math/rho.cpp @@ -120,6 +120,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/shortModInv.cpp b/test/math/shortModInv.cpp index 565989c..5e74907 100644 --- a/test/math/shortModInv.cpp +++ b/test/math/shortModInv.cpp @@ -34,6 +34,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/simpson.cpp b/test/math/simpson.cpp index d7cdba3..019caca 100644 --- a/test/math/simpson.cpp +++ b/test/math/simpson.cpp @@ -53,8 +53,10 @@ void stress_test() { queries++; } } - if (t.time > 5000) cerr << "too slow: " << t.time << FAIL; - cerr << "tested random queries: " << queries << " (" << t.time << "ms)" << endl; + if (!sanitize) { + if (t.time > 5000) cerr << "too slow: " << t.time << FAIL; + cerr << "tested random queries: " << queries << " (" << t.time << "ms)" << endl; + } } int main() { diff --git a/test/math/sqrtModCipolla.cpp b/test/math/sqrtModCipolla.cpp index 26d975b..c7be9a4 100644 --- a/test/math/sqrtModCipolla.cpp +++ b/test/math/sqrtModCipolla.cpp @@ -43,6 +43,6 @@ void performance_test() { int main() { stress_test(1'000); stress_test(1'000'000'000); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/andTransform.cpp b/test/math/transforms/andTransform.cpp index fa029f6..eef57bf 100644 --- a/test/math/transforms/andTransform.cpp +++ b/test/math/transforms/andTransform.cpp @@ -33,6 +33,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/bitwiseTransforms.cpp b/test/math/transforms/bitwiseTransforms.cpp index 132740c..79fe120 100644 --- a/test/math/transforms/bitwiseTransforms.cpp +++ b/test/math/transforms/bitwiseTransforms.cpp @@ -33,6 +33,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/fft.cpp b/test/math/transforms/fft.cpp index 66df1bf..aa7ddd2 100644 --- a/test/math/transforms/fft.cpp +++ b/test/math/transforms/fft.cpp @@ -46,6 +46,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/fftMul.cpp b/test/math/transforms/fftMul.cpp index 7887a5e..38e7c73 100644 --- a/test/math/transforms/fftMul.cpp +++ b/test/math/transforms/fftMul.cpp @@ -57,6 +57,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/multiplyBitwise.cpp b/test/math/transforms/multiplyBitwise.cpp index 8b9eb2f..f460204 100644 --- a/test/math/transforms/multiplyBitwise.cpp +++ b/test/math/transforms/multiplyBitwise.cpp @@ -50,6 +50,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/multiplyFFT.cpp b/test/math/transforms/multiplyFFT.cpp index 61040d0..f11ec45 100644 --- a/test/math/transforms/multiplyFFT.cpp +++ b/test/math/transforms/multiplyFFT.cpp @@ -50,6 +50,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/multiplyNTT.cpp b/test/math/transforms/multiplyNTT.cpp index 6424c50..48a1aa3 100644 --- a/test/math/transforms/multiplyNTT.cpp +++ b/test/math/transforms/multiplyNTT.cpp @@ -51,6 +51,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/ntt.cpp b/test/math/transforms/ntt.cpp index cd32073..533d086 100644 --- a/test/math/transforms/ntt.cpp +++ b/test/math/transforms/ntt.cpp @@ -34,6 +34,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/orTransform.cpp b/test/math/transforms/orTransform.cpp index 0ec9155..b1fdfad 100644 --- a/test/math/transforms/orTransform.cpp +++ b/test/math/transforms/orTransform.cpp @@ -33,6 +33,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } diff --git a/test/math/transforms/seriesOperations.cpp b/test/math/transforms/seriesOperations.cpp index f78541d..1242537 100644 --- a/test/math/transforms/seriesOperations.cpp +++ b/test/math/transforms/seriesOperations.cpp @@ -63,9 +63,9 @@ namespace reference {//checked against yosupo } } -void test_inv() { +void test_inv(ll LIM) { ll queries = 0; - for (ll i = 0; i < 50'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); int m = Random::integer<int>(1, 100); vector<ll> a = Random::integers<ll>(n, 0, mod); @@ -78,9 +78,9 @@ void test_inv() { cerr << "tested inv: " << queries << endl; } -void test_deriv() { +void test_deriv(ll LIM) { ll queries = 0; - for (ll i = 0; i < 50'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); vector<ll> a = Random::integers<ll>(n, 0, mod); @@ -92,9 +92,9 @@ void test_deriv() { cerr << "tested deriv: " << queries << endl; } -void test_integr() { +void test_integr(ll LIM) { ll queries = 0; - for (ll i = 0; i < 50'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); vector<ll> a = Random::integers<ll>(n, 0, mod); @@ -106,9 +106,9 @@ void test_integr() { cerr << "tested integr: " << queries << endl; } -void test_log() { +void test_log(ll LIM) { ll queries = 0; - for (ll i = 0; i < 50'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); int m = Random::integer<int>(1, 100); vector<ll> a = Random::integers<ll>(n, 0, mod); @@ -121,9 +121,9 @@ void test_log() { cerr << "tested log: " << queries << endl; } -void test_exp() { +void test_exp(ll LIM) { ll queries = 0; - for (ll i = 0; i < 50'000; i++) { + for (ll i = 0; i < LIM; i++) { int n = Random::integer<int>(1, 100); int m = Random::integer<int>(1, 100); vector<ll> a = Random::integers<ll>(n, 0, mod); @@ -137,9 +137,10 @@ void test_exp() { } int main() { - test_inv(); - test_deriv(); - test_integr(); - test_log(); - test_exp(); + ll LIM = sanitize ? 5'000 : 50'000; + test_inv(LIM); + test_deriv(LIM); + test_integr(LIM); + test_log(LIM); + test_exp(LIM); } diff --git a/test/math/transforms/xorTransform.cpp b/test/math/transforms/xorTransform.cpp index 17b0f6f..630331a 100644 --- a/test/math/transforms/xorTransform.cpp +++ b/test/math/transforms/xorTransform.cpp @@ -33,6 +33,6 @@ void performance_test() { int main() { stress_test(); - performance_test(); + if (!sanitize) performance_test(); } |
