| 1 |
/* ./src_f77/sasum.f -- translated by f2c (version 20030320). |
| 2 |
You must link the resulting object file with the libraries: |
| 3 |
-lf2c -lm (in that order) |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <punc/vf2c.h> |
| 7 |
|
| 8 |
doublereal sasum_(integer *n, real *sx, integer *incx) |
| 9 |
{ |
| 10 |
/* System generated locals */ |
| 11 |
integer i__1, i__2; |
| 12 |
real ret_val, r__1, r__2, r__3, r__4, r__5, r__6; |
| 13 |
|
| 14 |
/* Local variables */ |
| 15 |
static integer i__, m, mp1, nincx; |
| 16 |
static real stemp; |
| 17 |
|
| 18 |
|
| 19 |
/* takes the sum of the absolute values. */ |
| 20 |
/* uses unrolled loops for increment equal to one. */ |
| 21 |
/* jack dongarra, linpack, 3/11/78. */ |
| 22 |
/* modified 3/93 to return if incx .le. 0. */ |
| 23 |
/* modified 12/3/93, array(1) declarations changed to array(*) */ |
| 24 |
|
| 25 |
|
| 26 |
/* Parameter adjustments */ |
| 27 |
--sx; |
| 28 |
|
| 29 |
/* Function Body */ |
| 30 |
ret_val = 0.f; |
| 31 |
stemp = 0.f; |
| 32 |
if (*n <= 0 || *incx <= 0) { |
| 33 |
return ret_val; |
| 34 |
} |
| 35 |
if (*incx == 1) { |
| 36 |
goto L20; |
| 37 |
} |
| 38 |
|
| 39 |
/* code for increment not equal to 1 */ |
| 40 |
|
| 41 |
nincx = *n * *incx; |
| 42 |
i__1 = nincx; |
| 43 |
i__2 = *incx; |
| 44 |
for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { |
| 45 |
stemp += (r__1 = sx[i__], dabs(r__1)); |
| 46 |
/* L10: */ |
| 47 |
} |
| 48 |
ret_val = stemp; |
| 49 |
return ret_val; |
| 50 |
|
| 51 |
/* code for increment equal to 1 */ |
| 52 |
|
| 53 |
|
| 54 |
/* clean-up loop */ |
| 55 |
|
| 56 |
L20: |
| 57 |
m = *n % 6; |
| 58 |
if (m == 0) { |
| 59 |
goto L40; |
| 60 |
} |
| 61 |
i__2 = m; |
| 62 |
for (i__ = 1; i__ <= i__2; ++i__) { |
| 63 |
stemp += (r__1 = sx[i__], dabs(r__1)); |
| 64 |
/* L30: */ |
| 65 |
} |
| 66 |
if (*n < 6) { |
| 67 |
goto L60; |
| 68 |
} |
| 69 |
L40: |
| 70 |
mp1 = m + 1; |
| 71 |
i__2 = *n; |
| 72 |
for (i__ = mp1; i__ <= i__2; i__ += 6) { |
| 73 |
stemp = stemp + (r__1 = sx[i__], dabs(r__1)) + (r__2 = sx[i__ + 1], |
| 74 |
dabs(r__2)) + (r__3 = sx[i__ + 2], dabs(r__3)) + (r__4 = sx[ |
| 75 |
i__ + 3], dabs(r__4)) + (r__5 = sx[i__ + 4], dabs(r__5)) + ( |
| 76 |
r__6 = sx[i__ + 5], dabs(r__6)); |
| 77 |
/* L50: */ |
| 78 |
} |
| 79 |
L60: |
| 80 |
ret_val = stemp; |
| 81 |
return ret_val; |
| 82 |
} /* sasum_ */ |
| 83 |
|