function R=implicitqrdouble(A)

% [Q,R]=IMPLICITQRDOUBLE(A) naredi en korak implicitne QR metode z 
% dvojnim premikom. Pri tem so vidne vse faze postopka.
% Matrika A je zgornja Hessenbergova

n=length(A);

dt=A(n-1,n-1)*A(n,n)-A(n-1,n)*A(n,n-1);
sl=A(n-1,n-1)+A(n,n);

a=A(1,1)^2+A(1,2)*A(2,1)-sl*A(1,1)+dt;
b=A(2,1)*(A(1,1)+A(2,2)-sl);
c=A(3,2)*A(2,1);

% prvo zrcaljenje je odvisno od prvega stolpca (A-premik*I)(A-premik'*I)

w=house([a;b;c]);
A(1:3,:)=rowhouse(A(1:3,:),w);
A(:,1:3)=colhouse(A(:,1:3),w)

for k=2:n-2
   w=house(A(k:k+2,k-1)); 
   A(k:k+2,:)=rowhouse(A(k:k+2,:),w);
   A(:,k:k+2)=colhouse(A(:,k:k+2),w)
end

[c,s]=givens(A(n-1,n-2),A(n,n-2));
A(n-1:n,:)=rowrot(A(n-1:n,:),c,s);
A(:,n-1:n)=colrot(A(:,n-1:n),c,s)

R=A;
   
