PyAlgebraLib
v1.0.0
多重化のためのKaratsubaのアルゴリズムや拡張ユークリッドアルゴリズムなどの効率的なアルゴリズムを使用して、代数操作を実行する簡単なPythonプログラム(GCD)のための拡張ユークリッドアルゴリズム。
このプログラムは、軽量(依存関係なし)であり、非常に効率的であることを目的としています。
pip install PyAlgebraLibモジュールをインポートできます。
import PyAlgebraLib as paベース2からベース16までの数値で動作することができます。各操作のベース間を変換することなく。
注:各番号を入力する必要があり、ベースを除く文字列として返されます。
pip install PyAlgebraLibモジュールをインポートできます。
import PyAlgebraLib as pa次に、次のような操作を実行できます。
pa . karatsuba ( "364da" , "-13f" , 16 ) # Multiplication (karatsuba algorithm)
pa . extEuclid ( "-1460" , "44321521" , 7 ) # GCD (Extended)出力は、結果を伴う文字列またはタプルのいずれかで、詳細については特定の関数Docstringsを調べてください。
例:
pa . extEuclid ( "-1460" , "44321521" , 7 )
# Output: ('1', '-20066304', '511')
pa . modularInversion ( "9a1aa8a02232" , "a6a722a" , 11 )
# Output: '3293845' - Addition
- Subtraction
- Multiplication (Normal "primary school method" + Karatsuba algorithm)
- Division
- GCD of 2 numbers (Extended Euclidean algorithm)
- Modular Arithmetic:
- Reduction
- Addition
- Subtraction
- Multiplication
- Inversion
| 関数名 | 入力 | 出力 |
|---|---|---|
| Removeleadingzeros | A(str) | STR:すべての主要なゼロを備えた変更された文字列が削除されました |
| Greaterorequal | x(str)、y(str) | bool:xがy以上の場合はtrue、それ以外の場合はfalse |
| 分ける | x(str)、y(str)、r(int)= 10 | str:xの商はyで割って、radix rで表されます |
| ElementaryAdd | x(str)、y(str)、c(str)、r(int)= 10 | タプル:( result(str)、carry(str)) |
| ElementarySub | x(str)、y(str)、c(str)、r(int)= 10 | タプル:( result(str)、carry(str)) |
| 小学校 | x(str)、y(str)、z(str)、c(str)、r(int)= 10 | タプル:( result(str)、carry(str)) |
| 追加 | x(str)、y(str)、r(int)= 10 | STR:基数rのx + yの結果 |
| 減算します | x(str)、y(str)、r(int)= 10 | STR:基数rのx -yの結果 |
| 乗算します | x(str)、y(str)、r(int)= 10 | STR:基数rのx * yの結果 |
| カラツバ | x(str)、y(str)、r(int)= 10 | str:radix rでkaratsubaアルゴリズムを使用したx * yの結果 |
| exteuclid | x(str)、y(str)、r(int)= 10 | タプル:(gcd(str)、a(str)、b(str)) |
| モジュラーリデクション | n(str)、m(str)、r(int)= 10 | STR:基数rのn mod mの結果 |
| モジュラー拡張 | x(str)、y(str)、m(str)、r(int)= 10 | STR:ラジックスRの(x + y)mod mの結果 |
| モジュラーサブトラクション | x(str)、y(str)、m(str)、r(int)= 10 | str:radixRの(x -y)mod mの結果 |
| モジュラー測定 | x(str)、y(str)、m(str)、r(int)= 10 | str:radixRの(x * y)mod mの結果 |
| モジュラーインバージョン | a(str)、m(str)、r(int)= 10 | STR:ラジックスRのmod mの逆か、または「逆は存在しない」印刷 |