Multiply Numbers using Number Theoretic Transform

バージョン 1.0.2 (4.1 KB) 作成者: David Hill
Multiply very numbers (hexadecimal or decimal) together efficiently using Number Theoretic Transform (NTT)
ダウンロード: 58
更新 2021/3/24

ライセンスの表示

Large Number Multiplier using Number Theoretic Transform (NTT). Quickly multiply two large numbers (either hexadecimal numbers or decimal numbers) together (less than approximately 500,000 (32-bit segments). Inputs to the multiply() function must be hexadecimal or decimal character arrays of at least 6 characters in length. Size can be up to 4 million characters each. The NTT should provide exact results (tested on several large inputs). I went through this exercise to learn about the NTT process and how it works. Output is of the same form as the input, either hexadecimal or decimal.

For example (inputs could be significantly larger):

a='1a2b3c4e5678987691827364abcdef1234567821123aabbcceeddff463723892736452';
b='9a8b7c6d5e4f123456473829ffddee1ffeeddaaccbb238edf1823938473627837463562aabbccddeeff2345678';
c=multiply(a,b);

Output:
c= '0fcc4478fdd013c81ae05b64c7bb3684de2ad903235d1f77200b0ccd60bc2ae10de191b86350c54c3632506364fd269e2bb91f08ffaf90110e75d19a688b025f5ad2ffe39f408feafd4f248b4e729270'

a='198583931643537581442143136962572284781970832530224711489217605344156699047702520914';
b='1417793757582264142991820210002764610425931296836066215122869608550065190067340067192259569688783751463851640';
Output:
c='281551058640350635133920212774963620686487650950043670801076786888070561874593787199498117484873007760364284017039572666137806333241698549708893818835351498777984006753645623564120972093198960'

引用

David Hill (2024). Multiply Numbers using Number Theoretic Transform (https://www.mathworks.com/matlabcentral/fileexchange/80305-multiply-numbers-using-number-theoretic-transform), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2020b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.0.2

Added new file

1.0.1

Added flexibility of using decimal numbers represented in a character string instead of hexadecimal inputs.

1.0.0