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

138 HP MLIB User’s Guide
SSCTR/DSCTR/ISCTR/CSCTR/ZSCTR Scatter sparse vector
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.
Output y Array containing the elements of y, y(i)=y
i
. If m 0,
then y is unchanged. Otherwise, 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
element of x or any index shares a memory location with any element of y.
Fortran
Equivalent
SUBROUTINE SSCTR (M, X,INDX, Y)
REAL*4 X(*),Y(*)
INTEGER*4 INDX(*)
IF ( M .LE. 0 ) RETURN
DO 10 I = 1, M
Y(INDX(I)) = X(I)
10 CONTINUE
RETURN
END
Example Scatter x into 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)
DATA INDX / 1, 4, 5, 9 /
M = 4
CALL DSCTR (M,X,INDX,Y)
1 indx i() n≤≤i 1=2 m,,,,
indx i() indx j() 1 i j m,