PyAlgebraLib
v1.0.0
簡單的Python程序使用有效的算法(例如Karatsuba的算法)進行代數操作,以用於乘法或擴展的Euclidean算法用於Great Common Divisor(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)輸出是帶有結果的字符串或元組(S),請查看特定功能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
| 功能名稱 | 輸入 | 輸出 |
|---|---|---|
| 去除序列 | A(str) | str:刪除了所有領先零的修改後字符串 |
| 大Qual | x(str),y(str) | 布爾:如果x大於或等於y,則為false,否則為 |
| 劃分 | x(str),y(str),r(int)= 10 | str:x的商除以y,在radix r中表達 |
| ElementaryAdd | x(str),y(str),c(str),r(int)= 10 | 元組:(結果(str),攜帶(str)) |
| 基本詞 | x(str),y(str),c(str),r(int)= 10 | 元組:(結果(str),攜帶(str)) |
| 小學 | x(str),y(str),z(str),c(str),r(int)= 10 | 元組:(結果(str),攜帶(str)) |
| 添加 | x(str),y(str),r(int)= 10 | str:radix r中x + y的結果 |
| 減去 | x(str),y(str),r(int)= 10 | str:radix r中x -y的結果 |
| 乘 | x(str),y(str),r(int)= 10 | str:radix r中x * y的結果 |
| Karatsuba | x(str),y(str),r(int)= 10 | str:x * y使用radix r中的karatsuba算法的結果 |
| 超核素 | x(str),y(str),r(int)= 10 | 元組:( gcd(str),a(str),b(str)) |
| 模塊化 | n(str),m(str),r(int)= 10 | str:radix r中n mod m的結果 |
| 模塊化 | x(str),y(str),m(str),r(int)= 10 | str:radix r中(x + y)mod m的結果 |
| 模塊化 | x(str),y(str),m(str),r(int)= 10 | str:radix r中(x -y)mod m的結果 |
| 模塊化 | x(str),y(str),m(str),r(int)= 10 | str:radix r中(x * y)mod m的結果 |
| 模塊化 | a(str),m(str),r(int)= 10 | str:radix r中mod m的逆,或打印“不存在逆” |