function u = house(x) % % compute householder transformation % this is a stable version. % % written by Ming Gu for Math 221, Fall 2008 % x = x(:); n = length(x); if (norm(x) == 0) u = ones(n,1)/sqrt(n); return; end x(1) = x(1) +sign(x(1))*norm(x); u = x/norm(x);