Calculates the Givens rotation matrix.
|p||The value which can rotate to any number.|
|q||The value which rotates to zero.|
|return value||Rotation matrix zeroing out q.|
An entry in the offdiagonal of a matrix M can be eliminted by a rotation G: G*M will have a prescribed zero offdiagonal element. The parameter p is the corresponding diagonal element in the same column, and q is the offdiagonal in question.
M = [1,2,3;4,5,6;7,8,9] col = 2 row = 1 G = eye(numRows(M)); G[col,row;col,row] = givens(M[col;col], M[row;col]); G*M
M = [1,2,3;4,5,6;7,8,9] col = 1 row = 2 G = eye(numCols(M)); G[row,col;row,col] = givens(M[row;row]', M[row;col]'); M*G'