Givens rotations
For any vector $\v a\in \R^m$, the Givens rotation matrix $Ω^{[p,q]}\in \R^{m\times m}$ is an orthogonal transformation that makes the $q$-th component zero and preserves all components other than the $p$ and $q$-th ones: $$ \begin{align*} \underbrace{\pmat{1\\&\ddots\\&&\frac{a_p}{\sqrt{a_p^2+a_q^2}} && \frac{a_q}{\sqrt{a_p^2+a_q^2}} \\ &&&\ddots \\&&-\frac{a_q}{\sqrt{a_p^2+a_q^2}}&&\frac{a_p}{\sqrt{a_p^2+a_q^2}} \\ &&&&&\ddots \\ &&&&&&1}}_{Ω^{[p,q]}} \underbrace{\pmat{a_{1} \\ \vdots \\ a_p \\ \vdots \\ a_q \\ \vdots \\ a_m}}_{\v a} = \pmat{a_1 \\ \vdots \\ a_p^2 + a_q^2 \\ \vdots \\ 0 \\ \vdots \\a_m} \end{align*} $$
Applying $Ω^{[p,q]}$ to a matrix $A$, all rows other than rows $p$ and $q$ are unchanged, one entry in row $p$ is killed, and the span of rows $p$ and $q$ is preserved.
Thus after at most $mn$ Givens rotations, we can annihilate all subdiagonal elements: $$ \begin{align*} \pmat{*&*&*\\ *&*&* \\ *&*&* \\ *&*&*} &\xrightarrow{Ω^{[1,2]}} \pmat{\bullet &\bullet&\bullet\\ 0 &\bullet&\bullet \\ *&*&* \\ *&*&*} \xrightarrow{Ω^{[1,3]}} \pmat{\bullet &\bullet&\bullet\\ 0 &*&* \\ 0&\bullet&\bullet \\ *&*&*} \xrightarrow{Ω^{[1,4]}} \pmat{\bullet &\bullet&\bullet\\ 0 &*&* \\ 0&*&* \\ 0&\bullet&\bullet} \\ &\xrightarrow{Ω^{[2,3]}} \pmat{*&*&* \\ 0 &\bullet&\bullet \\ 0&0&\bullet \\ 0&*&*} \xrightarrow{Ω^{[2,4]}} \pmat{*&*&* \\ 0 &\bullet&\bullet \\ 0&0&* \\ 0&0&\bullet} \\ &\xrightarrow{Ω^{[3,4]}} \pmat{*&*&* \\ 0 &*&* \\ 0&0&\bullet \\ 0&0&0} \\ \end{align*} $$ (Legend: $*$ remains the same as the previous matrix; $\bullet$ has changed through a rotation.)
Therefore $$ \begin{align*} & R = (Ω^{[m-1,m]})\cdot (Ω^{[m-2,m]} Ω^{[m-2, m-1]}) \cdot \ldots \cdot (Ω^{[1,m]} \ldots Ω^{[1,3]} Ω^{[1,2]}) \cdot A \\ \implies & A = \underbrace{\Bigl[(Ω^{[m-1,m]})\cdot (Ω^{[m-2,m]} Ω^{[m-2, m-1]}) \cdot \ldots \cdot (Ω^{[1,m]} \ldots Ω^{[1,3]} Ω^{[1,2]})\Bigr]^T}_{Q} R. \end{align*} $$
Example (QR factorisation using Givens rotations)
Cost:
-
Computing $R$: $O(mn\cdot n)$.
-
Computing an explicit form of $Q$ (usually not necessary): perform all the Given rotations on $I_m$. This gives an extra cost of $O(mn\cdot m)$.
-
Computing $Q^T \v b$: $O(mn)$.