Algorithm for SNF: D&F page 479.
For \(A\in \operatorname{Mat}(m\times n; R)\) over \(R\) any PID, \(\mathrm{SNF}(A)\) is a matrix whose diagonal entries are the invariant factors. How to compute \(\mathrm{SNF}(A)\): take \(A = \operatorname{diag}(a_i)\) where \(a_i = d_i/d_{i-1}\) and \(d_i\) is the \(\gcd\) of the determinants of all \(i\times i\) minors of \(A\). \(A\sim B\) are similar \(\iff \mathrm{SNF}(A) = \mathrm{SNF}(B)\).