How can I efficiently iterate over all h by n arrays made of 0s and 1s where all the rows and all the columns are distinct? At the moment I do this.
h = 10
n = 15
hxn = np.arange(h*n).reshape(h, -1)
for i in xrange(0, 2**(h*n)):
M = (i >> hxn) & 1
#DO WORK
But this includes lots of 2d arrays with rows or columns that are the same. I also don't care about the order of the rows or columns.
I don't want to just test each M to see if it has a duplicate row or column and discard those as that will be hugely inefficient. I would like to find a way just to iterate over the much smaller number of matrices with no duplicated row or column.