Fix $n\geq 2$. Let $A$ be the matrix whose rows and columns are indexed by pairs $(a,b)\in \mathbb{Z}/n\mathbb{Z}$ such that $a,b$ generate $\mathbb{Z}/n\mathbb{Z}$ (the number of such pairs is $\phi(n)\psi(n)$, where $\phi(n)$ is the Euler phi-function and $\psi(n)$ is the Dedekind $\psi$-function), with the $((a,b),(c,d))$ entry defined by $$ A_{(a,b),(c,d)}=\left\{ \begin{array}{rl} 1, & \mathrm{if}\ c=a\ \mathrm{and}\ d=b-a\\ 1, & \mathrm{if}\ c=a-b\ \mathrm{and}\ d=b\\ 0, & \mathrm{otherwise}. \end{array} \right. $$ The characteristic polynomial of $A$ factors quite a bit. What is the explanation for this behavior? Is $A$ diagonalizable (over $\mathbb{C}$)? What is the rank of $A$? This matrix arises in the congruence properties mod $n$ of the entries of Stern's triangle.
Here are these polynomials for $n\leq 11$. I write $[k]$ for an irreducible polynomial (over $\mathbb{Q}$) of degree $k$. $$ n=2:\ \ (x+1)(x-1)(x-2) $$ $$ n=3:\ \ x^2(x-1)^3(x-2)(x^2+x+2) $$ $$ n=4:\ \ x^2(x+1)^3(x-1)^4(x-2)(x^2-x+2) $$ $$ n=5:\ \ x^4(x+1)^2(x-1)^7(x-2)(x^2+1)^2(x^2-x+2)(x^4-x^2+4) $$ $$ n=6:\ \ x^6(x+1)^4(x-1)^7(x-2)(x^2+2x+2)(x^2-2x+2)(x^2+x+2) $$ $$ n=7:\ \ x^{10}(x+1)^4(x-1)^{11}(x-2)(x^2+2)(x^4+3)^2[4]^2[4] $$ $$ n=8:\ \ x^8(x+1)^8(x-1)^{13}(x-2)(x^2+1)^2(x^2-x+2)(x^4-x^2+4)[4][4] $$ $$ n=9:\ \ x^{14}(x+1)^6(x-1)^{17}(x-2)(x^2-2x+2)^2(x^2+x+2)^3[6]^2[6]^2 $$ $$ n=10:\ \ x^{12}(x+1)^{10}(x-1)^{15}(x-2)(x^2-x+2)(x^2+1)^2 [4]^2[4][4][4][4] $$ $$ n=11:\ \ x^{20}(x+1)^{10}(x-1)^{21}(x-2)(x^2+2x+2)(x^2-2x+2) (x^2+x+2)[3]^2[4]^2[4]^2[8]^2[12]^2. $$ The factor $x-2$ is clear since the all 1's vector is an eigenvector with eigenvalue 2.