Skip to main content

Module qr

Module qr 

Source
Expand description

The QR factorisation A = Q R: orthonormal columns times an upper triangular matrix.

Gram-Schmidt builds Q one column at a time by subtracting from each column of A its projections onto the columns already found. The classical form projects the original column; the modified form projects the partially orthogonalised one, which is algebraically identical but loses orthogonality much more slowly in floating point (roughly ε κ(A) instead of ε κ(A)², where κ is the condition number).

Householder QR instead multiplies A by reflections H = I − 2 v vᵀ, each zeroing the entries below one diagonal position. Products of reflections are exactly orthogonal, so Q is orthonormal to working precision whatever the conditioning of A. This is what production libraries use.

All three return the thin factorisation of an m × n matrix with m ≥ n: Q is m × n and R is n × n.

See the book entry QR factorisation.

Functions§

classical_gram_schmidt
Classical Gram-Schmidt: r_ij = q_i · a_j with the original column a_j.
householder
Householder QR. Reflection k maps column k (from row k down) onto a multiple of e_1; Q is then accumulated by applying the reflections to the first n columns of the identity.
modified_gram_schmidt
Modified Gram-Schmidt: r_ij = q_i · v with the column v as orthogonalised so far.
orthogonality_error
‖QᵀQ − I‖_F, the loss of orthogonality.