HP MLIB User's Guide Vol. 1 7th Ed.
64 HP MLIB User’s Guide
SASUM/DASUM/IASUM/SCASUM/DZASUM Sum of magnitudes
Indexing Conventions” in the introduction to this
chapter.
Output s If n ≤ 0, then s = 0. Otherwise, s is the sum of
magnitudes of the elements of x.
Fortran
Equivalent
REAL*4 FUNCTION SASUM (N, X,INCX)
REAL*4 X(*)
SASUM = 0.0
IF ( N .LE. 0 ) RETURN
IX = 1
INCXA = ABS ( INCX )
DO 10 I = 1, N
SASUM = SASUM + ABS ( X(IX) )
IX = IX + INCXA
10 CONTINUE
RETURN
END
Example Compute the sum of magnitudes of the elements of a REAL*8 vector x, where x
is a vector 10 elements long stored in a one-dimensional array X of dimension
20.
INTEGER*4 N,INCX
REAL*8 S,DASUM,X(20)
N = 10
INCX = 1
S = DASUM (N,X,INCX)