function [B]=do_givens(G,i,r,A)
%DO_GIVENS(G,i,r,A) Applies a Givens rotation G to rows r and i of A
% G is the Givens rotation matrix, from e.g. 'get_givens'.
%
% row i of A contains the element to be cleared using row r of A
% (The column is not specified, since G takes care of this)
%
% B (returned) is the transformed output.
%
% We can exploit sparsity of the Givens rotation, we don't need to do 
% a full matrix multiplication.

    B=A;

    B(r,:)=G(1,1)*A(r,:)+G(1,2)*A(i,:); % new row r
    B(i,:)=G(2,1)*A(r,:)+G(2,2)*A(i,:); % new row i
end