function [Q,R]=qrgv(A)
%QR decompostion by Givens Rotation 

%initialization
n=size(A,1);
R=A;
Q=eye(n);

% loop  
for i=1:n-1
    for j=2:n-i+1
        x=R(i:n,i);
        rt=givens(x,1,j); % rotation happens here
        r=blkdiag(eye(i-1),rt); %Block diagonal concatenation with new rt
        Q=Q*r';
        R=r*R;
        figure; matrixplot(r);
    end
end

