function [u,b] = householder(v)
% [u,b]=HOUSEHOLDER(v) constructs the parameters defining the
% Householder matrix which annihilates all components of v but the first
% v: a vector
% u,b: a vector and a scalar such that the Householder matrix is I-buu'
n = length(v);
e1 = [1;zeros(n-1,1)];
if v(1) == 0
a = 1;
else
a = sign(v(1));
end
u = v + a*norm(v)*e1;
b = 2/(u'*u);