where:
- is
- is square upper triangular matrix
- is Orthogonal matrix
Features: - QR factorization always exists but may not unique
- QR factorization only exists when Determinant is and all diagonal elements .
given by
Steps
Gram-Schmidt
most intuitive but not stable
ref: https://kwokanthony.medium.com/important-decomposition-in-linear-algebra-detailed-explanation-on-qr-decomposition-by-classical-3f8f5425915f
- for column in , calculate .
- then which is column in
- repeat for all columns to get .
- .
Householder
cost
Steps
- init
- for column in , calculate where is standard basis. Choose the sign to avoid cancellation.
- , and .
- keep this calculation column by column with only consider sub-matrix until is upper right triangle matrix.
- , is last result of .
2x2 example
Then
Since is already in right upper triangle matrix. We are done with and
It’s consist with
>>> numpy.linalg.qr(np.matrix("3,7;4,2"))
QRResult(Q=matrix([[-0.6, -0.8],
[-0.8, 0.6]]), R=matrix([[-5. , -5.8],
[ 0. , -4.4]]))
Givens
For higher dimensions, we need to use sth like
depend on which dimension.
Steps
- For column in , use to build it to consist with right upper triangle matrix
- e.g. if we need to remove 2nd element in matrix, we need to use with and where is 1st element and is the 2nd, and .
- Then get . Then check if we need to remove another element (like 3rd element) as well.
- Repeat this for all columns.
- , is the last .
Costs
if is upper Hessenberg matrix, it only requires Givens rotation.
otherwise .