function [c,s] = Givens(x,y)
% Determines c,s with c^2 + s^2 = 1 so that
% [c s;-s c]*[x;y] = [r;0]

% Since -sx + cy = 0 implies cy = sx we have...
if x==0 and y==0
c = 1; s = 0;
else
if abs(x) > abs(y)
tau = y/x; c = 1/sqrt(1 + tau^2); s = c*tau;
else
tau = x/y; s = 1/sqrt(1 + tau^2); c = s*tau;
end
end