HP MLIB User's Guide Vol. 1 7th Ed.

122 HP MLIB User’s Guide
SROTI/DROTI Apply sparse Givens rotation
indx Array containing the indices {k
i
} of the interesting
elements of x. The indices must satisfy the following:
where n is the length of y.
y Array containing the elements of y, y(i)=y
i
.
c The scalar c.
s The scalar s.
Output x and y If m 0 or if c = 1 and s = 0, then x and y are
unchanged. Otherwise, the result vectors overwrite the
input. Only the elements of y whose indices are
included in indx are changed.
Notes The result is unspecified if any element of indx is out of range, if any two
elements of indx have the same value, or if x, indx, and y overlap such that any
index or any element of x or y share a memory location.
Fortran
Equivalent
SUBROUTINE SROTI (M, X,INDX, Y, C,S)
REAL*4 C,S,TEMP,X(*),Y(*)
INTEGER*4 INDX(*)
IF ( M .LE. 0 ) RETURN
IF ( C .EQ. 1.0 .AND. S .EQ. 0.00 ) RETURN
DO 10 I = 1, M
TEMP = C * X(I) + S * Y(INDX(I))
Y(INDX(I)) = C * Y(INDX(I)) - S * X(I)
X(I) = TEMP
10 CONTINUE
RETURN
END
Example Apply a Givens rotation to x and y, where x is a sparse vector with interesting
elements x
1
, x
4
, x
5
, and x
9
stored in one-dimensional array X, and y is stored in a
one-dimensional array Y of dimension 20.
INTEGER*4 M,INDX(4)
REAL*8 X(4),Y(20),C,S
DATA INDX / 1, 4, 5, 9 /
M = 4
CALL DROTI (M,X,INDX,Y,C,S)
1 indx i() n≤≤i 12 m,, ,=,
indx i() indx j() 1 i j m,