%
%
%  Construction of hyperbolic Householder matrix by the 
%   Definition 2.2, i.e. the condition Phi(1,1)=sign(xPhi) 
%                                        is satisfied
%
%	     [y,H]=hyphsd(n,x,xphi,Phi)
%
% Input data:
%	n ... dimension of the vector x
%	x ... vector to be reduced
%    xPhi ... hyperbolic norm of x i.e. ||x||_Phi
%     Phi ... the given diagonal matrix with \pm 1 on the diagonal
%
% Output data:
%	y ... vector x after the reduction
%	H ... hyperbolic Householder matrix, H*x=y
%
%
function [y,H] = hyphsd(n,x,xPhi,Phi)
for j=1:n
    y(j)=0;
end
y=y';
beta = xPhi*(abs(xPhi)+abs(x(1)));
beta = 1/beta;
b=x;
b(1)=b(1)+x(1)*abs(xPhi)/abs(x(1));
b=Phi*b;
H=Phi-beta*b*b';
y(1)=-x(1)*xPhi/abs(x(1));


