皮肤过敏用什么药| 巧克力和什么不能一起吃| 竖中指什么意思| 断交社保有什么影响| hi是什么| 什么弟什么兄| 长情是什么意思| 瑄字五行属什么| 六味地黄丸是治什么的| 介质是什么意思| 脑梗会有什么后遗症| 肠道感染用什么抗生素| gia是什么意思| 食蚁兽是什么动物| 粿条是什么做的| 疖肿是什么| 乳房痛是什么原因| 青皮是什么皮| 左氧氟沙星治什么| 八七年属什么的| 海参崴买什么便宜| 肛门坠胀是什么原因| 三个土是什么字怎么读| 菠萝蜜过敏什么症状| 大姨妈来能吃什么水果| iu什么意思| 王字旁一个玉读什么| 兔死狗烹是什么意思| 糖尿病人能吃什么| g750和au750有什么区别| p5是什么意思| 阳起石是什么东西| 壁虎的尾巴有什么作用| 上房揭瓦是什么意思| 男人要吃什么才能壮阳| 眼睛有眼屎是什么原因| 什么是偏旁什么是部首| 什么情况下吃速效救心丸| 粿是什么意思| 碳酸钙d3颗粒什么时候吃最好| 老花镜什么品牌好| 118什么意思| 蛇和什么属相相冲| 做爱时间短吃什么药好| 脚为什么会臭| 鸡蛋加什么吃壮阳持久| 肉桂茶是什么茶| 做梦梦到老公出轨代表什么预兆| 什么是什么的摇篮| 莲藕炒什么好吃| 坤位是什么方向| 吃什么会回奶| 嗓子痒痒是什么原因| 身上长瘊子是什么原因| 感染性发热是什么意思| 磷是什么| 虎和什么属相不合| 肠道细菌感染吃什么药| 梦见死人和棺材预示着什么| 脐橙是什么意思| 吴刚和嫦娥什么关系| 做水果捞用什么酸奶好| 巳蛇五行属什么| 双子座是什么象星座| 伤口增生是什么原因造成的| 没什么好怕| 什么是腺样体面容| 情未了什么意思| 字母哥什么位置| 吴亦凡为什么退出exo| 生化流产是什么原因造成的| 子水是什么水| 拉肚子应该挂什么科| 昕字五行属什么| strong什么意思| 草鱼喜欢吃什么食物| 卷柏属于什么植物| 口犬读什么| 孩子一直咳嗽不好是什么原因| 胆囊炎有什么症状表现| 手发抖是什么原因引起的年轻人| 家里为什么突然有床虱| 泉州和晋江什么关系| 炸毛是什么意思| 脾虚湿蕴证是什么意思| 煮海带放什么容易烂| 劳动局全称叫什么| 翌字五行属什么| 反胃想吐是什么原因| 李白是什么| 西沙必利片治什么病| 大电念什么| 什么是g点| 脸上长扁平疣是什么原因引起的| 康复治疗技术是什么| 低血糖吃什么药| 血红蛋白是什么意思| 腿硬邦邦的是什么原因| 婴儿八个月可以吃什么辅食| 运六月有什么说法| 人鱼线是什么| 抗甲状腺球蛋白抗体高是什么原因| 肩膀疼应该挂什么科| 姑姑的女儿叫什么| 银屑病用什么药膏| 喉咙痒痒的吃什么药| 一什么西瓜| 确立是什么意思| 六月份什么星座| 欲望是什么意思| 提高什么| 过敏性紫癜用什么药| 仙人掌煎鸡蛋治什么病| 通草和什么炖最催奶了| 胃胀不消化吃什么药| 四两拨千斤是什么意思| 乐得什么填词语| 心电图窦性心动过速是什么意思| 一什么山泉| 金牛男喜欢什么样的女生| 青蛙长什么样| 日本是什么时候投降的| 脚趾长痣代表什么意思| 海啸是什么| congee是什么意思| 浅笑是什么意思| 湿疹吃什么中药| 湿疣是什么病| 南极被称为什么| 聪明反被聪明误是什么意思| 任督二脉是什么意思| 吃生蚝有什么好处和坏处| 饮食男女是什么意思| 什么是不动产权证| 复查肺结节挂什么科| ca199偏高是什么意思| 小麦是什么| 胃酸多吃什么药| 余田是什么字| 力争是什么意思| 补办身份证需要带什么| 重症医学科是干什么的| 穿山甲用什么中药代替| 流产后吃什么水果好| 做完无痛人流需要注意什么| 细胞是什么| 可乐加味精女人喝了什么效果| 幽门螺旋杆菌吃什么药最好| 筠字五行属什么| 什么属相好| 子宫内膜薄是什么原因造成的| 突然发胖要警惕什么病| 四个横念什么| 黑鱼是什么鱼| 解表化湿是什么意思| 平产是什么意思| 长沙有什么大学| 什么山峻岭| 小孩拉肚子吃什么食物| 什么减肥效果最好| 前胸后背疼挂什么科| 青黛色是什么颜色| 促甲状腺素高是什么意思| 毓婷和金毓婷有什么区别| 人参果总皂苷是什么| 广基息肉是什么意思| 什么的玻璃| 老睡不着觉是什么原因| 心魔是什么意思| 宝典是什么意思| 草口耳是什么字| 痤疮用什么药膏最有效| 我的部首是什么| 喝什么牌子的水最健康| 乐捐是什么意思| 感冒适合吃什么饭菜| 梦见买面条有什么预兆| 献血前要注意什么| 产复欣颗粒什么时候吃| 胎儿靠什么吸收营养| 腹泻不能吃什么食物| 什么赴什么继| 黑鸟是什么鸟| 长春新碱是什么药| 吃银耳有什么功效和作用| 漏蛋白是什么原因造成的| 气管炎不能吃什么食物| 日语一库一库是什么意思| 黄子韬爸爸是干什么的| 小孩放屁很臭是什么原因| 高知是什么意思| 香菜什么时候种最合适| 老干局是干什么的| 6.22什么星座| 打下手什么意思| 鲁迅为什么弃医从文| 鲭鱼是什么鱼| 中气不足是什么意思| 高大上是什么意思| 心电图能检查出什么病| 不吃肉对身体有什么影响| 冤家是什么意思| 什么是矫正视力| 副高是什么意思| 不可漂白是什么意思| 平均血小板体积偏低是什么原因| 4月29号是什么星座的| 诗韵是什么意思| 大便绿色什么原因| 草莓什么时候成熟| 常流鼻血是什么原因| 豆腐不能和什么一起吃| 龙眼什么时候成熟| 白粉病用什么药| 眼袋肿了是什么原因| 指甲盖有竖纹是什么原因| 粘胶纤维是什么| 情何以堪 什么意思| 乙肝e抗体阴性是什么意思| 眼睛充血是什么原因引起的| 指甲变黄是什么原因| 黑道日为什么还是吉日| 旗袍穿什么鞋子好看图| 正师级相当于地方什么级别| 庚午日五行属什么| 做梦放鞭炮什么意思| 宇宙的尽头是什么| 阳历六月是什么星座| 西洋参补什么| 血滴子是什么| 山东登州府现在叫什么| 欧亚斯密什么意思| 肺气肿什么症状| 除日是什么意思| 神经炎是什么症状| 好学不倦什么意思| 大脑供血不足头晕吃什么药最好| 苹果是什么季节的水果| 长脸适合什么眉形| 蚰蜒是什么| pw是什么意思| 黄金是什么生肖| 睡觉趴着睡是什么原因| 头发为什么会掉| 梅毒的病原体是什么| 总是嗜睡是什么原因| 冠脉ct和冠脉造影有什么区别| 月经来头疼是什么原因引起的| 宫颈管搔刮术是什么| plcc是什么意思| 画蛇添足什么意思| 12月15日是什么星座| 今年43岁属什么| 无氧运动是什么| 仲夏夜是什么意思| 半身不遂是什么原因引起的| 阴茎不硬是什么原因| 恐龙为什么会灭绝| 复出是什么意思| 门齿是指什么地方| 洁癖是什么意思| 失眠吃什么好睡觉| 榴莲什么季节吃最好| 回乡偶书的偶书是什么意思| 百度Jump to content

三明将设食品安全专家委员会 拟任成员名单...

From Wikipedia, the free encyclopedia
The Sch?nhage–Strassen algorithm is based on the fast Fourier transform (FFT) method of integer multiplication. This figure demonstrates multiplying 1234 × 5678 = 7006652 using the simple FFT method. Base 10 is used in place of base 2w for illustrative purposes.
Sch?nhage (on the right) and Strassen (on the left) playing chess in Oberwolfach, 1979
百度 我们建议把相关的行政处罚权集中到一个部门,避免再出现你推我我推你的情况。

The Sch?nhage–Strassen algorithm is an asymptotically fast multiplication algorithm for large integers, published by Arnold Sch?nhage and Volker Strassen in 1971.[1] It works by recursively applying fast Fourier transform (FFT) over the integers modulo . The run-time bit complexity to multiply two n-digit numbers using the algorithm is in big O notation.

The Sch?nhage–Strassen algorithm was the asymptotically fastest multiplication method known from 1971 until 2007. It is asymptotically faster than older methods such as Karatsuba and Toom–Cook multiplication, and starts to outperform them in practice for numbers beyond about 10,000 to 100,000 decimal digits.[2] In 2007, Martin Fürer published an algorithm with faster asymptotic complexity.[3] In 2019, David Harvey and Joris van der Hoeven demonstrated that multi-digit multiplication has theoretical complexity; however, their algorithm has constant factors which make it impossibly slow for any conceivable practical problem (see galactic algorithm).[4]

Applications of the Sch?nhage–Strassen algorithm include large computations done for their own sake such as the Great Internet Mersenne Prime Search and approximations of π, as well as practical applications such as Lenstra elliptic curve factorization via Kronecker substitution, which reduces polynomial multiplication to integer multiplication.[5][6]

Description

[edit]

This section has a simplified version of the algorithm, showing how to compute the product of two natural numbers , modulo a number of the form , where is some fixed number. The integers are to be divided into blocks of bits, so in practical implementations, it is important to strike the right balance between the parameters . In any case, this algorithm will provide a way to multiply two positive integers, provided is chosen so that .

Let be the number of bits in the signals and , where is a power of two. Divide the signals and into blocks of bits each, storing the resulting blocks as arrays (whose entries we shall consider for simplicity as arbitrary precision integers).

We now select a modulus for the Fourier transform, as follows. Let be such that . Also put , and regard the elements of the arrays as (arbitrary precision) integers modulo . Observe that since , the modulus is large enough to accommodate any carries that can result from multiplying and . Thus, the product (modulo ) can be calculated by evaluating the convolution of . Also, with , we have , and so is a primitive th root of unity modulo .

We now take the discrete Fourier transform of the arrays in the ring , using the root of unity for the Fourier basis, giving the transformed arrays . Because is a power of two, this can be achieved in logarithmic time using a fast Fourier transform.

Let (pointwise product), and compute the inverse transform of the array , again using the root of unity . The array is now the convolution of the arrays . Finally, the product is given by evaluating

This basic algorithm can be improved in several ways. Firstly, it is not necessary to store the digits of to arbitrary precision, but rather only up to bits, which gives a more efficient machine representation of the arrays . Secondly, it is clear that the multiplications in the forward transforms are simple bit shifts. With some care, it is also possible to compute the inverse transform using only shifts. Taking care, it is thus possible to eliminate any true multiplications from the algorithm except for where the pointwise product is evaluated. It is therefore advantageous to select the parameters so that this pointwise product can be performed efficiently, either because it is a single machine word or using some optimized algorithm for multiplying integers of a (ideally small) number of words. Selecting the parameters is thus an important area for further optimization of the method.

Details

[edit]

Every number in base B, can be written as a polynomial:

Furthermore, multiplication of two numbers could be thought of as a product of two polynomials:

Because, for : , we have a convolution.

By using FFT (fast Fourier transform), used in the original version rather than NTT (Number-theoretic transform),[7] with convolution rule; we get

That is; , where is the corresponding coefficient in Fourier space. This can also be written as: .

We have the same coefficients due to linearity under the Fourier transform, and because these polynomials only consist of one unique term per coefficient:

and

Convolution rule:

We have reduced our convolution problem to product problem, through FFT.

By finding the FFT of the polynomial interpolation of each , one can determine the desired coefficients.

This algorithm uses the divide-and-conquer method to divide the problem into subproblems.

Convolution under mod N

[edit]
, where .

By letting:

and

where is the nth root, one sees that:[8]

This mean, one can use weight , and then multiply with after.

Instead of using weight, as , in first step of recursion (when ), one can calculate:

In a normal FFT which operates over complex numbers, one would use:

However, FFT can also be used as a NTT (number theoretic transformation) in Sch?nhage–Strassen. This means that we have to use θ to generate numbers in a finite field (for example ).

A root of unity under a finite field GF(r), is an element a such that or . For example GF(p), where p is a prime number, gives .

Notice that in and in . For these candidates, under its finite field, and therefore act the way we want .

Same FFT algorithms can still be used, though, as long as θ is a root of unity of a finite field.

To find FFT/NTT transform, we do the following:

First product gives contribution to , for each k. Second gives contribution to , due to mod .

To do the inverse:

or

depending whether data needs to be normalized.

One multiplies by to normalize FFT data into a specific range, where , where m is found using the modular multiplicative inverse.

Implementation details

[edit]

Why N = 2M + 1 mod N

[edit]

In Sch?nhage–Strassen algorithm, . This should be thought of as a binary tree, where one have values in . By letting , for each K one can find all , and group all pairs into M different groups. Using to group pairs through convolution is a classical problem in algorithms.[9]

Having this in mind, help us to group into groups for each group of subtasks in depth k in a tree with

Notice that , for some L. This makes N a Fermat number. When doing mod , we have a Fermat ring.

Because some Fermat numbers are Fermat primes, one can in some cases avoid calculations.

There are other N that could have been used, of course, with same prime number advantages. By letting , one have the maximal number in a binary number with bits. is a Mersenne number, that in some cases is a Mersenne prime. It is a natural candidate against Fermat number

In search of another N

[edit]

Doing several mod calculations against different N, can be helpful when it comes to solving integer product. By using the Chinese remainder theorem, after splitting M into smaller different types of N, one can find the answer of multiplication xy [10]

Fermat numbers and Mersenne numbers are just two types of numbers, in something called generalized Fermat Mersenne number (GSM); with formula:[11]

In this formula, is a Fermat number, and is a Mersenne number.

This formula can be used to generate sets of equations, that can be used in CRT (Chinese remainder theorem):[12]

, where g is a number such that there exists an x where , assuming

Furthermore; , where a is an element that generates elements in in a cyclic manner.

If , where , then .

How to choose K for a specific N

[edit]

The following formula is helpful, finding a proper K (number of groups to divide N bits into) given bit size N by calculating efficiency :[13]

N is bit size (the one used in ) at outermost level. K gives groups of bits, where .

n is found through N, K and k by finding the smallest x, such that

If one assume efficiency above 50%, and k is very small compared to rest of formula; one get

This means: When something is very effective; K is bound above by or asymptotically bound above by

Pseudocode

[edit]

Following algorithm, the standard Modular Sch?nhage-Strassen Multiplication algorithm (with some optimizations), is found in overview through [14]

  1. Split both input numbers a and b into n coefficients of s bits each.

    Use at least ?? bits to store them,

    to allow encoding of the value ??
  2. Weight both coefficient vectors according to (2.24) with powers of θ by performing cyclic shifts on them.
  3. Shuffle the coefficients ?? and ?? .
  4. Evaluate ?? and ?? . Multiplications by powers of ω are cyclic shifts.
  5. Do n pointwise multiplications ?? in ??. If SMUL is used recursively, provide K as parameter. Otherwise, use some other multiplication function like T3MUL and reduce modulo ?? afterwards.
  6. Shuffle the product coefficients ??.
  7. Evaluate the product coefficients ??.
  8. Apply the counterweights to the ?? according to (2.25). Since ?? it follows that ??
  9. Normalize the ?? with ?? (again a cyclic shift).
  10. Add up the ?? and propagate the carries. Make sure to properly handle negative coefficients.
  11. Do a reduction modulo ??.
  • T3MUL = Toom–Cook multiplication
  • SMUL = Sch?nhage–Strassen multiplication
  • Evaluate = FFT/IFFT

Further study

[edit]

For implemantion details, one can read the book Prime Numbers: A Computational Perspective.[15] This variant differs somewhat from Sch?nhage's original method in that it exploits the discrete weighted transform to perform negacyclic convolutions more efficiently. Another source for detailed information is Knuth's The Art of Computer Programming.[16]

Optimizations

[edit]

This section explains a number of important practical optimizations, when implementing Sch?nhage–Strassen.

Use of other multiplications algorithm, inside algorithm

[edit]

Below a certain cutoff point, it's more efficient to use other multiplication algorithms, such as Toom–Cook multiplication.[17]

Square root of 2 trick

[edit]

The idea is to use as a root of unity of order in finite field ( it is a solution to equation ), when weighting values in NTT (number theoretic transformation) approach. It has been shown to save 10% in integer multiplication time.[18]

Granlund's trick

[edit]

By letting , one can compute and in combination with CRT (Chinese Remainder Theorem) to find exact values of multiplication uv[19].

References

[edit]
  1. ^ Sch?nhage, Arnold; Strassen, Volker (1971). "Schnelle Multiplikation gro?er Zahlen" [Fast multiplication of large numbers]. Computing (in German). 7 (3–4): 281–292. doi:10.1007/BF02242355. S2CID 9738629.
  2. ^ Karatsuba multiplication has asymptotic complexity of about and Toom–Cook multiplication has asymptotic complexity of about

    Van Meter, Rodney; Itoh, Kohei M. (2005). "Fast Quantum Modular Exponentiation". Physical Review. 71 (5): 052320. arXiv:quant-ph/0408006. Bibcode:2005PhRvA..71e2320V. doi:10.1103/PhysRevA.71.052320. S2CID 14983569.

    A discussion of practical crossover points between various algorithms can be found in: Overview of Magma V2.9 Features, arithmetic section Archived 2025-08-07 at the Wayback Machine

    Luis Carlos Coronado García, "Can Sch?nhage multiplication speed up the RSA encryption or decryption? Archived", University of Technology, Darmstadt (2005)

    The GNU Multi-Precision Library uses it for values of at least 1728 to 7808 64-bit words (33,000 to 150,000 decimal digits), depending on architecture. See:

    "FFT Multiplication (GNU MP 6.2.1)". gmplib.org. Retrieved 2025-08-07.

    "MUL_FFT_THRESHOLD". GMP developers' corner. Archived from the original on 24 November 2010. Retrieved 3 November 2011.

    "MUL_FFT_THRESHOLD". gmplib.org. Retrieved 2025-08-07.

  3. ^ Fürer's algorithm has asymptotic complexity
    Fürer, Martin (2007). "Faster Integer Multiplication" (PDF). Proc. STOC '07. Symposium on Theory of Computing, San Diego, Jun 2007. pp. 57–66. Archived from the original (PDF) on 2025-08-07.
    Fürer, Martin (2009). "Faster Integer Multiplication". SIAM Journal on Computing. 39 (3): 979–1005. doi:10.1137/070711761. ISSN 0097-5397.

    Fürer's algorithm is used in the Basic Polynomial Algebra Subprograms (BPAS) open source library. See: Covanov, Svyatoslav; Mohajerani, Davood; Moreno Maza, Marc; Wang, Linxiao (2025-08-07). "Big Prime Field FFT on Multi-core Processors". Proceedings of the 2019 on International Symposium on Symbolic and Algebraic Computation (PDF). Beijing China: ACM. pp. 106–113. doi:10.1145/3326229.3326273. ISBN 978-1-4503-6084-5. S2CID 195848601.

  4. ^ Harvey, David; van der Hoeven, Joris (2021). "Integer multiplication in time " (PDF). Annals of Mathematics. Second Series. 193 (2): 563–617. doi:10.4007/annals.2021.193.2.4. MR 4224716. S2CID 109934776.
  5. ^ This method is used in INRIA's ECM library.
  6. ^ "ECMNET". members.loria.fr. Retrieved 2025-08-07.
  7. ^ Becker, Hanno; Hwang, Vincent; J. Kannwischer, Matthias; Panny, Lorenz (2022). "Efficient Multiplication of Somewhat Small Integers using Number-Theoretic Transforms" (PDF).
  8. ^ Lüders, Christoph (2014). "Fast Multiplication of Large Integers: Implementation and Analysis of the DKSS Algorithm". p. 26.
  9. ^ Kleinberg, Jon; Tardos, Eva (2005). Algorithm Design (1 ed.). Pearson. p. 237. ISBN 0-321-29535-8.
  10. ^ Gaudry, Pierrick; Alexander, Kruppa; Paul, Zimmermann (2007). "A GMP-based implementation of Sch?nhage-Strassen's large integer multiplication algorithm" (PDF). p. 6.
  11. ^ S. Dimitrov, Vassil; V. Cooklev, Todor; D. Donevsky, Borislav (1994). "Generalized Fermat-Mersenne Number Theoretic Transform". p. 2.
  12. ^ S. Dimitrov, Vassil; V. Cooklev, Todor; D. Donevsky, Borislav (1994). "Generalized Fermat-Mersenne Number Theoretic Transform". p. 3.
  13. ^ Gaudry, Pierrick; Kruppa, Alexander; Zimmermann, Paul (2007). "A GMP-based Implementation of Sch?nhage-Strassen's Large Integer Multiplication Algorithm" (PDF). p. 2.
  14. ^ Lüders, Christoph (2014). "Fast Multiplication of Large Integers: Implementation and Analysis of the DKSS Algorithm". p. 28.
  15. ^ R. Crandall & C. Pomerance. Prime Numbers – A Computational Perspective. Second Edition, Springer, 2005. Section 9.5.6: Sch?nhage method, p. 502. ISBN 0-387-94777-9
  16. ^ Knuth, Donald E. (1997). "§ 4.3.3.C: Discrete Fourier transforms". The Art of Computer Programming. Vol. 2: Seminumerical Algorithms (3rd ed.). Addison-Wesley. pp. 305–311. ISBN 0-201-89684-2.
  17. ^ Gaudry, Pierrick; Kruppa, Alexander; Zimmermann, Paul (2007). "A GMP-based implementation of Sch?nhage-Strassen's large integer multiplication algorithm" (PDF). p. 7.
  18. ^ Gaudry, Pierrick; Kruppa, Alexander; Zimmermann, Paul (2007). "A GMP-based implementation of Sch?nhage-Strassen's large integer multiplication algorithm" (PDF). p. 6.
  19. ^ Gaudry, Pierrick; Kruppa, Alexander; Zimmermann, Paul (2007). "A GMP-based implementation of Sch?nhage-Strassen's large integer multiplication algorithm" (PDF). p. 6.
脚抽筋是什么原因引起的 折射率是什么意思 孕期阴道炎可以用什么药 唯粉是什么意思 长期口腔溃疡挂什么科
看指甲去医院挂什么科 肾结石有什么症状表现 肠胃不舒服挂什么科 拉肚子可以吃什么药 刘晓庆什么星座
葵花宝典是什么意思 遇到黄鼠狼是什么征兆 羊肚菌为什么那么贵 智齿发炎肿痛吃什么药 衬衫搭配什么裤子好看
男性什么适合长期泡水喝 肾阴虚吃什么 尿路感染 吃什么 肌酐低是什么意思啊 急性湿疹用什么药膏
女人梦到小蛇什么预兆qingzhougame.com 七月半是什么日子hcv8jop7ns1r.cn 熬夜吃什么保健品hcv9jop6ns1r.cn 乳糖不耐受什么意思hcv9jop7ns9r.cn 日本艺伎是干什么的hcv9jop1ns4r.cn
乡长是什么级别hcv7jop5ns4r.cn 海南简称是什么hcv9jop5ns8r.cn 脖子为什么有颈纹hcv9jop3ns0r.cn cc什么意思hcv9jop6ns1r.cn 北京摇号什么时候开始的hcv9jop3ns5r.cn
一天吃一个苹果有什么好处hcv9jop0ns3r.cn 乙肝e抗体阴性是什么意思hcv9jop1ns3r.cn 孕妇什么时候吃dha效果比较好hcv9jop4ns2r.cn mmc是什么意思inbungee.com 盐酸氟桂利嗪胶囊治什么病tiangongnft.com
什么是avhcv9jop4ns0r.cn 慢性活动性胃炎是什么意思hcv9jop3ns8r.cn 晚上睡觉喉咙干燥是什么原因hcv8jop3ns5r.cn 喝石斛水有什么禁忌hcv7jop5ns5r.cn 排卵日和排卵期有什么区别hcv7jop7ns2r.cn
百度