From 3fe8ee352845741d97a76e2ed6a390cb1481d755 Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Sat, 16 Nov 2024 21:43:46 +0100 Subject: minor changes --- content/math/transforms/multiplyNTT.cpp | 2 +- content/other/josephus2.cpp | 6 +++--- content/other/other.tex | 4 +--- test.h | 33 --------------------------------- test/other/josephus2.cpp | 2 +- test/util.h | 8 ++++++++ 6 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 test.h diff --git a/content/math/transforms/multiplyNTT.cpp b/content/math/transforms/multiplyNTT.cpp index aec2a61..d234ce3 100644 --- a/content/math/transforms/multiplyNTT.cpp +++ b/content/math/transforms/multiplyNTT.cpp @@ -1,5 +1,5 @@ vector mul(vector a, vector b) { - int n = 1 << (__lg(ssize(a) + ssize(b) - 1) + 1); + int n = 1 << bit_width(size(a) + size(b) - 1); a.resize(n), b.resize(n); ntt(a), ntt(b); for (int i=0; i -using namespace std; -using ll = long long; - -template -T _lg_check(T n) { - assert(n > 0); - return __lg(n); -} - -#define __lg _lg_check - -namespace util { - -mt19937 rd(0); - -int randint(int l, int r) { - assert(l <= r); - return uniform_int_distribution(l, r)(rd); -} - -int randint(int x) { - assert(x > 0); - return randint(0, x-1); -} - -int randint() { - return randint(-1'000'000, +1'000'000); -} - -} diff --git a/test/other/josephus2.cpp b/test/other/josephus2.cpp index c6b1cd1..f2c0440 100644 --- a/test/other/josephus2.cpp +++ b/test/other/josephus2.cpp @@ -15,7 +15,7 @@ void stress_test() { ll tests = 0; for (ll i = 1; i < 2'000; i++) { auto got = rotateLeft(i); - auto expected = naive<1>(i, 2); + auto expected = naive<0>(i, 2); if (got != expected) cerr << "error: " << i << FAIL; tests++; } diff --git a/test/util.h b/test/util.h index 0c14ff8..e0d9b57 100644 --- a/test/util.h +++ b/test/util.h @@ -10,6 +10,14 @@ namespace INT {constexpr int INF = 0x3FFF'FFFF;} namespace LL {constexpr ll INF = 0x3FFF'FFFF'FFFF'FFFFll;} namespace LD {constexpr ld INF = numeric_limits::infinity();} +template +T _lg_check(T n) { + assert(n > 0); + return __lg(n); +} + +#define __lg _lg_check + namespace details { template bool isPrime(T x) { -- cgit v1.2.3