Skip to content

Instantly share code, notes, and snippets.

View algmyr's full-sized avatar

Anton Älgmyr algmyr

  • Zürich
View GitHub Profile
@Chillee
Chillee / fft.cpp
Last active October 18, 2024 00:06
FFT
template <int maxn> struct FFT {
constexpr static int lg2(int n) { return 32 - __builtin_clz(n - 1); }
const static int MAXN = 1 << lg2(maxn);
typedef complex<double> cpx;
int rev[MAXN];
cpx rt[MAXN];
FFT() {
rt[1] = cpx{1, 0};
for (int k = 2; k < MAXN; k *= 2) {
cpx z[] = {1, polar(1.0, M_PI / k)};