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

**URL:** <https://discourse.julialang.org/t/checking-condition-on-matrix-array-element-wise-modulo-an-integer/60954>\
**Category:** General Usage\
**Tags:** question, array\
**Created:** [May 11, 2021, 2:05pm UTC](https://discourse.julialang.org/t/checking-condition-on-matrix-array-element-wise-modulo-an-integer/60954 "2021-05-11T14:05:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scipham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scipham/32/24977_2.png) [@scipham](https://discourse.julialang.org/u/scipham)\
**Post date:** [May 11, 2021, 2:05pm UTC](https://discourse.julialang.org/t/checking-condition-on-matrix-array-element-wise-modulo-an-integer/60954/1 "2021-05-11T14:05:47Z")

</div>

My aim is to check whether a matrix (i.e. a 2D array) modulo d is Symplectic (see condition on wikipedia: [Symplectic matrix - Wikipedia](https://en.wikipedia.org/wiki/Symplectic_matrix)). 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):

```julia
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]
