CXML
ssum, dsum, csum, zsum
Sum of the values of the elements of a vector
FORMAT
{S,D,C,Z}SUM (n, x, incx)
Function Value
sum real*4 | real*8 | complex*8 | complex*16
The total of the values of the elements in 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 n 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|).
If incx = 0, only the first element is accessed.
On exit, incx is unchanged.
Description
The _SUM subprograms compute the total value of the elements of a vector,
performing the following operation: SUM(i=1...n,x(i))
Because of efficient coding, 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.
If incx < 0, the result is identical to using |incx|. If incx = 0, the
computation is a time-consuming way of setting sum = nx(1).
Example
INTEGER*4 N, INCX
REAL*4 X(200), SUM
INCX = 2
N = 50
SUM = SSUM(N,X,INCX)
This FORTRAN example shows how to compute the sum of the values of the
elements of the vector x.
CXML Home Page Index of CXML Routines