理解 Harvey & van der Hoeven 2019 算法(大整数乘法)
Understanding Harvey & van der Hoeven 2019 algorithm (huge integer multiplication)
我需要尽可能高效地乘以几个大的长整数。
我正在尝试实现 Harvey & van der Hoeven 2019 整数乘法算法,但我仍然无法理解它背后的定义和数学,尤其是 Agarwal–Cooley 算法。
任何有助于理解此算法的信息,例如实际示例或一些伪代码,我们将不胜感激。
请记住,Big O notation 的定义是存在一些 x≥x₀,对于所有此类 x,某些函数 |f(x)|≤εg(x)。
Harvey & van der Hoeven (2019) 算法的问题在于涉及的 x₀ 相当大。因此,对于大多数输入,他们的算法提供了一种低效乘以整数的方法。但是,对于非常大的数字,该算法确实给出了 O(n log n) 算法。
但这些数字有多大? David Harvey,作者之一 states:
The new algorithm is not really practical in its current form, because the proof given in our paper only works for ludicrously large numbers. Even if each digit was written on a hydrogen atom, there would not be nearly enough room available in the observable universe to write them down.
On the other hand, we are hopeful that with further refinements, the algorithm might become practical for numbers with merely billions or trillions of digits. If so, it may well become an indispensable tool in the computational mathematician's arsenal.
因此,如果您认真对待既定目标——快速乘以大数——这种算法不适合您。
我需要尽可能高效地乘以几个大的长整数。
我正在尝试实现 Harvey & van der Hoeven 2019 整数乘法算法,但我仍然无法理解它背后的定义和数学,尤其是 Agarwal–Cooley 算法。
任何有助于理解此算法的信息,例如实际示例或一些伪代码,我们将不胜感激。
请记住,Big O notation 的定义是存在一些 x≥x₀,对于所有此类 x,某些函数 |f(x)|≤εg(x)。
Harvey & van der Hoeven (2019) 算法的问题在于涉及的 x₀ 相当大。因此,对于大多数输入,他们的算法提供了一种低效乘以整数的方法。但是,对于非常大的数字,该算法确实给出了 O(n log n) 算法。
但这些数字有多大? David Harvey,作者之一 states:
The new algorithm is not really practical in its current form, because the proof given in our paper only works for ludicrously large numbers. Even if each digit was written on a hydrogen atom, there would not be nearly enough room available in the observable universe to write them down.
On the other hand, we are hopeful that with further refinements, the algorithm might become practical for numbers with merely billions or trillions of digits. If so, it may well become an indispensable tool in the computational mathematician's arsenal.
因此,如果您认真对待既定目标——快速乘以大数——这种算法不适合您。