summaryrefslogtreecommitdiff
path: root/math/transforms
diff options
context:
space:
mode:
authormzuenni <mzuenni@users.noreply.github.com>2024-07-28 22:54:40 +0200
committerGitHub <noreply@github.com>2024-07-28 22:54:40 +0200
commit8d11c6c8213f46f0fa19826917c255edd5d43cb1 (patch)
tree96d75baff33d5a04b5a60f1a41f514a26c716874 /math/transforms
parent8c33b4e0d3030cfed17fc64b4fe41133339f6d87 (diff)
Test (#4)
* update * moved content in subdir * rename file * add test setup * add test setup * add github action * automaticly test all cpp files * timeout after 10s * setulimit and dont zero memory * test build pdf * install latexmk * update * update * ngerman * fonts * removed old code * add first test * added tests * test in sorted order * more tests * simplified test * more tests * fix suffix tree * fixes and improvements * done ust lst directly * fix swap * add links to pdf * fix constants * add primorial * add comment * various improvements * more tests * added missing stuf * more tests * fix tests * more tests * more tests * more tests * fix recursion? * test trie * more tests * only use python temporarily for listings * only use python temporarily for listings * more tests * fix longestCommonSubstring * more tests * more tests * made code more similiar * fix? * more tests * more tests * more tests * add ahoCorasick test + limit 4GB stack size * more tests * fix test * add additional test * more tests * more tests * fix? * better fix * fix virtual tree * more tests * more tests * recursive closest pair * more tests * decrease limit * new tests * more tests * fix name * more tests * add test * new test * more tests * more tests * more tests * more tests * new test and content * new code * new code * larger tests * fix and test * new test * new test * update pdf * remove comments * new test * more tests * more testcases * more tests * increased limit * more tests * more tests * more tests * new tests * more tests * shortened code * new test * add basic tests for bigint * more tests * removed old files * new test * ignore some files * more auto more ccw * fix test * more tests * fix * new tests * more tests * more tests * stronger test * actually verify delaunay... * more tests * fix header * more tests * run tests parallel? * test parralel? * add --missing * separate workflows * test * is the pdf checked? * separate workflows * fix workflow * more workflows --------- Co-authored-by: Yidi <noob999noob999@gmail.com>
Diffstat (limited to 'math/transforms')
-rw-r--r--math/transforms/andTransform.cpp8
-rw-r--r--math/transforms/bitwiseTransforms.cpp12
-rw-r--r--math/transforms/fft.cpp23
-rw-r--r--math/transforms/fftMul.cpp14
-rw-r--r--math/transforms/multiplyBitwise.cpp8
-rw-r--r--math/transforms/multiplyFFT.cpp12
-rw-r--r--math/transforms/multiplyNTT.cpp8
-rw-r--r--math/transforms/ntt.cpp23
-rw-r--r--math/transforms/orTransform.cpp8
-rw-r--r--math/transforms/seriesOperations.cpp56
-rw-r--r--math/transforms/xorTransform.cpp10
11 files changed, 0 insertions, 182 deletions
diff --git a/math/transforms/andTransform.cpp b/math/transforms/andTransform.cpp
deleted file mode 100644
index 1fd9f5c..0000000
--- a/math/transforms/andTransform.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-void fft(vector<ll>& a, bool inv = false) {
- int n = sz(a);
- for (int s = 1; s < n; s *= 2) {
- for (int i = 0; i < n; i += 2 * s) {
- for (int j = i; j < i + s; j++) {
- ll& u = a[j], &v = a[j + s];
- tie(u, v) = inv ? pair(v - u, u) : pair(v, u + v);
-}}}}
diff --git a/math/transforms/bitwiseTransforms.cpp b/math/transforms/bitwiseTransforms.cpp
deleted file mode 100644
index 28561da..0000000
--- a/math/transforms/bitwiseTransforms.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-void bitwiseConv(vector<ll>& a, bool inv = false) {
- int n = sz(a);
- for (int s = 1; s < n; s *= 2) {
- for (int i = 0; i < n; i += 2 * s) {
- for (int j = i; j < i + s; j++) {
- ll& u = a[j], &v = a[j + s];
- tie(u, v) = inv ? pair(v - u, u) : pair(v, u + v); // AND
- //tie(u, v) = inv ? pair(v, u - v) : pair(u + v, u); //OR
- //tie(u, v) = pair(u + v, u - v); // XOR
- }}}
- //if (inv) for (ll& x : a) x /= n; // XOR (careful with MOD)
-}
diff --git a/math/transforms/fft.cpp b/math/transforms/fft.cpp
deleted file mode 100644
index 2bd95b2..0000000
--- a/math/transforms/fft.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-using cplx = complex<double>;
-
-void fft(vector<cplx>& a, bool inv = false) {
- int n = sz(a);
- for (int i = 0, j = 1; j < n - 1; ++j) {
- for (int k = n >> 1; k > (i ^= k); k >>= 1);
- if (j < i) swap(a[i], a[j]);
- }
- static vector<cplx> ws(2, 1);
- for (static int k = 2; k < n; k *= 2) {
- ws.resize(n);
- cplx w = polar(1.0, acos(-1.0) / k);
- for (int i=k; i<2*k; i++) ws[i] = ws[i/2] * (i % 2 ? w : 1);
- }
- for (int s = 1; s < n; s *= 2) {
- for (int j = 0; j < n; j += 2 * s) {
- for (int k = 0; k < s; k++) {
- cplx u = a[j + k], t = a[j + s + k];
- t *= (inv ? conj(ws[s + k]) : ws[s + k]);
- a[j + k] = u + t;
- a[j + s + k] = u - t;
- if (inv) a[j + k] /= 2, a[j + s + k] /= 2;
-}}}}
diff --git a/math/transforms/fftMul.cpp b/math/transforms/fftMul.cpp
deleted file mode 100644
index eac343c..0000000
--- a/math/transforms/fftMul.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-vector<cplx> mul(vector<cplx>& a, vector<cplx>& b) {
- vector<cplx> c(sz(a)), d(sz(a));
- for (int i = 0; i < sz(b); i++) {
- c[i] = {real(a[i]), real(b[i])};
- }
- fft(c);
- for (int i = 0; i < sz(b); i++) {
- int j = (sz(a) - i) % sz(a);
- cplx x = (c[i] + conj(c[j])) / cplx{2, 0}; //fft(a)[i];
- cplx y = (c[i] - conj(c[j])) / cplx{0, 2}; //fft(b)[i];
- d[i] = x * y;
- }
- return fft(d, true);
-}
diff --git a/math/transforms/multiplyBitwise.cpp b/math/transforms/multiplyBitwise.cpp
deleted file mode 100644
index 0fa671c..0000000
--- a/math/transforms/multiplyBitwise.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-vector<ll> mul(vector<ll> a, vector<ll> b) {
- int n = 1 << (__lg(max(sz(a), sz(b)) - 1) + 1);
- a.resize(n), b.resize(n);
- bitwiseConv(a), bitwiseConv(b);
- for (int i=0; i<n; i++) a[i] *= b[i]; // MOD?
- bitwiseConv(a, true);
- return a;
-}
diff --git a/math/transforms/multiplyFFT.cpp b/math/transforms/multiplyFFT.cpp
deleted file mode 100644
index 0022d1f..0000000
--- a/math/transforms/multiplyFFT.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-vector<ll> mul(vector<ll>& a, vector<ll>& b) {
- int n = 1 << (__lg(sz(a) + sz(b) - 1) + 1);
- vector<cplx> a2(all(a)), b2(all(b));
- a2.resize(n), b2.resize(n);
- fft(a2), fft(b2);
- for (int i=0; i<n; i++) a2[i] *= b2[i];
- fft(a2, true);
-
- vector<ll> ans(n);
- for (int i=0; i<n; i++) ans[i] = llround(a2[i].real());
- return ans;
-}
diff --git a/math/transforms/multiplyNTT.cpp b/math/transforms/multiplyNTT.cpp
deleted file mode 100644
index 806d124..0000000
--- a/math/transforms/multiplyNTT.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-vector<ll> mul(vector<ll> a, vector<ll> b) {
- int n = 1 << (__lg(sz(a) + sz(b) - 1) + 1);
- a.resize(n), b.resize(n);
- ntt(a), ntt(b);
- for (int i=0; i<n; i++) a[i] = a[i] * b[i] % mod;
- ntt(a, true);
- return a;
-}
diff --git a/math/transforms/ntt.cpp b/math/transforms/ntt.cpp
deleted file mode 100644
index ca605d3..0000000
--- a/math/transforms/ntt.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-constexpr ll mod = 998244353, root = 3;
-
-void ntt(vector<ll>& a, bool inv = false) {
- int n = sz(a);
- auto b = a;
- ll r = inv ? powMod(root, mod - 2, mod) : root;
-
- for (int s = n / 2; s > 0; s /= 2) {
- ll ws = powMod(r, (mod - 1) / (n / s), mod), w = 1;
- for (int j = 0; j < n / 2; j += s) {
- for (int k = j; k < j + s; k++) {
- ll u = a[j + k], t = a[j + s + k] * w % mod;
- b[k] = (u + t) % mod;
- b[n/2 + k] = (u - t + mod) % mod;
- }
- w = w * ws % mod;
- }
- swap(a, b);
- }
- if (inv) {
- ll div = powMod(n, mod - 2, mod);
- for (auto& x : a) x = x * div % mod;
-}}
diff --git a/math/transforms/orTransform.cpp b/math/transforms/orTransform.cpp
deleted file mode 100644
index eb1da44..0000000
--- a/math/transforms/orTransform.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-void fft(vector<ll>& a, bool inv = false) {
- int n = sz(a);
- for (int s = 1; s < n; s *= 2) {
- for (int i = 0; i < n; i += 2 * s) {
- for (int j = i; j < i + s; j++) {
- ll& u = a[j], &v = a[j + s];
- tie(u, v) = inv ? pair(v, u - v) : pair(u + v, u);
-}}}}
diff --git a/math/transforms/seriesOperations.cpp b/math/transforms/seriesOperations.cpp
deleted file mode 100644
index 4743674..0000000
--- a/math/transforms/seriesOperations.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-vector<ll> poly_inv(const vector<ll>& a, int n) {
- vector<ll> q = {powMod(a[0], mod-2, mod)};
- for (int len = 1; len < n; len *= 2){
- vector<ll> a2 = a, q2 = q;
- a2.resize(2*len), q2.resize(2*len);
- ntt(q2);
- for (int j : {0, 1}) {
- ntt(a2);
- for (int i = 0; i < 2*len; i++) a2[i] = a2[i]*q2[i] % mod;
- ntt(a2, true);
- for (int i = 0; i < len; i++) a2[i] = 0;
- }
- for (int i = len; i < min(n, 2*len); i++) {
- q.push_back((mod - a2[i]) % mod);
- }}
- return q;
-}
-
-vector<ll> poly_deriv(vector<ll> a) {
- for (int i = 1; i < sz(a); i++)
- a[i-1] = a[i] * i % mod;
- a.pop_back();
- return a;
-}
-
-vector<ll> poly_integr(vector<ll> a) {
- if (a.empty()) return {0};
- a.push_back(a.back() * powMod(sz(a), mod-2, mod) % mod);
- for (int i = sz(a)-2; i > 0; i--)
- a[i] = a[i-1] * powMod(i, mod-2, mod) % mod;
- a[0] = 0;
- return a;
-}
-
-vector<ll> poly_log(vector<ll> a, int n) {
- a = mul(poly_deriv(a), poly_inv(a, n));
- a.resize(n-1);
- a = poly_integr(a);
- return a;
-}
-
-vector<ll> poly_exp(vector<ll> a, int n) {
- vector<ll> q = {1};
- for (int len = 1; len < n; len *= 2) {
- vector<ll> p = poly_log(q, 2*len);
- for (int i = 0; i < 2*len; i++)
- p[i] = (mod - p[i] + (i < sz(a) ? a[i] : 0)) % mod;
- vector<ll> q2 = q;
- q2.resize(2*len);
- ntt(p), ntt(q2);
- for (int i = 0; i < 2*len; i++) p[i] = p[i] * q2[i] % mod;
- ntt(p, true);
- for (int i = len; i < min(n, 2*len); i++) q.push_back(p[i]);
- }
- return q;
-}
diff --git a/math/transforms/xorTransform.cpp b/math/transforms/xorTransform.cpp
deleted file mode 100644
index f9d1d82..0000000
--- a/math/transforms/xorTransform.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-void fft(vector<ll>& a, bool inv = false) {
- int n = sz(a);
- for (int s = 1; s < n; s *= 2) {
- for (int i = 0; i < n; i += 2 * s) {
- for (int j = i; j < i + s; j++) {
- ll& u = a[j], &v = a[j + s];
- tie(u, v) = pair(u + v, u - v);
- }}}
- if (inv) for (ll& x : a) x /= n;
-}