MCPcopy Create free account
hub / github.com/atcoder/ac-library / convolution_fft

Function convolution_fft

atcoder/convolution.hpp:199–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198template <class mint, internal::is_static_modint_t<mint>* = nullptr>
199std::vector<mint> convolution_fft(std::vector<mint> a, std::vector<mint> b) {
200 int n = int(a.size()), m = int(b.size());
201 int z = (int)internal::bit_ceil((unsigned int)(n + m - 1));
202 a.resize(z);
203 internal::butterfly(a);
204 b.resize(z);
205 internal::butterfly(b);
206 for (int i = 0; i < z; i++) {
207 a[i] *= b[i];
208 }
209 internal::butterfly_inv(a);
210 a.resize(n + m - 1);
211 mint iz = mint(z).inv();
212 for (int i = 0; i < n + m - 1; i++) a[i] *= iz;
213 return a;
214}
215
216} // namespace internal
217

Callers 1

convolutionFunction · 0.85

Calls 5

bit_ceilFunction · 0.85
butterflyFunction · 0.85
butterfly_invFunction · 0.85
sizeMethod · 0.45
invMethod · 0.45

Tested by

no test coverage detected