Skip to content

Commit

Permalink
gr_poly_mul_karatsuba: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Apr 7, 2024
1 parent e882beb commit 940102e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/gr_poly/mul_karatsuba.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/

#include "gr_vec.h"
#include "gr_poly.h"

/* TODO: a self-recursive variant that can reuse scratch space. */
Expand Down Expand Up @@ -77,11 +78,9 @@ _gr_poly_mul_karatsuba(gr_ptr res, gr_srcptr f, slong flen, gr_srcptr g, slong g
}

/* v -= f0 g0 */
status |= _gr_poly_sub(v, v, vlen, res, 2 * m - 1, ctx);
vlen = FLINT_MAX(vlen, 2 * m - 1);
status |= _gr_vec_sub(v, v, res, 2 * m - 1, ctx);
/* v -= f1 g1 */
status |= _gr_poly_sub(v, v, vlen, GR_ENTRY(res, 2 * m, sz), f1len + g1len - 1, ctx);
vlen = FLINT_MAX(vlen, f1len + g1len - 1);
status |= _gr_vec_sub(v, v, GR_ENTRY(res, 2 * m, sz), f1len + g1len - 1, ctx);

/* Finally add the middle part. */
status |= _gr_poly_add(GR_ENTRY(res, m, sz), GR_ENTRY(res, m, sz), vlen, v, vlen, ctx);
Expand Down

0 comments on commit 940102e

Please sign in to comment.