matrixzq
Functions to carry out operations on matrices over Zq (Z/qZ) in pure Python without using Numpy or Scipy.
All matrix elements are expected to be nonnegative integers in the range [0, q-1]. All computations are carried out modulo q, where q is an integer greater than 1.
The modulus q is stored as a global variable __Q.
It must be set using the set_modulus() function before calling functions that set or carry out arithmetic operations
(add, multiply, etc.) on the matrix elements.
If the modulus q is not a prime then any operation that involves division (invert, solve) is undefined.
Documentation
We have provided basic Python functions rather than a more-complicated class so you can easily extract and work with the underlying list of lists.
History
-
v1.2.0 (2026-10-07)
- Fixed problem in
invertwhen leading element is zero - Fixed
determinantfor 1x1 matrix - Added stricter check that input to
new_matrixis properly rectangular - Added method
new_matrix_from_string
- Fixed problem in
-
v1.1.1 (2024-10-11)
- Fixed error in determinant method when adding prior total to a 2 x 2 matrix.
-
v1.1.0 (2024-02-13)
- Added new functions
sprint_matrixandsprint_vectorto print directly to strings. - Added
roundfrac2intto round a fraction to an integer without using float operations. - Change name of test module from
matrixzq_t.pytotest_matrixzq.pyto work better with pytest.
- Added new functions
Acknowledgements
This code was inspired by and some parts are derived from LinearAlgebraPurePython.py by Thom Ives
https://github.com/ThomIves/BasicLinearAlgebraToolsPurePy
https://integratedmlai.com/basic-linear-algebra-tools-in-pure-python-without-numpy-or-scipy/
David Ireland
https://di-mgt.com.au/contact/
This document last updated 2026-10-07
Metadata
Release files for matrixzq 1.2.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 | Provenance | |
|---|---|---|---|---|
| matrixzq-1.2.0.tar.gz | 11.6 kB | Without provenance | Details |
Release files / matrixzq-1.2.0.tar.gz
| Download URL | matrixzq-1.2.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00ff440ace33695078748f9c75959e89cdf9bf4355250fefb1e8959b1c1607bf
|
|
BLAKE2b-256 checksum How to use checksums |
cb80a7ad101f318fa482f98c48a83b7eb9669b2db6ecedddcceca9df95f97ff2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Security for matrixzq 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.