It seems
that Matlab is not using the LAPACK xGEDLD function like Octave does,
but rather a formulation based on the QR factorization. The formulation
can be written as
m=10; n=20; A = randn(m,n); b=rand(m,1); [Q,R,E]=qr(A);
[A\b E(:,1:m)*(R(:,1:m)\(Q'*b))]
Result returned by this is not the minimum 2-norm solution, like in
Octave but is equally valid. It also appears that the matlab method is
faster and uses less memory. Marco points out that values like m=50 and
n=20000 in the above will result in an exhaustion of the memory of the
machine, whereas Matlab is still capable of returning a result.
Another issue is what is the result that is returned by Matlab and
Octave for singular matrices. Consider a case like
A = [eps, 0, -eps; 0, eps, -eps; -eps, 0, 10]; x = A \ ones(3,1)
Octave falls back to using xGELSD to solve the matrix in this case
whereas as Matlab returns the result based on LU factorization with a
warning of its inaccuracy.