We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2694be8 commit bf95bb7Copy full SHA for bf95bb7
1 file changed
src/alfred/math/conv.hpp
@@ -130,6 +130,18 @@ inline std::vector<ModInt<mod>> add_conv(
130
std::vector<ModInt<mod>> g
131
) {
132
if (f.empty() || g.empty()) return {};
133
+ if (f.size() < g.size()) {
134
+ std::swap(f, g);
135
+ }
136
+ if (g.size() < 128) {
137
+ std::vector<ModInt<mod>> h(f.size() + g.size() - 1);
138
+ for (size_t i = 0; i < f.size(); i++) {
139
+ for (size_t j = 0; j < g.size(); j++) {
140
+ h[i + j] += f[i] * g[j];
141
142
143
+ return h;
144
145
int len = f.size() + g.size() - 1, lim;
146
for (lim = 1; lim < len; lim <<= 1);
147
f.resize(lim, 0), g.resize(lim, 0);
0 commit comments