Bases s.t. matrix for $T: V \rightarrow W$ is diagonal 
Let $T: V \rightarrow W$ be a linear map between finite-dimensional vector spaces. Show that there exist bases ${e_i}$ of $V$ and ${f_i}$ of $W$ such that the matrix of $T$ has entries $\alpha_{i,j} = 0$ if $i \neq j$, $\alpha_{i,i} = 1$ for $1 \leq i \leq rank(T)$, and $\alpha_{i,i} = 0$ for $i > rank(T)$. 

If I understand correctly, if we identify $V$ and $W$ with $F^n$ and $F^m$ where $F$ is the field and then (say $m \geq n$) identify $F^n$ with $F^m$ using the canonical injection, $T: F^m \rightarrow F^m$ is just a projection? (because the matrix described in the problem is like a projection matrix)
Not sure how to solve the problem or if my understanding is correct. Any help is appreciated.  
 A: Let $(f_1,\dots, f_r)$ be a basis of $T(V)$; complete it to a basis $(f_1, \dots, f_p)\;$ of $\;W\enspace (p\ge r)$.
For each $1\le i\le r$, let $e_i$ such that $T(e_i)=f_i$. These vectors are linearly independent. Denote $V'=\langle\,e_1,\dots, e_r\,\rangle$. As $V'\cap\ker T=0$, we have:
$$V=V'\oplus\ker T$$
by the rank-nullity theorem. Complete the basis $(e_1,\dots,e_r)$ of $V'$ with a basis $(e_{r+1},\dots, e_n)$ of $\ker T\enspace(n\ge r)$. Then $(e_1,\dots,e_n)$ is a basis of $V$. With these bases for $V$ and $W$, the matrix of $T$ has the prescribed form.
A: HINT: Let $\mathcal{B}=\{e_1,...,e_n\}$ a basis for $V$, and let $\mathcal{D}=\{f_1,...,f_m\}$ a basis for $W$; where $n=dimV$, $m=dimW$. Let $T$ a linear transformation; so
$$T(e_i)=\sum_{j=1}^m a_{ji}f_j$$
So the matrix respect to $\mathcal{B},\mathcal{D}$ is
$$
\begin{pmatrix}
a_{11}&\dots & a_{1n}\\
\dots& \dots&\dots\\
a_{m1}&\dots& a_{mn}
\end{pmatrix}.
$$ 
The kernel of $T$ is a subspace of $V$ so we can choose a basis for it and then complete to a basis for $V$. Suppose so that $\{v_{k+1},...,v_n\}$ is a base for $kerT$; and let $u_1,...,u_k$ $k$ linearity independent vector such that: $\{u_1,..,u_k,v_{k+1},..,v_n\}$ is a basis for $V$.
Now $T(v_{k+i})=0$ for every $i=1,..,n-k$, and 
$$T(v_i)=\sum_{j=1}^m a_{ji}f_j;$$
where $i$ now run from $1$ to $k$. Now the matrix is 
$$
\begin{pmatrix}
a_{11}&\dots & a_{1k}&0&\dots&0\\
\dots& \dots&\dots&0&\dots&0\\
a_{m1}&\dots& a_{mk} &0&\dots&0\\
\dots& \dots&\dots&0&\dots&0\\0&0&0&0&\dots&0
\end{pmatrix}.
$$ 
Now we change the first $k$ vector of the basis of $W$. We call $w_i=\sum_{j=1}^m a_{ji}f_j$ define above for $i=1,...,k$ and respect this new basis the matrix will be:
$$
\begin{pmatrix}
1&\dots & 0&0&\dots&0\\
\dots& 1&\dots&0&\dots&0\\
0&\dots& 1 &0&\dots&0\\
\dots& \dots&\dots&0&\dots&0\\0&0&0&0&\dots&0
\end{pmatrix}.
$$ 
Observe that $k\le\min\{n,m\}$.
