Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / dasum.c
1 #include "clapack.h"
2
3 doublereal dasum_(integer *n, doublereal *dx, integer *incx)
4 {
5     /* System generated locals */
6     integer i__1, i__2;
7     doublereal ret_val, d__1, d__2, d__3, d__4, d__5, d__6;
8
9     /* Local variables */
10     integer i__, m, mp1;
11     doublereal dtemp;
12     integer nincx;
13
14 /*     .. Scalar Arguments .. */
15 /*     .. */
16 /*     .. Array Arguments .. */
17 /*     .. */
18
19 /*  Purpose */
20 /*  ======= */
21
22 /*     takes the sum of the absolute values. */
23 /*     jack dongarra, linpack, 3/11/78. */
24 /*     modified 3/93 to return if incx .le. 0. */
25 /*     modified 12/3/93, array(1) declarations changed to array(*) */
26
27
28 /*     .. Local Scalars .. */
29 /*     .. */
30 /*     .. Intrinsic Functions .. */
31 /*     .. */
32     /* Parameter adjustments */
33     --dx;
34
35     /* Function Body */
36     ret_val = 0.;
37     dtemp = 0.;
38     if (*n <= 0 || *incx <= 0) {
39         return ret_val;
40     }
41     if (*incx == 1) {
42         goto L20;
43     }
44
45 /*        code for increment not equal to 1 */
46
47     nincx = *n * *incx;
48     i__1 = nincx;
49     i__2 = *incx;
50     for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
51         dtemp += (d__1 = dx[i__], abs(d__1));
52 /* L10: */
53     }
54     ret_val = dtemp;
55     return ret_val;
56
57 /*        code for increment equal to 1 */
58
59
60 /*        clean-up loop */
61
62 L20:
63     m = *n % 6;
64     if (m == 0) {
65         goto L40;
66     }
67     i__2 = m;
68     for (i__ = 1; i__ <= i__2; ++i__) {
69         dtemp += (d__1 = dx[i__], abs(d__1));
70 /* L30: */
71     }
72     if (*n < 6) {
73         goto L60;
74     }
75 L40:
76     mp1 = m + 1;
77     i__2 = *n;
78     for (i__ = mp1; i__ <= i__2; i__ += 6) {
79         dtemp = dtemp + (d__1 = dx[i__], abs(d__1)) + (d__2 = dx[i__ + 1], 
80                 abs(d__2)) + (d__3 = dx[i__ + 2], abs(d__3)) + (d__4 = dx[i__ 
81                 + 3], abs(d__4)) + (d__5 = dx[i__ + 4], abs(d__5)) + (d__6 = 
82                 dx[i__ + 5], abs(d__6));
83 /* L50: */
84     }
85 L60:
86     ret_val = dtemp;
87     return ret_val;
88 } /* dasum_ */