dasum.c
Go to the documentation of this file.
00001 /* dasum.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 dasum_(integer *n, doublereal *dx, integer *incx)
00017 {
00018     /* System generated locals */
00019     integer i__1, i__2;
00020     doublereal ret_val, d__1, d__2, d__3, d__4, d__5, d__6;
00021 
00022     /* Local variables */
00023     integer i__, m, mp1;
00024     doublereal dtemp;
00025     integer nincx;
00026 
00027 /*     .. Scalar Arguments .. */
00028 /*     .. */
00029 /*     .. Array Arguments .. */
00030 /*     .. */
00031 
00032 /*  Purpose */
00033 /*  ======= */
00034 
00035 /*     takes the sum of the absolute values. */
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     --dx;
00047 
00048     /* Function Body */
00049     ret_val = 0.;
00050     dtemp = 0.;
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         dtemp += (d__1 = dx[i__], abs(d__1));
00065 /* L10: */
00066     }
00067     ret_val = dtemp;
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         dtemp += (d__1 = dx[i__], abs(d__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         dtemp = dtemp + (d__1 = dx[i__], abs(d__1)) + (d__2 = dx[i__ + 1], 
00093                 abs(d__2)) + (d__3 = dx[i__ + 2], abs(d__3)) + (d__4 = dx[i__ 
00094                 + 3], abs(d__4)) + (d__5 = dx[i__ + 4], abs(d__5)) + (d__6 = 
00095                 dx[i__ + 5], abs(d__6));
00096 /* L50: */
00097     }
00098 L60:
00099     ret_val = dtemp;
00100     return ret_val;
00101 } /* dasum_ */


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