Exact Gram-matrix count over a split quadratic algebra
Let $k$ be a finite field of order $q$, let $0\le a\le M$, and put $K=k\times k$ with involution $\overline{(x,y)}=(y,x)$. Let $J\in M_M(K)$ and $T\in M_a(K)$ be Hermitian matrices with unit determinants. The number of ordered tuples $x_1,\ldots,x_a\in K^M$ satisfying $$\overline{x_i}^{t}Jx_j=T_{ij}\qquad(1\le i,j\le a)$$ is $$q^{a(M-a)}\prod_{i=0}^{a-1}(q^M-q^i).$$