Givens rotation


In numerical linear algebra, a Givens rotation is a rotation in the plane spanned by two coordinates axes. Givens rotations are named after Wallace Givens, who introduced them to numerical analysts in the 1950s while he was working at Argonne National Laboratory.

As action on matrices

A Givens rotation acting on a matrix from the left is a row operation, moving data between rows but always within the same column. Unlike the elementary operation of row-addition, a Givens rotation changes both of the rows addressed by it. To understand how it is a rotation, one may denote the elements of one target row by through and the elements of the other target row by through :
Then the effect of a Givens rotation is to rotate each subvector by the same angle. As with row-addition, algorithms often choose this angle so that one specific element becomes zero, and whatever happens in remaining columns is considered acceptable side-effects.
A Givens rotation acting on a matrix from the right is instead a column operation, moving data between two columns but always within the same row. As with action from the left, it rotates each subvector by the same angle, but here these named elements occur in the matrix as
Some algorithms, especially those concerned with preserving matrix similarity, apply Givens rotations as a conjugate action: both rotating by one angle between two rows, and rotating by the same angle between the corresponding columns. In this case the effect on the four elements affected by both rotations is more complicated; a Jacobi rotation is such a conjugate action to the end of zeroing the two off-diagonal elements among these four.
The main use of Givens rotations in numerical linear algebra is to transform vectors or matrices into a special form with zeros in certain coefficients. This effect can, for example, be employed for computing the QR decomposition of a matrix. One advantage over Householder transformations is that they can easily be parallelised, and another is that often for very sparse matrices they have a lower operation count.

Matrix representation

A Givens rotation is represented by a matrix of the form
where and appear at the intersections th and th rows and columns. That is, for fixed, the non-zero elements of Givens matrix are given by:
The product represents a counterclockwise rotation of the vector in the plane of radians, hence the name Givens rotation.

Stable calculation

When a Givens rotation matrix,, multiplies another matrix,, from the left,, only rows and of are affected. Thus we restrict attention to the following counterclockwise problem. Given and, find and such that
where is the length of the vector.
Explicit calculation of is rarely necessary or desirable. Instead we directly seek and. An obvious solution would be
However, the computation for may overflow or underflow. An alternative formulation avoiding this problem is implemented as the hypot function in many programming languages.
The following Fortran code is a minimalistic implementation of Givens rotation for real numbers. If the input values 'a' or 'b' are frequently zero, the code may be optimized to handle these cases as presented .

subroutine givens_rotation
real a, b, c, s, r
real h, d
if then
h = hypot
d = 1.0 / h
c = abs * d
s = sign * b
r = sign * h
else
c = 1.0
s = 0.0
r = a
end if
return
end

Furthermore, as Edward Anderson discovered in improving LAPACK, a previously overlooked numerical consideration is continuity. To achieve this, we require to be positive. The following MATLAB/GNU Octave code illustrates the algorithm.

function = givens_rotation
if b 0;
c = sign;
if ;
c = 1.0; % Unlike other languages, MatLab's sign function returns 0 on input 0.
end;
s = 0;
r = abs;
elseif a 0;
c = 0;
s = -sign;
r = abs;
elseif abs > abs;
t = b / a;
u = sign * sqrt;
c = 1 / u;
s = -c * t;
r = a * u;
else
t = a / b;
u = sign * sqrt;
s = -1 / u;
c = t / u;
r = b * u;
end
end

The IEEE 754 copysign function, provides a safe and cheap way to copy the sign of y to x. If that is not available,, using the abs and sgn functions, is an alternative as done above.

Triangularization

Given the following Matrix:
two iterations of the Givens rotation yield an upper triangular matrix in order to compute the QR decomposition.
In order to form the desired matrix, zeroing elements and is required; element is zeroed first, using a rotation matrix of:
The following matrix multiplication results:
where
Using these values for and and performing the matrix multiplication above yields :
Zeroing element finishes off the process. Using the same idea as before, the rotation matrix is:
Afterwards, the following matrix multiplication is:
where
Using these values for and and performing the multiplications results in :
This new matrix is the upper triangular matrix needed to perform an iteration of the QR decomposition. is now formed using the transpose of the rotation matrices in the following manner:
Performing this matrix multiplication yields:
This completes two iterations of the Givens Rotation and calculating the QR decomposition can now be done.

QR iteration variant

If performing the above calculations as a step in the QR algorithm for finding the eigenvalues of a matrix, then one next wants to compute the matrix, but one should not do so by first multiplying and to form, instead rather by multiplying each by . The reason for this is that each multiplication by a Givens matrix on the right changes only two columns of, thus requiring a mere arithmetic operations, which for Givens rotations sums up to arithmetic operations; multiplying by the general matrix would require arithmetic operations. Likewise, storing the full matrix amounts to elements, but each Givens matrix is fully specified the pairs and and of them can thus be stored in elements.
In the example,

Complex matrices

A Givens rotation in the complex case would have to be a unitary matrix which maps a nonzero vector to some. A straightforward solution for this is
which is even in SU(2) and makes real.
suggest the specialised form
for a Givens rotation. Their idea is to choose and so that
and they explain how to obtain from three calls to a function for computing real Givens rotations. This more complicated initialisation can be justified by the observation that since half the matrix elements are real, fewer arithmetic operations are needed when applying this rotation. Note however that having only two real degrees of freedom means the component of the result cannot in general be made real.
A more elementary approach to the same end is to first multiply both rows being targeted by unit magnitude complex numbers of appropriate phase, so that both elements in the column considered become real – then a real Givens rotation suffices for zeroing out one of those entires. In the same notation as above, this amounts to
where is unitary because it is a diagonal matrix whose diagonal elements have unit magnitudes, and the product is unitary because a product of unitary matrices is unitary. Here we save some arithmetic operations because multiplication by acts on each row separately, and multiplication by has real coefficients throughout.
A potential concern with the latter two methods is however that the choice of rotation is discontinuous along the line, and for the last method also along the line; even though the result of applying the rotation to varies continuously, the result of applying that same rotation to other columns of a matrix does not. For example,

In Clifford algebras

In Clifford algebras and its child structures such as geometric algebras, rotations are represented by bivectors. Givens rotations are represented by the exterior product of the basis vectors. Given any pair of basis vectors Givens rotations bivectors are:
Their action on any vector is written:
where

Dimension 3

There are three Givens rotations in dimension 3:
Given that they are endomorphisms they can be composed with each other as many times as desired, keeping in mind that.
These three Givens rotations composed can generate any rotation matrix according to Davenport's chained rotation theorem. This means that they can transform the standard basis of the space to any other frame in the space.
When rotations are performed in the right order, the values of the rotation angles of the final frame will be equal to the Euler angles of the final frame in the corresponding convention. For example, an operator transforms the basis of the space into a frame with angles roll, pitch and yaw in the Tait–Bryan convention z-''x-y''.
For the same reason, any rotation matrix in 3D can be decomposed in a product of three of these rotation operators.
The meaning of the composition of two Givens rotations is an operator that transforms vectors first by and then by, being and rotations about one axis of basis of the space. This is similar to the extrinsic rotation equivalence for Euler angles.

Table of composed rotations

The following table shows the three Givens rotations equivalent to the different Euler angles conventions using extrinsic composition of active rotations and the right-handed rule for the positive sign of the angles.
The notation has been simplified in such a way that means and means. The subindexes of the angles are the order in which they are applied using extrinsic composition
As rotations are applied just in the opposite order of the Euler angles table of rotations, this table is the same but swapping indexes 1 and 3 in the angles associated with the corresponding entry. An entry like zxy means to apply first the y rotation, then x, and finally z, in the basis axes.
All the compositions assume the right hand convention for the matrices that are multiplied, yielding the following results.