Skip to content

Commit 2d03521

Browse files
committed
fix
1 parent 1103794 commit 2d03521

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cp-algo/math/fft.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,15 @@ namespace cp_algo::math::fft {
282282
}
283283
cp_algo::checkpoint("mod join");
284284
}
285+
auto make_copy(auto &&x) {
286+
return x;
287+
}
285288
void cyclic_mul(auto &a, auto const& b, size_t k) {
286289
return cyclic_mul(a, make_copy(b), k);
287290
}
288291
void mul(auto &a, auto &&b) {
289292
size_t N = size(a) + size(b) - 1;
290-
if(N > (1 << 19)) {
293+
if(N > (1 << 19)) {
291294
size_t NN = std::bit_ceil(N);
292295
a.resize(NN);
293296
b.resize(NN);
@@ -298,7 +301,12 @@ namespace cp_algo::math::fft {
298301
}
299302
}
300303
void mul(auto &a, auto const& b) {
301-
mul(a, make_copy(b));
304+
size_t N = size(a) + size(b) - 1;
305+
if(N > (1 << 19)) {
306+
mul(a, make_copy(b));
307+
} else {
308+
mul_truncate(a, b, N);
309+
}
302310
}
303311
}
304312
#endif // CP_ALGO_MATH_FFT_HPP

0 commit comments

Comments
 (0)