summaryrefslogtreecommitdiff
path: root/content/math/transforms
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2025-01-18 03:05:17 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2025-01-18 03:08:45 +0100
commit52ba871e0de9399f77da4b5b0d2c33a2dd6eb6a1 (patch)
tree493152c57313f651cae92f88b6f24af2ede1b6d6 /content/math/transforms
parent69c98b39106cc2776f6a4983e548338ac24b5e84 (diff)
changes to bitwise convolutions
- modify or/and transform to remove unnecessary reversal - or transform is now sum over subsets, add note about this - remove old sum over subsets DP
Diffstat (limited to 'content/math/transforms')
-rw-r--r--content/math/transforms/andTransform.cpp2
-rw-r--r--content/math/transforms/bitwiseTransforms.cpp4
-rw-r--r--content/math/transforms/orTransform.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/content/math/transforms/andTransform.cpp b/content/math/transforms/andTransform.cpp
index 1e9cfc0..9e40c74 100644
--- a/content/math/transforms/andTransform.cpp
+++ b/content/math/transforms/andTransform.cpp
@@ -4,5 +4,5 @@ void fft(vector<ll>& a, bool inv = false) {
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);
+ tie(u, v) = inv ? pair(u - v, v) : pair(u + v, v);
}}}}
diff --git a/content/math/transforms/bitwiseTransforms.cpp b/content/math/transforms/bitwiseTransforms.cpp
index b98ea94..17f3163 100644
--- a/content/math/transforms/bitwiseTransforms.cpp
+++ b/content/math/transforms/bitwiseTransforms.cpp
@@ -4,8 +4,8 @@ void bitwiseConv(vector<ll>& a, bool inv = false) {
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) = inv ? pair(u - v, v) : pair(u + v, v); // AND
+ //tie(u, v) = inv ? pair(u, v - u) : 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/content/math/transforms/orTransform.cpp b/content/math/transforms/orTransform.cpp
index d0122bf..6503a68 100644
--- a/content/math/transforms/orTransform.cpp
+++ b/content/math/transforms/orTransform.cpp
@@ -4,5 +4,5 @@ void fft(vector<ll>& a, bool inv = false) {
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);
+ tie(u, v) = inv ? pair(u, v - u) : pair(u, v + u);
}}}}