Suppose you are given a finite abelian group $G$ represented by a (square) matrix $M$, that is $$G \cong \mathbb{Z}^n /M \cong \mathbb{Z}^n /S, $$ where $S$ is the Smith normal form of $M$.
My question is, given an element $v$ of $G$ written as a vector $v \in \mathbb{Z}^n$ (seen as a vector in the cokernel of $M$), how can it be transformed in a vector $v'\in \mathbb{Z}^n$ in the cokernel of $S$?
The transformation you're looking for is simply $v'=Pv$, where $PMQ=S$ is the Smith decomposition of $S$ : $P,Q$ are invertible and $S$ is diagonal with each diagonal coefficient dividing the next.
Let $g\in G$. If we present $G$ as $\frac{{\mathbb Z}^n}{M{\mathbb Z}^n}$, we see that $g$ is represented by a coset $m=v+M{\mathbb Z}^n$ for some $v\in {\mathbb Z}^n$. Then :
$$ \begin{array}{lcl} m &=& v+M{\mathbb Z}^n \\ &=& v+P^{-1}SQ^{-1}{\mathbb Z}^n \\ &=& v+P^{-1}S{\mathbb Z}^n \ (\textrm{because}\ Q \ \textrm{is invertible}) \\ &=& P^{-1}Pv+P^{-1}S{\mathbb Z}^n \\ &=& P^{-1}(Pv+S{\mathbb Z}^n) \\ &=& P^{-1}(v'+S{\mathbb Z}^n) \\ \end{array} $$
Note that the two cosets, $v+M{\mathbb Z}^n$ and $v'+S{\mathbb Z}^n$ are not equal but they are related by the isomorphism $P^{-1}$.