The algorithms based on normal equations and QR decomposition only work
for fully-ranked input matrices (i.e. rank() = n). If
is rank-deficient, that there are infinite number of solutions to
the least squares problems and we can use algorithms based on SVD's. In
particular, if
is a least square minimizer to the input system,
than
is also a minimizer, where
belongs to
the kernel of
.
Given the SVD: , the minimal
solution corresponds to:
In practice, computation of SVD can take about operations.