  Given any polynomial $p$ in $C[X]$, we show that the set of irreducible
matrices satisfying $p(A)=0$ is finite. In the specific case $p(X)=X^2-nX$, we
count the number of irreducible matrices in this set and analyze the arising
sequences and their asymptotics. Such matrices turn out to be related to
generalized compositions and generalized partitions.
