crypto-bigint icon indicating copy to clipboard operation
crypto-bigint copied to clipboard

Improve multiplication

Open pdogr opened this issue 4 years ago • 2 comments

The current implementation of mul_wide uses schoolbook multiplication, which has complexity of the order of O(n*m) where n, m are the number of limbs in the operands.

Perhaps we should switch to an asymptotically better algorithm like karatsuba multiplication. If so I would be happy to work on this.

pdogr avatar Feb 01 '22 00:02 pdogr

Yes indeed, it's listed as a TODO and we'd be happy to switch to Karatsuba (see also #1).

There are a few other algorithms I've seen that also may be potentially faster than Karatsuba, although I don't have references to them offhand and Karatsuba is a perfectly reasonable starting place.

tarcieri avatar Feb 01 '22 00:02 tarcieri

@tarcieri I've tried to implement Toom-Cook multiplication.

The current impl uses arguments of the form &[Limb], &mut [Limb], there is definitely a much better way to do this. Please let me know what you think.

pdogr avatar Feb 03 '22 09:02 pdogr

As of #649 we support Karatsuba. Closing.

tarcieri avatar Sep 19 '24 16:09 tarcieri