Orthogonal Factorization

Theorem Every real m×n matrix A (mn) can be written as A=QR, where Q is an m×m orthogonal matrix and R is an m×n upper triangular matrix.

  • Thin QR: A=ˆQˆR, where ˆQ is m×n and ONC, and ˆR is n×n and upper triangular.
A = rand(1.:9.,6,4);
Q,R = qr(A);

We can get the thin from Q by converting to matrix:

Q_hat = Matrix(Q)

#6×4 Matrix{Float64}:
# -0.35793   -0.14544    -0.152543   0.829375
# -0.178965  -0.71283    -0.130244  -0.0381754
# -0.417585   0.207821   -0.702897  -0.0976324
# -0.298275  -0.498701    0.397811  -0.146905
# -0.536895   0.0280366  -0.078145  -0.512537
# -0.536895   0.421951    0.548947   0.129896

Verify that QTQ is the identity:

Q_hat'*Q_hat

#4×4 Matrix{Float64}:
#  1.0          -2.21581e-17  -2.82658e-17   4.37205e-17
# -2.21581e-17   1.0          -5.41623e-17   8.02735e-17
# -2.82658e-17  -5.41623e-17   1.0          -9.94081e-17
#  4.37205e-17   8.02735e-17  -9.94081e-17   1.0