Thin QR factorization from Cholesky decomposition (source code)

= Thin QR factorization from Cholesky decomposition
{title2=$A=QR,\quad Q^TQ=I,\quad R^TR=A^TA$}

If a real $m$-by-$n$ matrix $A$ has full column rank, with $m\ge n$, then $A^TA$ is <positive-definite>. Its upper-triangular <Cholesky decomposition> $A^TA=R^TR$, with positive diagonal, is unique. Defining $Q=AR^{-1}$ gives $Q^TQ=I$ and $A=QR$. Any other such factorization yields another Cholesky factor of $A^TA$, so its $R$ and then its $Q$ must agree. This proves existence and uniqueness; it does not assert that forming $A^TA$ is the most numerically stable algorithm.