Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / sdot.c
1 #include "clapack.h"
2
3 doublereal sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy)
4 {
5     /* System generated locals */
6     integer i__1;
7     real ret_val;
8
9     /* Local variables */
10     integer i__, m, ix, iy, mp1;
11     real stemp;
12
13 /*     .. Scalar Arguments .. */
14 /*     .. */
15 /*     .. Array Arguments .. */
16 /*     .. */
17
18 /*  Purpose */
19 /*  ======= */
20
21 /*     forms the dot product of two vectors. */
22 /*     uses unrolled loops for increments equal to one. */
23 /*     jack dongarra, linpack, 3/11/78. */
24 /*     modified 12/3/93, array(1) declarations changed to array(*) */
25
26
27 /*     .. Local Scalars .. */
28 /*     .. */
29 /*     .. Intrinsic Functions .. */
30 /*     .. */
31     /* Parameter adjustments */
32     --sy;
33     --sx;
34
35     /* Function Body */
36     stemp = 0.f;
37     ret_val = 0.f;
38     if (*n <= 0) {
39         return ret_val;
40     }
41     if (*incx == 1 && *incy == 1) {
42         goto L20;
43     }
44
45 /*        code for unequal increments or equal increments */
46 /*          not equal to 1 */
47
48     ix = 1;
49     iy = 1;
50     if (*incx < 0) {
51         ix = (-(*n) + 1) * *incx + 1;
52     }
53     if (*incy < 0) {
54         iy = (-(*n) + 1) * *incy + 1;
55     }
56     i__1 = *n;
57     for (i__ = 1; i__ <= i__1; ++i__) {
58         stemp += sx[ix] * sy[iy];
59         ix += *incx;
60         iy += *incy;
61 /* L10: */
62     }
63     ret_val = stemp;
64     return ret_val;
65
66 /*        code for both increments equal to 1 */
67
68
69 /*        clean-up loop */
70
71 L20:
72     m = *n % 5;
73     if (m == 0) {
74         goto L40;
75     }
76     i__1 = m;
77     for (i__ = 1; i__ <= i__1; ++i__) {
78         stemp += sx[i__] * sy[i__];
79 /* L30: */
80     }
81     if (*n < 5) {
82         goto L60;
83     }
84 L40:
85     mp1 = m + 1;
86     i__1 = *n;
87     for (i__ = mp1; i__ <= i__1; i__ += 5) {
88         stemp = stemp + sx[i__] * sy[i__] + sx[i__ + 1] * sy[i__ + 1] + sx[
89                 i__ + 2] * sy[i__ + 2] + sx[i__ + 3] * sy[i__ + 3] + sx[i__ + 
90                 4] * sy[i__ + 4];
91 /* L50: */
92     }
93 L60:
94     ret_val = stemp;
95     return ret_val;
96 } /* sdot_ */