Conjugacy class size formulas for linear groups of degree two

This article gives formulas for the number of conjugacy classes as well as the sizes of individual conjugacy classes for the general linear group of degree two and some other related groups, both for a finite field of size $$q$$ and for some related rings.

For a finite field of size $$q$$
In the formulas below, the field size is $$q$$. The characteristic of the field is a prime number $$p$$. $$q$$ is a prime power with underlying prime $$p$$. We let $$r = \log_pq$$, so $$q = p^r$$ and $$r$$ is a nonnegative integer.