function G = givens(v) % G=GIVENS(v) constructs the real Givens matrix which eliminates the % second component of the vector v of length 2 % v: a vector of length 2 % G: Givens matrix s = 0; c = 1; if abs(v(2)) < abs(v(1)) tau = v(2)/v(1); c = 1/sqrt(1+tau^2); s = tau*c; end if abs(v(1)) < abs(v(2)) tau = v(1)/v(2); s = 1/sqrt(1+tau^2); c = tau*s; end G = [c s;-s c];