SROT(3dxml) — Subroutines
Name
srot, drot, crot, zrot, csrot, zdrot − Apply givens plane rotation
FORMAT
{S,D,C,Z}ROT (n, x, incx, y, incy, c, s) CSROT (n, x, incx, y, incy, c, s) ZDROT (n, x, incx, y, incy, c, s)
Arguments
ninteger∗4
On entry, the number of elements in the vectors x and y.
On exit, n is unchanged.
xreal∗4 | real∗8 | complex∗8 | complex∗16
On entry, a one-dimensional array X of length at least (1+(n-1)∗|incx|), containing the elements of the vector x.
On exit, if n<=0 or if c is 1.0 and s is 0.0, x is unchanged. Otherwise, x is overwritten; X contains the rotated vector x.
incxinteger∗4
On entry, the increment for the array X.
If incx >= 0, vector x is stored forward in the array, so that x(i) is stored in location X(1+(i-1)∗incx).
If incx < 0, vector x is stored backward in the array, so that x(i) is stored in location X(1+(n-i)∗|incx|).
On exit, incx is unchanged.
yreal∗4 | real∗8 | complex∗8 | complex∗16
On entry, a one-dimensional array Y of length at least (1+(n-1)∗|incy|). Y contains the n elements of the vector y.
On exit, if n<=0 or if c is 1.0 and s is 0.0, y is unchanged. Otherwise, y is overwritten; Y contains the rotated vector y.
incyinteger∗4
On entry, the increment for the array Y.
If incy >= 0, vector y is stored forward in the array, so that y(i) is stored in location Y(1+(i-1)∗incy).
If incy < 0, vector y is stored backward in the array, so that y(i) is stored in location Y(1+(n-i)∗|incy|).
On exit, incy is unchanged.
creal∗4 | real∗8
On entry, the first rotation element, that is, the cosine of the angle of rotation. The argument c is the first rotation element generated by the _ROTG subroutines.
On exit, c is unchanged.
sreal∗4 | real∗8 | complex∗8 | complex∗16
On entry, the second rotation element, that is, the sine of the angle of rotation. The argument s is the second rotation element generated by the _ROTG subroutines.
On exit, s is unchanged.
Description
SROT and DROT apply a real Givens plane rotation to each element in the pair of real vectors, x and y. CSROT and ZDROT apply a real Givens plane rotation to elements in the complex vectors, x and y. CROT and ZROT apply a complex Givens plane rotation to each element in the pair of complex vectors x and y.
The cosine and sine of the angle of rotation are c and s, respectively, and are provided by the BLAS Level 1 _ROTG subroutines.
The Givens plane rotation for SROT, DROT, CSROT, and ZDROT follows: x(i) = c∗x(i) + s∗y(i) y(i) = -s∗x(i) + c∗y(i)
The elements of the rotated vector x are x(i) = cx(i) + sy(i).
The elements of the rotated vector y are y(i) = -sx(i) + cy(i).
The Givens plane rotation for CROT and ZROT follows: x(i) = c∗x(i) + s∗y(i) y(i) = -conjugate(s)∗x(i) + c∗y(i)
The elements of the rotated vector x are x(i) = cx(i) + sy(i).
The elements of the rotated vector y are y(i) = -conjugate(s)x(i) + cy(i).
If n<=0 or if c = 1.0 and s = 0.0, x and y are unchanged. If any element of x shares a memory location with an element of y, the results are unpredictable.
These subroutines can be used to introduce zeros selectively into a matrix.
Example
INTEGER∗4 INCX, N
REAL X(20,20), A, B, C, S
INCX = 20
N = 20
A = X(1,1)
B = X(2,1)
CALL SROTG(A,B,C,S)
CALL SROT(N,X,INCX,X(2,1),INCX,C,S)
This FORTRAN code shows how to rotate the first two rows of a matrix and zero out the element in the first column of the second row.