SAXPYI/DAXPYI/CAXPYI/ZAXPYI |
| Sparse elementary vector operation | |
| indx | Array containing the indices {ki} of the interesting | |
|
| elements of x. The indices must satisfy | |
|
| 1 ≤ indx(i) ≤ n | i = 1, 2, …, m |
|
| and |
|
|
| indx(i) ≠ indx( j) | 1 ≤ i ≠ j ≤ m, |
|
| where n is the length of y. | |
| y | Array containing the elements of y, y(i) = yi. | |
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))
10CONTINUE RETURN END
Example Compute the REAL*8 elementary vector operation
y← 2x + y,
where x is a sparse vector with interesting elements x1, x4, x5, and x9 stored in
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)
70HP MLIB User’s Guide