I need to multiply several 1000s digits long integers as efficiently as possible in Python. The numbers are read from a file.
I am trying to implement the Schönhage-Strassen algorithm for integer multiplication, but I am stuck on understanding the definition and mathematics behind it, specially the Fast Fourier Transform.
Any help to understand this algorithm, like a practical example or some pseudo-code would be highly appreciated.
Chapter 4.3.3 of Knuth's TAOCP describes it and also has some FFT pseudocode in other chapters that could be used for this.
1000 digits is "small" for Schönhage-Strassen to be really worth using. You may have a look at the Toom Cook multiplication. gmpy is a Python wrapper to gmp providing these functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With