function [lambda,iter] = eig_QR(A, tol)
% This function computes all eigenvalues of the matrix A

% Input A   -> nxn matrix 
%       tol -> tolerance we accept on the largest entry
%              in the lower triangular part of A=RQ
%    
% Output lambda -> eigenvalues of A


err=1;
iter=1;

while err >= tol
    [Q,R]=qr(A);
    A=R*Q;
    err=norm((tril(A,-1)));
    iter=iter+1;
end
lambda=diag(A);

