SASUM and DASUM compute the sum of the absolute values of the elements in
vector x. SCASUM and DZASUM compute the sum of the absolute
values of the real and imaginary parts of the elements in vector
x.
x | Result | Subprogram |
Short-precision real | Short-precision real | SASUM |
Long-precision real | Long-precision real | DASUM |
Short-precision complex | Short-precision real | SCASUM |
Long-precision complex | Long-precision real | DZASUM |
Fortran | SASUM | DASUM | SCASUM | DZASUM (n, x, incx) |
C and C++ | sasum | dasum | scasum | dzasum (n, x, incx); |
PL/I | SASUM | DASUM | SCASUM | DZASUM (n, x, incx); |
Declare this function in your program as returning a value of the type indicated in Table 40.
SASUM and DASUM compute the sum of the absolute values of the elements of x, which is expressed as follows:
SCASUM and DZASUM compute the sum of the absolute values of the real and imaginary parts of the elements of x, which is expressed as follows:
See reference [79]. The result is returned as a function value. If n is 0, then 0.0 is returned as the value of the function. For SASUM and SCASUM, intermediate results are accumulated in long precision.
None
n < 0
This example shows a vector, x, with a stride of 1.
N X INCX | | | SUMM = SASUM( 7 , X , 1 ) X = (1.0, -3.0, -6.0, 7.0, 5.0, 2.0, -4.0)
SUMM = 28.0
This example shows a vector, x, with a stride greater than 1.
N X INCX | | | SUMM = SASUM( 4 , X , 2 ) X = (1.0, . , -6.0, . , 5.0, . , -4.0)
SUMM = 16.0
This example shows a vector, x, with negative stride. Processing begins at element X(7), which is -4.0.
N X INCX | | | SUMM = SASUM( 4 , X , -2 ) X = (1.0, . , -6.0, . , 5.0, . , -4.0)
SUMM = 16.0
This example shows a vector, x, with a stride of 0. The result in SUMM is nx1.
N X INCX | | | SUMM = SASUM( 7 , X , 0 ) X = (-2.0, . , . , . , . , . , .)
SUMM = 14.0
This example shows a vector, x, containing complex numbers and having a stride of 1.
N X INCX | | | SUMM = SCASUM( 5 , X , 1 ) X = ((1.0, 2.0), (-3.0, 4.0), (5.0, -6.0 ), (-7.0, -8.0), (9.0, 10.0))
SUMM = 55.0