Reputation: 1069
I'm training my C++ and I'm trying to write a library that'll be able to represent the following number using XOR linked lists:
999999999 * ( [i=0]Σ[999999999] 1000000000 ^ i )
For example if my number was 711381450277869054011, it'll be represented like this:
711 * 1000000000^2 + 381450277 * 1000000000^1 + 869054011 * 1000000000^0
Or simply:
711 * X^2 + 381450277 * X^1 + 869054011 * X^0
I overloaded the *
operator for my class, but I think the algorithm I used is clumsy.
I was going to go for Karatsuba algorithm, but since it's recursive, it'll lead to stack overflows.
Then I checked Toom-3 algorithm. I liked it, but I couldn't apply it because I still didn't program negative numbers yet.
My question is: What algorithm you suggest, would be best for polynomial multiplication ? Is there any good algorithms I need to see ?
Upvotes: 1
Views: 879
Reputation: 1419
You can use Fast Fourier transform to perform it. There also exists non-recursive implementation of it.
Upvotes: 3