Skip to content

Commit 7aaecd3

Browse files
committed
Speedup precomputation a bit
1 parent da90632 commit 7aaecd3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cp-algo/math/fft.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ namespace cp_algo::math::fft {
2929
bitr.resize(maxn);
3030
for(int i = 1; i < maxn; i *= 2) {
3131
int ti = i / 2;
32+
ftype arg = pi / i;
33+
point base = std::polar(1., arg);
34+
point cur = 1.;
3235
for(int j = 0; j < i; j++) {
33-
w[i + j] = std::polar(ftype(1), pi * j / i);
36+
if((j & 15) == 0) {
37+
cur = std::polar(1., j * arg);
38+
}
39+
w[i + j] = cur;
40+
cur *= base;
3441
if(ti) {
3542
bitr[i + j] = 2 * bitr[ti + j % ti] + (j >= ti);
3643
}

0 commit comments

Comments
 (0)