Skip to main content

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

Read the 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 invert when leading element is zero
    • Fixed determinant for 1x1 matrix
    • Added stricter check that input to new_matrix is properly rectangular
    • Added method new_matrix_from_string
  • 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_matrix and sprint_vector to print directly to strings.
    • Added roundfrac2int to round a fraction to an integer without using float operations.
    • Change name of test module from matrixzq_t.py to test_matrixzq.py to work better with pytest.

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)

Source distribution for matrixzq 1.2.0
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.

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page