Idempotents in $n \times n$ matrices with entries in $Z_2$ OEIS has the following sequence and formula http://oeis.org/A132186 for counting how many $n \times n$ idempotents there are over $GF(2)$.
But how does one find/generate them? I haven't been able to find any resource for this.
I assume that this is solved for $GF(2)$, is it also solved in general?
 A: An idempotent matrix $X$ satisfies $X^2-X=0$, therefore it has minimal polynomial either $t$, $t-1$ or $t^2-t$. The first two cases give the zero and identity matrices. The second one decomposes into linear factors so $X$ must be diagonalizable, with eigenvalues some number of zeros and some number of ones. It follows that all the idempotents are the conjugacy classes of these matrices.
Now by the orbit stabilizer theorem, the size of the conjugacy class of $X$ is precisely $|G|/|C_G(X) |$, where $G=GL_n(\mathbb{F}_2)$ and $C_G(X) $ is the centralizer of $X$. Applying this to the diagonal matrix $D_k$ with $k$ ones and $n-k$ zeros on the diagonal (these are representatives for each conjugacy class we're interested in), we see that the centralizer consists of matrices that are block diagonal $A\oplus B$, with $A$ in $GL_k(\mathbb{F}_2)$ and $B$ in $GL_{n-k} (\mathbb{F}_2)$.
Since there is a formula for the order of $GL_n$ over a finite field, putting all together you should get a formula for the total number of idempotents.
To generate the matrices, you need coset representatives $g_i $ for $G/C_G(X)$ (computer programs give you these), and then the idempotent matrices will be precisely the $g_iXg_i^{-1}$ (for each $X=D_k$).
