@@ -201,16 +201,17 @@ namespace cp_algo::math::fft {
201
201
void mul (auto &a, auto const & b) {
202
202
size_t N = size (a) + size (b) - 1 ;
203
203
if (std::max (size (a), size (b)) > (1 << 23 )) {
204
+ using T = std::decay_t <decltype (a[0 ])>;
204
205
// do karatsuba to save memory
205
206
auto n = (std::max (size (a), size (b)) + 1 ) / 2 ;
206
- auto a0 = to<std::vector>(a | std::views::take (n));
207
- auto a1 = to<std::vector>(a | std::views::drop (n));
208
- auto b0 = to<std::vector>(b | std::views::take (n));
209
- auto b1 = to<std::vector>(b | std::views::drop (n));
207
+ auto a0 = to<std::vector<T, big_alloc<T>> >(a | std::views::take (n));
208
+ auto a1 = to<std::vector<T, big_alloc<T>> >(a | std::views::drop (n));
209
+ auto b0 = to<std::vector<T, big_alloc<T>> >(b | std::views::take (n));
210
+ auto b1 = to<std::vector<T, big_alloc<T>> >(b | std::views::drop (n));
210
211
a0.resize (n); a1.resize (n);
211
212
b0.resize (n); b1.resize (n);
212
- auto a01 = to<std::vector>(std::views::zip_transform (std::plus{}, a0, a1));
213
- auto b01 = to<std::vector>(std::views::zip_transform (std::plus{}, b0, b1));
213
+ auto a01 = to<std::vector<T, big_alloc<T>> >(std::views::zip_transform (std::plus{}, a0, a1));
214
+ auto b01 = to<std::vector<T, big_alloc<T>> >(std::views::zip_transform (std::plus{}, b0, b1));
214
215
checkpoint (" karatsuba split" );
215
216
mul (a0, b0);
216
217
mul (a1, b1);
0 commit comments