PyAlgebraLib
v1.0.0
GCD (Great Common Divisor)를위한 곱하기 또는 확장 된 유클리드 알고리즘을위한 Karatsuba 알고리즘과 같은 효율적인 알고리즘을 사용하여 대수 작업을 수행하는 간단한 Python 프로그램.
이 프로그램은 Lighweight (종속성 없음)이며 매우 효율적입니다.
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)출력은 결과와 함께 문자열이거나 튜플이며 자세한 내용은 특정 함수 문서를 살펴보십시오.
예:
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 : 모든 주요 0이 제거 된 수정 된 문자열이 제거되었습니다 |
| 그레이터 오레 쿼일 | x (str), y (str) | bool : x가 y보다 크거나 같으면 true, 그렇지 않으면 false |
| 나누다 | x (str), y (str), r (int) = 10 | str : x의 몫을 y로 나눈 값, radix r로 표현됩니다. |
| 초등학교 | 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의 결과 |
| 카라츠바 | x (str), y (str), r (int) = 10 | str : radix r에서 karatsuba 알고리즘을 사용한 x * y의 결과 |
| 엑테 클리드 | 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의 결과 |
| modularAddition | x (str), y (str), m (str), r (int) = 10 | str : radix r에서 (x + y) mod m의 결과 |
| modularSubtraction | 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의 결과 |
| modularInversion | a (str), m (str), r (int) = 10 | str : radix r의 mod m 또는 prints "versials is bicant" |