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

70 HP MLIB User’s Guide
SAXPYI/DAXPYI/CAXPYI/ZAXPYI Sparse elementary vector operation
indx Array containing the indices {k
i
} of the interesting
elements of x. The indices must satisfy
and
where n is the length of y.
y Array containing the elements of y, y(i)=y
i
.
Output y If m 0 or a = 0, then y is unchanged. Otherwise, ax+y
overwrites 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
element of x or any index shares a memory location with any element of y.
Fortran
Equivalent
SUBROUTINE SAXPYI (M, A, X,INDX, Y)
REAL*4 A,X(*),Y(*)
INTEGER*4 INDX(*)
IF ( M .LE. 0 ) RETURN
IF ( A .EQ. 0.0 ) RETURN
DO 10 I = 1, M
Y(INDX(I)) = A * X(I) + Y(INDX(I))
10 CONTINUE
RETURN
END
Example Compute the REAL*8 elementary vector operation
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 A,X(4),Y(20)
DATA INDX / 1, 4, 5, 9 /
M = 4
A = 2.0D0
CALL DAXPYI (M,A,X,INDX,Y)
1 indx i() n≤≤i 12 m,, ,=
indx i() indx j() 1 i j m,
y 2x y,+