Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / sswap.c
1 #include "clapack.h"
2
3 /* Subroutine */ int sswap_(integer *n, real *sx, integer *incx, real *sy, 
4         integer *incy)
5 {
6     /* System generated locals */
7     integer i__1;
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 /*     interchanges two vectors. */
22 /*     uses unrolled loops for increments equal to 1. */
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     if (*n <= 0) {
37         return 0;
38     }
39     if (*incx == 1 && *incy == 1) {
40         goto L20;
41     }
42
43 /*       code for unequal increments or equal increments not equal */
44 /*         to 1 */
45
46     ix = 1;
47     iy = 1;
48     if (*incx < 0) {
49         ix = (-(*n) + 1) * *incx + 1;
50     }
51     if (*incy < 0) {
52         iy = (-(*n) + 1) * *incy + 1;
53     }
54     i__1 = *n;
55     for (i__ = 1; i__ <= i__1; ++i__) {
56         stemp = sx[ix];
57         sx[ix] = sy[iy];
58         sy[iy] = stemp;
59         ix += *incx;
60         iy += *incy;
61 /* L10: */
62     }
63     return 0;
64
65 /*       code for both increments equal to 1 */
66
67
68 /*       clean-up loop */
69
70 L20:
71     m = *n % 3;
72     if (m == 0) {
73         goto L40;
74     }
75     i__1 = m;
76     for (i__ = 1; i__ <= i__1; ++i__) {
77         stemp = sx[i__];
78         sx[i__] = sy[i__];
79         sy[i__] = stemp;
80 /* L30: */
81     }
82     if (*n < 3) {
83         return 0;
84     }
85 L40:
86     mp1 = m + 1;
87     i__1 = *n;
88     for (i__ = mp1; i__ <= i__1; i__ += 3) {
89         stemp = sx[i__];
90         sx[i__] = sy[i__];
91         sy[i__] = stemp;
92         stemp = sx[i__ + 1];
93         sx[i__ + 1] = sy[i__ + 1];
94         sy[i__ + 1] = stemp;
95         stemp = sx[i__ + 2];
96         sx[i__ + 2] = sy[i__ + 2];
97         sy[i__ + 2] = stemp;
98 /* L50: */
99     }
100     return 0;
101 } /* sswap_ */