I have this matrix: $$ A= \begin{pmatrix} 2 & 5 & -1 & 2\\ -2 & -16 & -4 & 4 \\ -2 &-2 &0 &6 \end{pmatrix} $$ If we set K as the Image of this matrix, how do you find a basis of $ K $ of this form : $$( d_1 w_1 , \cdots , d_s w_s ), s \leq 4$$ such that we have that $( w_1 , \cdots , w_4 ) $ is a basis of $ \mathbb Z ^{3} $ and that $ d_i | d_{i+1} $
I must use the Smith normal form, but I'm blocked by the fact that I can't find a basis of the Image. In the correction of this exercice, their are using a method I'm not understanding.
I would firstly determine a basis of the image and then do the same computation as I usually do.


$\DeclareMathOperator{\im}{Im}\DeclareMathOperator{sp}{Span}\require{AMScd}$First, let us understand where all the maps are going in the Smith normal form:
\begin{CD} \mathbb{Z}^4 @>A>> \mathbb{Z}^3\\ @APAA @AAQA \\ \mathbb{Z}^4 @>>D> \mathbb{Z}^3 \end{CD}
$P$ and $Q$ are isomorphisms (invertible), $D$ is diagonal and $A = QDP^{-1}$. The point of $P$ and $Q$ is that they are a change of basis such that in the new basis, $A$ acts diagonally.
We want to compute the image of $A$, or equivalently, the image of $QDP^{-1}$.
First, I claim that $\im(A) = \im(QD)$ and this is because $P$ is invertible.
The general rule here is that if $A = BC$ and $C$ is invertible, then $\im(A) = \im(B)$.
Next, given any matrix, the image of that matrix is the same as the column space.
So what we have shown is that $\im(A) = \im(QD) = \sp\{\text{columns of $QD$}\}$.
Now the last step is what I said near the beginning: $P$ and $Q$ represent a change of basis. So the columns of $Q$ are a basis for $\mathbb{Z}^3$ and the columns of $P$ are a basis for $\mathbb{Z}^4$. (In fact, the same is true for $P^{-1}, Q^{-1}$ as well as $P^T$ and $Q^T$ or, more generally, any invertible matrix.)
So the columns of $Q$ are a basis for $\mathbb{Z^3}$ and the (non-zero) columns of $QD$ are a basis for $\im(A)$. Then it's just a matter of understanding how diagonal matrices act on other matrices. Multiplying by a diagonal matrix on the right multiplies the columns by the corresponding diagonal element. Multiplying by a diagonal matrix on the left multiplies the rows by the corresponding diagonal element.
This is why $QD$ is obtained from $Q$ by multiplying the columns by $-1, -2$, and $2$ respectively.