viernes, 7 de octubre de 2016

Implementación de los métiodos de Householder Hessenberg

Implementation: Householder-Hessenberg method

http://www.auburn.edu/~tamtiny/lecture%2010.pdf 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Function Householder-Hessenberg method

function [H,Q]=houshess(A)
0002 n=max(size(A));
0003 Q=eye(n);
0004 H=A;
0005 for k=1:(n-2),
0006     [v,beta]=vhouse(H(k+1:n,k));
0007     I=eye(k);
0008     N=zeros(k,n-k);
0009     m=length(v);
0010     R=eye(m)-beta*v*v';
0011     H(k+1:n,k:n)=R*H(k+1:n,k:n);
0012     H(1:n,k+1:n)=H(1:n,k+1:n)*R;
0013     P=[I, N; N', R];
0014     Q=Q*P;
0015 end
0016 return

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Picking Householder vector

function [v,beta]=vhouse(x)
0002 n=length(x);
0003 x=x/norm(x);
0004 s=x(2:n)'*x(2:n);
0005 v=[1; x(2:n)];
0006 if (s==0), beta=0;
0007 else
0008    mu=sqrt(x(1)^2+s);
0009 if (x(1) <= 0)
0010       v(1)=x(1)-mu;
0011
else
0012       v(1)=-s/(x(1)+mu);
0013
end
0014    beta=2*v(1)^2/(s+v(1)^2);
0015    v=v/v(1);
0016 end
0017 return


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

No hay comentarios:

Publicar un comentario