%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Master pro II SNMA
%2006/2007
%Méthode QR pour les valeur propres
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
n=20;
A=gallery('poisson',n);
niter=30;
nt=max(size(A));
Q=speye(nt,nt);
T=Q'*A*Q;
figure(1)
for k=1:niter
    [Q,R]=qr(T);
    T=R*Q;
    mesh(T)
    drawnow
end
Vqr=sort(diag(T));
Vmtlb=sort(eigs(A,nt));
figure(2)
plot(1:nt,Vqr,'+',1:nt,Vmtlb,'d')
legend('QR','Matlab',-1)

