% FUNCTION [ x, e ] = LS_QR( A, b )
%
% Least square solution of an overdetermined system Ax = b
% where A is a M-by-N matrix with M > N
% x is a M-by-1 vector
% b is a M-by-1 vector
%
% This is done using QR decomposition of A.
% Also returned: e (scalar) the euclidian norm of Ax-b
function [ x, e ] = ls_qr( A, b )
error( nargchk( 1, 2, nargin ) );
M = size( A, 1 );
N = size( A, 2 );
[ Q, R ] = qr( A );
U = R( 1:N, 1:N );
c = Q' * b;
d = c( 1:N );
error( 'unfinished' );