I want to fix the first row and first column of the matrices to be 0 1 2..only such matrices is to be filtered among all possible 3x3 matrices with entries from 0,1,2. Later I have to check one condition for those filtered ones. The condition is as follows:
i + j = a_ij (the corresponding entry of one matrix) = m , m + k = a_mk
j + k = a_jk (entry from j th row and k th column) = n, i + n = a_in
I have to display only those matrices among all combinations which satisfy a_mk = a_in
. Its more like checking associativity. Can anyone help to complete this?
from itertools import product
import numpy as np
m=3
n=3
x = [[list(i[x:x+m]) for x in range(0, len(i), m)] for i in product("012", repeat=m*n)]
print(len(x))
A=[]
for j in x:
j = np.array(j)
for i in range(3):
if j[0][i] == i:
if j[i][0] == i:
A.append(j)
print(len(A))
So far I have been able to write so far.
Here is the Modifyed Code