😁 Welcome!!
Contents
- 😁 Welcome!!
- Contents
- 🧮 PyAlgebraLib
- 🚀 Quick start
- ✨ Features
- 📦 Installation and Usage
- 📜 Supported operations:
🧮 PyAlgebraLib
Simple Python program to perform algebra operations using efficient algorithms like Karatsuba's algorithm for multiplication or Extended Euclidean Algorithm for great common divisor (GCD).
This program is intended to be lighweight (no dependencies) and very efficient.
🚀 Quick start
pip install PyAlgebraLib
You can import the module:
import PyAlgebraLib as ap
✨ Features
Can operate with numbers from base 2 to base 16. Without converting between bases in each operation.
Note: Each number has to be inputted and will be returned as a string, except the base.
📦 Installation and Usage
pip install PyAlgebraLib
You can import the module:
import PyAlgebraLib as ap
Then, you can perform operations like:
pa.karatsuba("364da","-13f", 16) # Multiplication (karatsuba algorithm)
pa.extEuclid("-1460","44321521", 7) # GCD (Extended)
The output is either a string or a tuple with the result(s), look into the specific function docstrings for more information.
Example:
pa.extEuclid("-1460","44321521", 7)
# Output: ('1', '-20066304', '511')
pa.modularInversion("9a1aa8a02232", "a6a722a", 11)
# Output: '3293845'
📜 Supported operations:
- Addition
- Subtraction
- Multiplication (Normal "primary school method" + Karatsuba algorithm)
- Division
- GCD of 2 numbers (Extended Euclidean algorithm)
- Modular Arithmetic:
- Reduction
- Addition
- Subtraction
- Multiplication
- Inversion
| Function Name | Input | Output |
|---|---|---|
| removeLeadingZeros | a (str) | str: The modified string with all leading zeros removed |
| greaterOrEqual | x (str), y (str) | bool: True if x is greater than or equal to y, False otherwise |
| divide | x (str), y (str), r (int) = 10 | str: The quotient of x divided by y, expressed in radix r |
| elementaryAdd | x (str), y (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| elementarySub | x (str), y (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| elementaryMult | x (str), y (str), z (str), c (str), r (int) = 10 | tuple: (result (str), carry (str)) |
| add | x (str), y (str), r (int) = 10 | str: Result of x + y in radix r |
| subtract | x (str), y (str), r (int) = 10 | str: Result of x - y in radix r |
| multiply | x (str), y (str), r (int) = 10 | str: Result of x * y in radix r |
| karatsuba | x (str), y (str), r (int) = 10 | str: Result of x * y using Karatsuba algorithm in radix r |
| extEuclid | x (str), y (str), r (int) = 10 | tuple: (gcd (str), a (str), b (str)) |
| modularReduction | n (str), m (str), r (int) = 10 | str: Result of n mod m in radix r |
| modularAddition | x (str), y (str), m (str), r (int) = 10 | str: Result of (x + y) mod m in radix r |
| modularSubtraction | x (str), y (str), m (str), r (int) = 10 | str: Result of (x - y) mod m in radix r |
| modularMultiplication | x (str), y (str), m (str), r (int) = 10 | str: Result of (x * y) mod m in radix r |
| modularInversion | a (str), m (str), r (int) = 10 | str: Inverse of a mod m in radix r, or prints "Inverse does not exist" |
Metadata
Release files for PyAlgebraLib 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyalgebralib-1.0.0.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyAlgebraLib-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / pyalgebralib-1.0.0.tar.gz
| Download URL | pyalgebralib-1.0.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
304295251d00cd5573abeabe81fbf39725005407f036e18418c922b78f0f3e05
|
|
BLAKE2b-256 checksum How to use checksums |
d92ddb437ef4db589a6376947e72da1f5a8285a8414f78eb4d50e82521666046
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / PyAlgebraLib-1.0.0-py3-none-any.whl
| Download URL | PyAlgebraLib-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d726143c5a4d69e66696cbfd8b9adaf2136f126980aa7abb2f37749f06f6209
|
|
BLAKE2b-256 checksum How to use checksums |
499eb5db0e6f6d0c3c049a4a352f2ab00f245a4e4c1c7fce9b4be7d41c2a0f56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|