% calulation of the ls estimator B
%   written by: Chriss Grimholt, 3/5-2011

function B = lsn(Y,X)

[u,s,v] = svd(X);

d = diag(s);

for i = 1:size(d)
   if d(i) > 0
       s(i,i)=s(i,i)^-1;
   end    
end

B = Y*v*s'*u';

%B = Y*pinv(X,0);
end
