SASUM/DASUM/IASUM/SCASUM/DZASUM

Sum of magnitudes

Name SASUM/DASUM/IASUM/SCASUM/DZASUM

Sum of magnitudes

Purpose Given a real or integer vector x of length n, SASUM, DASUM, or IASUM computes the l1 norm of x, that is, the sum of magnitudes of the elements of the

vector

n

s = x 1 = xi i = 1

Given a complex vector x of length n, SCASUM or DZASUM computes

n

s= Re( xi) + Im( xi)

i= 1

where Re(xi) and Im(xi) are the real and imaginary parts of xi, respectively.

The usual definition of sum of magnitudes of a complex vector is

 

 

 

 

 

 

 

 

n

 

1 2

 

 

 

 

 

 

 

 

t =

 

 

 

X

 

 

 

2 =

Re( xi)2

+ Im( xi)2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i = 1

s is computed instead of t because, with its lack of square roots, it is faster to compute. Because t s 2t , s is often an acceptable substitute for t.

The vector can be stored in a one-dimensional array or in either a row or a column of a two-dimensional array.

Usage

VECLIB:

 

 

INTEGER*4

n, incx

 

REAL*4

s, SASUM, x(lenx)

 

s = SASUM(n, x, incx)

 

INTEGER*4

n, incx

 

REAL*8

s, DASUM, x(lenx)

 

s = DASUM(n, x, incx)

 

INTEGER*4

n, incx, s, IASUM, x(lenx)

s = IASUM(n, x, incx)

62HP MLIB User’s Guide