# Computing all binary matrices with given row and column sum

Given $a,b \in \mathbb{N}$, and $r,c \in \mathbb{N}$. I want to construct all matrices $A \in \{0,1\}^{a \times b}$ such that each row of $A$ contains exactly $r$ ones and each column of $A$ contains exactly $c$ ones. Generally $a \neq b$ and $r \neq c$.

If it makes constructing these matrices $A$ any simpler, one can also assume that each row and column in $A\cdot A^T$ appears the same number of times.

My first thought was that one can set the first row and column of $A$ without loss of generality and then compute all possible permutations of the first row and column and combine them together. Most of the time this does not yield a matrix with the desired properties because one does not use the information about the rows and column simultaneously.

Does anyone have any ideas? One can further assume that $a+b \leq 30$ holds.