gh-37980: Fix order computation for linear groups GL(n, R) and SL(n, R)
#36881 introduced some wrong results for orders of linear groups since
it did not check whether the base ring is a field. We add the necessary
checks as well as formulas for some further cases, namely $\mathbb{Z}$
and $\mathbb{Z}/q\mathbb{Z}.$ Finally, we add a `NotImplementedError`
for the cases that are not supported.
The formula for the general linear group over $\mathbb{Z}/q\mathbb{Z}$
is taken from https://math.stackexchange.com/a/2044571, and for the
order of the special linear group we use the group isomorphism induced
by the determinant.
Fixes #37934.
URL: https://github.com/sagemath/sage/pull/37980
Reported by: Sebastian A. Spindler
Reviewer(s): Travis Scrimshaw