Skip to content

Commit 05e100d

Browse files
committed
add docs now
1 parent 5dd22f5 commit 05e100d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

library/convolution/xor_convolution.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#pragma once
22
#include "../math/mod_division.hpp"
3+
//! https://codeforces.com/blog/entry/127823
4+
//! @code
5+
//! vi c = xor_conv(a, b);
6+
//! // must have sz(a) == sz(b) == a power of 2
7+
//! // c[k] = sum of a[i]*b[j] where i^j==k
8+
//! @endcode
9+
//! @time O(n log n)
10+
//! @space O(n)
311
void fwht(int n, vi& a) {
4-
for (int i = 1; i != n; i <<= 1)
5-
for (int j = 0; j != n; j += i << 1)
6-
for (int k = 0; k != i; k++) {
12+
for (int i = 1; i < n; i *= 2)
13+
for (int j = 0; j < n; j += 2 * i) rep(k, 0, i) {
714
int x = a[j + k], y = a[i + j + k];
815
a[j + k] = (x + y) % mod;
916
a[i + j + k] = (x - y + mod) % mod;

0 commit comments

Comments
 (0)