I have implemented the multiplication for two byte array and it works fine. More precisely, I need to multiply a 64 bytes operand with a 32 bytes one.
I implemented it the easiest way : I make a double loop and I compute the product for each byte in each array.
So for the specific values, it takes 64 * 32 = 2048
steps.
I tried to optimize it with the Karatsuba
method.
So I proceed the following way :
a
has a length of 64 bytes and b
has a length of 32 bytes.
We split a
in : a = p * 16^(32) + q
(so p
and q
have both a length of 32 bytes) and compute : a * b = p * b * 16^(32) + q * b
(products are compute with my function described before).
I get the right result but it takes the same time to compute : 2 multiplications of two 32 bytes array : 32 * 32 * 2 = 64 * 32 = 2048
.
My question is the following : to optimize my multiplication using Karatsuba
, should I program it totally recursively ? In other way it will never be faster ?
Thank you in advance :)