_images/heading.svg

The zmodn package provides a class for representing and performing operations in the ring of integers modulo \(n\) (\(\mathbb{Z}/n\mathbb{Z}\)). The package is built on top of NumPy for efficient array operations, making it suitable for applications in cryptography, computer algebra, and other fields requiring modular arithmetic.

Features

  • Perform arithmetic operations (addition, subtraction, multiplication, division, power).

  • Compute the modular inverse.

  • Handle matrix operations in modular arithmetic, including matrix addition, subtraction, multiplication, exponentiation, and inversion.

  • Compare elements modular arithmetic.

  • Seamless integration with NumPy arrays.

Installation

To zmodn package can use pip:

$ cd zmodn
$ pip install -e .

Quick Start

Here is basic example of using the zmodn package:

from zmodn import Zmodn

a = Zmodn([1, 2, 7], 5)
b = Zmodn([3, 4, 2], 5)

print(a)  # Output: [1 2 2] (mod 5)
print(a + b)  # Output: [4 1 4] (mod 5)
print(a * b)  # Output: [3 3 4] (mod 5)
print(a.mod_inv())  # Output: [1 3 3] (mod 5)

License

zmodn is licensed under the terms of the MIT license. See the license file for details.

Contact

For questions or issues, please open an issue on GitHub or contact the maintainer directly. You can also join our Discord community for discussions, support, and updates: Math & Code Discord Server Join us to connect with other users, get help, and stay updated on the latest developments!

Contributing

We welcome contributions to zmodn library! If you have an idea for a new feature or improvement, please feel free to create an issue or submit a pull request.

To contribute to the zmodn library, you will need to:

  1. Fork the repository.

  2. Create a new branch for your changes.

  3. Make your changes to the code.

  4. Add tests to ensure that your changes work correctly.

  5. Push your branch to the fork.

  6. Create a pull request to merge your changes into the main repository.

  7. Please be sure to follow the coding style guide and add documentation for any new features or changes that you make.

We appreciate your contributions to the zmodn library!

Citation

If this library was useful to you in your research, please cite us. Following the GitHub citation standards, here is the recommended citation.

@software{Sanchez_Alejandro_2020,
   title = {{Zmodn}: Practical Modular Arithmetic Using NumPy},
   author = {Sánchez, Alejandro},
   month = {11},
   year = {2023},
   url = {https://github.com/asanchezyali/Zmodn},
}
Sánchez, A. (2023). Zmodn: Practical Modular Arithmetic Using NumPy. [Computer software]. https://github.com/asanchezyali/Zmodn

Last update: Sep 10, 2024