sasum.c
Go to the documentation of this file.
00001 /* sasum.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 doublereal sasum_(integer *n, real *sx, integer *incx)
00017 {
00018     /* System generated locals */
00019     integer i__1, i__2;
00020     real ret_val, r__1, r__2, r__3, r__4, r__5, r__6;
00021 
00022     /* Local variables */
00023     integer i__, m, mp1, nincx;
00024     real stemp;
00025 
00026 /*     .. Scalar Arguments .. */
00027 /*     .. */
00028 /*     .. Array Arguments .. */
00029 /*     .. */
00030 
00031 /*  Purpose */
00032 /*  ======= */
00033 
00034 /*     takes the sum of the absolute values. */
00035 /*     uses unrolled loops for increment equal to one. */
00036 /*     jack dongarra, linpack, 3/11/78. */
00037 /*     modified 3/93 to return if incx .le. 0. */
00038 /*     modified 12/3/93, array(1) declarations changed to array(*) */
00039 
00040 
00041 /*     .. Local Scalars .. */
00042 /*     .. */
00043 /*     .. Intrinsic Functions .. */
00044 /*     .. */
00045     /* Parameter adjustments */
00046     --sx;
00047 
00048     /* Function Body */
00049     ret_val = 0.f;
00050     stemp = 0.f;
00051     if (*n <= 0 || *incx <= 0) {
00052         return ret_val;
00053     }
00054     if (*incx == 1) {
00055         goto L20;
00056     }
00057 
00058 /*        code for increment not equal to 1 */
00059 
00060     nincx = *n * *incx;
00061     i__1 = nincx;
00062     i__2 = *incx;
00063     for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00064         stemp += (r__1 = sx[i__], dabs(r__1));
00065 /* L10: */
00066     }
00067     ret_val = stemp;
00068     return ret_val;
00069 
00070 /*        code for increment equal to 1 */
00071 
00072 
00073 /*        clean-up loop */
00074 
00075 L20:
00076     m = *n % 6;
00077     if (m == 0) {
00078         goto L40;
00079     }
00080     i__2 = m;
00081     for (i__ = 1; i__ <= i__2; ++i__) {
00082         stemp += (r__1 = sx[i__], dabs(r__1));
00083 /* L30: */
00084     }
00085     if (*n < 6) {
00086         goto L60;
00087     }
00088 L40:
00089     mp1 = m + 1;
00090     i__2 = *n;
00091     for (i__ = mp1; i__ <= i__2; i__ += 6) {
00092         stemp = stemp + (r__1 = sx[i__], dabs(r__1)) + (r__2 = sx[i__ + 1], 
00093                 dabs(r__2)) + (r__3 = sx[i__ + 2], dabs(r__3)) + (r__4 = sx[
00094                 i__ + 3], dabs(r__4)) + (r__5 = sx[i__ + 4], dabs(r__5)) + (
00095                 r__6 = sx[i__ + 5], dabs(r__6));
00096 /* L50: */
00097     }
00098 L60:
00099     ret_val = stemp;
00100     return ret_val;
00101 } /* sasum_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:56