D
D
DVirt2019-01-02 20:00:36
Programming
DVirt, 2019-01-02 20:00:36

A very fast algorithm for multiplying long numbers, where to dig?

Hello.
It is required to multiply a very long number very quickly and many times, for example:
a long number (more than two million digits in a number) is multiplied by a random number in a limited range of 2 ^ 8. (number of operations over 40 million).
Googling this information, I have so far found algorithms:
Fast multiplication: Karatsuba method
Fast multiplication: Toom-Cook method
Fast multiplication: Schnhage-Strassen method
Discrete Fourier transform
Fast Fourier transform
algorithm Schoenhage-Strassen algorithm for multiplying integers
But, unfortunately, in more detail in did not understand them.
I also looked towards GPU computing on Cuda, but, unfortunately, I think that this technology will not suit me, because. I don’t know and haven’t found yet how fast multiplication works on long numbers.
Please specify where to dig on this topic?
Or maybe someone will throw in a formula or implementation of this algorithm in some PL.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Tikhonov, 2019-01-03
@DVirt

Don't dig in the direction of CUDA in vain, multiplication and addition are GPU's forte.
Trite, we translate a super long number into an array, multiply the array by a 1-byte number, take into account shifts. You don’t even need to write your own kernels, the cublas library has everything you need. The result in terms of speed is very surprising.

A
A, 2019-01-10
@AndrBell

When multiplying a number from a heap of millionth digits, only the first senior ones will be important.
The rest are younger - an error.
The more to the right, the more useless is their contribution to the result - computational noise!
What is the accuracy of multiplication?
Isn't it enough to follow this rule?
Multiply, for example, a number consisting of the following digits:
1 00000000000000 and any other (noise) , a total of one million digits:
for example:
OR any other number, with a difference in digits on the right, for example:
Multiply any of them for example by 5, the result of multiplying by 5 will be:
Fast?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question