Keivan,
I'm not sure if this is the best way to do this (e.g. if there's a
naive approach we teach in undergrad linear algebra, it escapes me at
the moment), but I'm a graph theorist so it's the approach that
readily comes to mind, and easy to implement. Treat your graphs as
incidence matrices of bipartite graphs. We could check if two
matrices were isomorphic in this way, but the better approach for "do
I have a new object" is generally to compute canonical labels.
The following computes the number of inequivalent matrices.
for n in range(1,6):
uniquematrices = {}
for M in MatrixSpace(GF(2),n,n):
a,b = M.dimensions()
G = Graph([(i+1,-j-1) for i in range(a) for j in range(b) if M[i,j]])
L = G.canonical_label(partition = [[v for v in G if v>0],[v
for v in G if v<0]])
key = L.graph6_string()
uniquematrices[key] = M
print len(uniquematrices)
It's dog slow, but the first 3 numbers come up pretty quick: 2,7,37.
That's enough to find it in Sloane's:
http://oeis.org/search?q=2%2C7%2C36 and the first hit has a huge
number of terms of the sequence. That sequence has a couple of
references that might help, if this is too slow.