This function performs Householder QR with column pivoting:
Given an \(m\)-by-\(n\) matrix \(A\) with \(m \geq n\),
the following algorithm computes \(r = \textrm{rank}(A)\) and
the factorization \(Q^T A P\) equal to
| | \(R_{11}\) | \(R_{12}\) | | | \(r\) |
| | 0 | 0 | | | \(m-r\) |
| \(r\) | \(n-r\) | | |
with \(Q = H_1 \cdots H_r\) and \(P = P_1 \cdots P_r\).
The upper triangular part of \(A\)
is overwritten by the upper triangular part of \(R\) and
components \((j+1):m\) of
the \(j\)th Householder vector are stored in \(A((j+1):m, j)\).
The permutation \(P\) is encoded in an integer vector pivot
.