# Checking condition on matrix/array element-wise modulo an integer

My aim is to check whether a matrix (i.e. a 2D array) modulo d is Symplectic (see condition on wikipedia: Symplectic matrix - Wikipedia). That is, whether there is any Symplectic matrix in the set of matrices that are element-wise equal modulo some number d. This is for a given M that is an element in this set.

Is there any logical and especially efficient way to check such a condition involving matrixmultiplication without the need to loop through (possibly) infinite matrices? The condition without modulo d condition is now simply implemented this way (with tolerance 0.001 and M an 2n x 2n array):

``````omega = [zeros((n,n)) Matrix(1I, n, n)); -Matrix(1I, n, n) zeros((n,n))]

isSymplec = maximum(abs.(transpose(M)*(omega*M) - omega)) < 0.001
``````

Just as an simple example: The array/matrix [1 0 0 0; 1 1 0 0; 0 0 1 1; 0 0 0 1] is not symplectic but has a modulo 2 symplectic “equivalent”: [1 0 0 0; 1 1 0 0; 0 0 1 -1; 0 0 0 1]