Previous Next Contents Generated Index Doc Set Home



Sum of the Absolute Values of a Vector

DASUM and SASUM compute

which is the l1-norm of a vector x.

DZASUM and SCASUM compute

Note that DZASUM and SCASUM do not compute

which is the l1-norm of a complex vector.

Calling Sequence

DL1 = DASUM (N, DX, INCX)
SL1 = SASUM (N, SX, INCX)
DL1 = DZASUM (N, ZX, INCX)
SL1 = SCASUM (N, CX, INCX)



double dasum (int n, double *dx, int incx)
real sasum (int n, float *sx, int incx)
double dzasum (int n, doublecomplex *zx, int incx)
real scasum (int n, complex *cx, int incx)

Arguments

N

Number of elements in the vector. N 0.

xX

Input vector X; the size of array X must be at least max(1,N*|INCX|).

INCX

Specifies the storage spacing between successive elements of the vector X. A value of one indicates that the elements of the vector are consecutive in memory. INCX > 0.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X then the elements of the vector will be a row of X.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X plus one then the elements of the vector will be a diagonal of X.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           N
      PARAMETER        (N = 4)
C
      DOUBLE PRECISION  SUM, X(N)
      INTEGER           I, INCX
C
      DOUBLE PRECISION  DASUM
      EXTERNAL          DASUM
C
C     Initialize the array X to store the vector x shown below.
C
C         1.0
C     x = 2.0
C         3.0
C         4.0
C
      DATA X / 1.0D0, 2.0D0, 3.0D0, 4.0D0 /
C
      PRINT 1000
      PRINT 1010, (X(I), I = 1, N)
      INCX = 1
      SUM = DASUM (N, X, INCX)
      PRINT 1020, SUM
C
 1000 FORMAT (1X, 'x:')
 1010 FORMAT (3X, F3.1)
 1020 FORMAT (/1X, 'The L-1 norm of x is ', F4.1)
C
      END
 

Sample Output




 x:
   1.0
   2.0
   3.0
   4.0



 The L-1 norm of x is 10.0






Previous Next Contents Generated Index Doc Set Home