What is the smith normal form decomposition $U^{-1}DV^{-1}$ of
$$ \pmatrix{q&1&0&0&0&0&1\\1&q&1&0&0&0&0\\0&1&q&1&0&0&0\\0&0&1&q&1&0&0\\0&0&0&1&q&1&0\\0&0&0&0&1&q&1\\1&0&0&0&0&1&q} $$ where $q\in\Bbb Z$?
I am very much interested in $U,V$ as well ( the entire decomposition).
According to http://www-math.mit.edu/~rstan/transparencies/snf.pdf, the Smith Normal form for a nonsingular matrix $A$ is $$ \textrm{Diag}(e_1,e_2,e_3,e_4,e_5,e_6,e_7), $$ where $e_1\cdots e_i = \gcd \big( i\times i\textrm{ minors of }A \big)$.
Assume that $A$ is nonsingular. In fact, it turns out that $q=-2$ is the only value of $q$ such that $A$ is singular. This is because $$ \det A = (q+2)(q^3-q^2-2q+1)^2.$$ If $q\neq -2$, then we have $e_1=e_2=e_3=e_4=e_5=1$, and $$ \begin{align} e_6&=\gcd(q^6-5q^4+6q^2-1,q(q^4-4q^2+3)-1) \\ &= (q^3-q^2-2q+1)\gcd(q^3+q^2-2q-1,q^2+q-1) \\ &=(q^3-q^2-2q+1) \gcd(q^2+q-1,q+1) \\&=(q^3-q^2-2q+1) \gcd(q+1, -1)\\ &=q^3-q^2-2q+1.\end{align} $$ Finally, $$ e_6e_7=\det A = (q+2)(q^3-q^2-2q+1)^2.$$ This gives $$ e_7=(q+2)(q^3-q^2-2q+1).$$
If $q=-2$, then the Smith Normal Form for $A$ contains $0$ in the diagonal. Elementary row and column operations take $A$ to a matrix with all zero on the last row and the last column. Thus, we have $e_1=e_2=e_3=e_4=e_5=1$, and $$ e_6=(q^3-q^2-2q+1)(q^3+q^2-2q-1)=7, \ \ e_7=0. $$