Solution (source code)

= Solution

Choose $r$ independent columns of $A$ that form a <basis> of its <column space>, and put them in $B\in\mathbb R^{m\times r}$. For each column $a_j$ of $A$, let $c_j$ be its coordinate <vector> in that basis; put these coordinate <vectors> in $C\in\mathbb R^{r\times n}$. The column equations $a_j=Bc_j$ give \b[$A=BC$].

By construction $B$ has <full column rank> $r$. The columns of $C$ corresponding to the selected basis columns are the standard <vectors> of $\mathbb R^r$, so $C$ has <full row rank> $r$. This proves the requested <rank factorization>. When $r=0$, $A=0$ and the corresponding empty-column and empty-row factors have the required shapes and rank zero.