c@427
|
1 /* dswap.f -- translated by f2c (version 20061008).
|
c@427
|
2 You must link the resulting object file with libf2c:
|
c@427
|
3 on Microsoft Windows system, link with libf2c.lib;
|
c@427
|
4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
|
c@427
|
5 or, if you install libf2c.a in a standard place, with -lf2c -lm
|
c@427
|
6 -- in that order, at the end of the command line, as in
|
c@427
|
7 cc *.o -lf2c -lm
|
c@427
|
8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
|
c@427
|
9
|
c@427
|
10 http://www.netlib.org/f2c/libf2c.zip
|
c@427
|
11 */
|
c@427
|
12
|
c@427
|
13 #include "f2c.h"
|
c@427
|
14 #include "blaswrap.h"
|
c@427
|
15
|
c@427
|
16 /* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx,
|
c@427
|
17 doublereal *dy, integer *incy)
|
c@427
|
18 {
|
c@427
|
19 /* System generated locals */
|
c@427
|
20 integer i__1;
|
c@427
|
21
|
c@427
|
22 /* Local variables */
|
c@427
|
23 integer i__, m, ix, iy, mp1;
|
c@427
|
24 doublereal dtemp;
|
c@427
|
25
|
c@427
|
26 /* .. Scalar Arguments .. */
|
c@427
|
27 /* .. */
|
c@427
|
28 /* .. Array Arguments .. */
|
c@427
|
29 /* .. */
|
c@427
|
30
|
c@427
|
31 /* Purpose */
|
c@427
|
32 /* ======= */
|
c@427
|
33
|
c@427
|
34 /* interchanges two vectors. */
|
c@427
|
35 /* uses unrolled loops for increments equal one. */
|
c@427
|
36 /* jack dongarra, linpack, 3/11/78. */
|
c@427
|
37 /* modified 12/3/93, array(1) declarations changed to array(*) */
|
c@427
|
38
|
c@427
|
39
|
c@427
|
40 /* .. Local Scalars .. */
|
c@427
|
41 /* .. */
|
c@427
|
42 /* .. Intrinsic Functions .. */
|
c@427
|
43 /* .. */
|
c@427
|
44 /* Parameter adjustments */
|
c@427
|
45 --dy;
|
c@427
|
46 --dx;
|
c@427
|
47
|
c@427
|
48 /* Function Body */
|
c@427
|
49 if (*n <= 0) {
|
c@427
|
50 return 0;
|
c@427
|
51 }
|
c@427
|
52 if (*incx == 1 && *incy == 1) {
|
c@427
|
53 goto L20;
|
c@427
|
54 }
|
c@427
|
55
|
c@427
|
56 /* code for unequal increments or equal increments not equal */
|
c@427
|
57 /* to 1 */
|
c@427
|
58
|
c@427
|
59 ix = 1;
|
c@427
|
60 iy = 1;
|
c@427
|
61 if (*incx < 0) {
|
c@427
|
62 ix = (-(*n) + 1) * *incx + 1;
|
c@427
|
63 }
|
c@427
|
64 if (*incy < 0) {
|
c@427
|
65 iy = (-(*n) + 1) * *incy + 1;
|
c@427
|
66 }
|
c@427
|
67 i__1 = *n;
|
c@427
|
68 for (i__ = 1; i__ <= i__1; ++i__) {
|
c@427
|
69 dtemp = dx[ix];
|
c@427
|
70 dx[ix] = dy[iy];
|
c@427
|
71 dy[iy] = dtemp;
|
c@427
|
72 ix += *incx;
|
c@427
|
73 iy += *incy;
|
c@427
|
74 /* L10: */
|
c@427
|
75 }
|
c@427
|
76 return 0;
|
c@427
|
77
|
c@427
|
78 /* code for both increments equal to 1 */
|
c@427
|
79
|
c@427
|
80
|
c@427
|
81 /* clean-up loop */
|
c@427
|
82
|
c@427
|
83 L20:
|
c@427
|
84 m = *n % 3;
|
c@427
|
85 if (m == 0) {
|
c@427
|
86 goto L40;
|
c@427
|
87 }
|
c@427
|
88 i__1 = m;
|
c@427
|
89 for (i__ = 1; i__ <= i__1; ++i__) {
|
c@427
|
90 dtemp = dx[i__];
|
c@427
|
91 dx[i__] = dy[i__];
|
c@427
|
92 dy[i__] = dtemp;
|
c@427
|
93 /* L30: */
|
c@427
|
94 }
|
c@427
|
95 if (*n < 3) {
|
c@427
|
96 return 0;
|
c@427
|
97 }
|
c@427
|
98 L40:
|
c@427
|
99 mp1 = m + 1;
|
c@427
|
100 i__1 = *n;
|
c@427
|
101 for (i__ = mp1; i__ <= i__1; i__ += 3) {
|
c@427
|
102 dtemp = dx[i__];
|
c@427
|
103 dx[i__] = dy[i__];
|
c@427
|
104 dy[i__] = dtemp;
|
c@427
|
105 dtemp = dx[i__ + 1];
|
c@427
|
106 dx[i__ + 1] = dy[i__ + 1];
|
c@427
|
107 dy[i__ + 1] = dtemp;
|
c@427
|
108 dtemp = dx[i__ + 2];
|
c@427
|
109 dx[i__ + 2] = dy[i__ + 2];
|
c@427
|
110 dy[i__ + 2] = dtemp;
|
c@427
|
111 /* L50: */
|
c@427
|
112 }
|
c@427
|
113 return 0;
|
c@427
|
114 } /* dswap_ */
|