We study the functions that count matrices of given rank over a finite field
with specified positions equal to zero. We show that these matrices are
q-analogues of permutations with certain restricted values. We obtain a
simple closed formula for the number of invertible matrices with zero diagonal,
a q-analogue of derangements, and a curious relationship between invertible
skew-symmetric matrices and invertible symmetric matrices with zero diagonal.
In addition, we provide recursions to enumerate matrices and symmetric matrices
with zero diagonal by rank, and we frame some of our results in the context of
Lie theory. Finally, we provide a brief exposition of polynomiality results for
enumeration questions related to those mentioned, and give several open
questions.Comment: 29 pages, 2 figures, v2: one additional result, some formulas
simplified, and a new reference; v3: corrected typo