CXML

sasum, dasum, scasum, dzasum 


FORMAT

  {S,D}ASUM (n, x, incx) SCASUM (n, x, incx) DZASUM (n, x, incx)

Function Value

  sum: real*4 | real*8 | complex*8 | complex*16
  The sum of the absolute values of the elements of the vector x.
  If n<=0, sum returns the value 0.0.

Arguments

  n                   integer*4
                      On entry, the number of elements in the vector x.
                      On exit, n is unchanged.

  x                   real*4 | real*8 | complex*8 | complex*16
                      On entry, a one-dimensional array X of length at least
                      (1+(n-1)*|incx|), containing the elements of the vector
                      x.
                      On exit, x is unchanged.

  incx                integer*4
                      On entry, the increment for the array X.
                      If incx >= 0, vector x is stored forward in the array,
                      so that x(i) is stored in location X(1+(i-1)*incx).
                      If incx < 0, vector x is stored backward in the array,
                      so that x(i) is stored in location X(1+(n-i)*|incx|).
                      On exit, incx is unchanged.

Description

  The SASUM and DASUM functions compute the sum of the absolute values of the
  elements of a real vector x: SUM(i=1...n,|x(i)|) = |x(1)| + |x(2)| + ... +
  |x(n)|

  SCASUM and DZASUM compute the sum of the absolute values of the real and
  imaginary parts of the elements of a complex vector x: SUM(i=1...(n),|a(i)|
  + |b(i)|) = (|a(1)| + |b(1)|) + (|a(2)| + |b(2)|) + ...  + (|a(n)| +
  |b(n)|)

  where x(i) = (a(i),b(i)) and |x(i)| = |a(i)| + |b(i)| = |real| +
  |imaginary|

  If incx < 0, the result is identical to using |incx|.  If (incx = 0, the
  computation is a time-consuming way of setting sum = n*x(1).

  Because of the efficient coding of these routines, rounding errors can
  cause the final result to differ from the result computed by a sequential
  evaluation of the sum of the elements of the vector.

Example

  INTEGER*4 N, INCX
  REAL*4 X(20), SUM
  INCX = 1
  N = 20
  SUM = SASUM(N,X,INCX)

  This FORTRAN code shows how to compute the sum of the absolute values of
  the elements of the vector x.

CXML Home Page

Index of CXML Routines