# Matrix operations “Modulus->non-prime” problem

I am using Mathematica 10.4.1.0. When I specify the "Modulus" option to be a non-prime, the functions RowReduce and MatrixRank return the error

"Value of option Modulus -> (non-prime number) should be a prime number or zero".


I have tried a variety of matrices and Mathematica can process none of them, unless I choose "Modulus->(prime)".

I would like to easily find the row reduced form and the rank of small ($n<10$) square matrices, modulo a non-zero positive integer. Can the inbuilt functions be corrected, or is there an alternative easy way to accomplish these tasks?

EDIT: Perhaps a motivated Mathematica coder could produce a general row reduction package for matrices over Rings. I was able to cobble together something from the following sources.

This article goes through row reduction of matrices with elements from rings: Gaussian Elimination: Workhorse of Linear Algebra.

And this Mathematica package by John H. Matthews has an explicit Gaussian elimination algorithm with different pivoting options, see 0309Pivoting.nb within the package.

• If you post a specific example that would be helpful. – Daniel Lichtblau Apr 16 '17 at 17:50

The problem is with division: $\mathbb{Z}/n \mathbb{Z}$ is not a field unless $n$ is prime. So, if you don't do division (which will leave your "pivots" not equal to $1$) there is no problem with non-prime modulus, otherwise, it's a bit problematic.
Edit you can easily implement row reduction over $\mathbb{Z}/n \mathbb{Z}$ yourself. It won't be super fast.