% Compute a Givens Rotation function rot = Givens(x) % compute c and s so that rot = [[c,s];[-s,c]], rot*x = [norm(x,2);0] % and c^2 + s^2 = 1 r = norm(x,2); if r==0, c=1;s=0; else c=x(1)/r; s=x(2)/r; end rot = [[c,s];[-s,c]];