|
kusano |
7d535a |
#include "f2c.h"
|
|
kusano |
7d535a |
/*#include "blaswrap.h"*/
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx,
|
|
kusano |
7d535a |
doublereal *dy, integer *incy)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
/* System generated locals */
|
|
kusano |
7d535a |
integer i__1;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Local variables */
|
|
kusano |
7d535a |
integer i__, m, ix, iy, mp1;
|
|
kusano |
7d535a |
doublereal dtemp;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* .. Scalar Arguments .. */
|
|
kusano |
7d535a |
/* .. */
|
|
kusano |
7d535a |
/* .. Array Arguments .. */
|
|
kusano |
7d535a |
/* .. */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Purpose */
|
|
kusano |
7d535a |
/* ======= */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* interchanges two vectors. */
|
|
kusano |
7d535a |
/* uses unrolled loops for increments equal one. */
|
|
kusano |
7d535a |
/* jack dongarra, linpack, 3/11/78. */
|
|
kusano |
7d535a |
/* modified 12/3/93, array(1) declarations changed to array(*) */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* .. Local Scalars .. */
|
|
kusano |
7d535a |
/* .. */
|
|
kusano |
7d535a |
/* .. Intrinsic Functions .. */
|
|
kusano |
7d535a |
/* .. */
|
|
kusano |
7d535a |
/* Parameter adjustments */
|
|
kusano |
7d535a |
--dy;
|
|
kusano |
7d535a |
--dx;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* Function Body */
|
|
kusano |
7d535a |
if (*n <= 0) {
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if (*incx == 1 && *incy == 1) {
|
|
kusano |
7d535a |
goto L20;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* code for unequal increments or equal increments not equal */
|
|
kusano |
7d535a |
/* to 1 */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
ix = 1;
|
|
kusano |
7d535a |
iy = 1;
|
|
kusano |
7d535a |
if (*incx < 0) {
|
|
kusano |
7d535a |
ix = (-(*n) + 1) * *incx + 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if (*incy < 0) {
|
|
kusano |
7d535a |
iy = (-(*n) + 1) * *incy + 1;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
i__1 = *n;
|
|
kusano |
7d535a |
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
kusano |
7d535a |
dtemp = dx[ix];
|
|
kusano |
7d535a |
dx[ix] = dy[iy];
|
|
kusano |
7d535a |
dy[iy] = dtemp;
|
|
kusano |
7d535a |
ix += *incx;
|
|
kusano |
7d535a |
iy += *incy;
|
|
kusano |
7d535a |
/* L10: */
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* code for both increments equal to 1 */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
/* clean-up loop */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
L20:
|
|
kusano |
7d535a |
m = *n % 3;
|
|
kusano |
7d535a |
if (m == 0) {
|
|
kusano |
7d535a |
goto L40;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
i__1 = m;
|
|
kusano |
7d535a |
for (i__ = 1; i__ <= i__1; ++i__) {
|
|
kusano |
7d535a |
dtemp = dx[i__];
|
|
kusano |
7d535a |
dx[i__] = dy[i__];
|
|
kusano |
7d535a |
dy[i__] = dtemp;
|
|
kusano |
7d535a |
/* L30: */
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if (*n < 3) {
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
L40:
|
|
kusano |
7d535a |
mp1 = m + 1;
|
|
kusano |
7d535a |
i__1 = *n;
|
|
kusano |
7d535a |
for (i__ = mp1; i__ <= i__1; i__ += 3) {
|
|
kusano |
7d535a |
dtemp = dx[i__];
|
|
kusano |
7d535a |
dx[i__] = dy[i__];
|
|
kusano |
7d535a |
dy[i__] = dtemp;
|
|
kusano |
7d535a |
dtemp = dx[i__ + 1];
|
|
kusano |
7d535a |
dx[i__ + 1] = dy[i__ + 1];
|
|
kusano |
7d535a |
dy[i__ + 1] = dtemp;
|
|
kusano |
7d535a |
dtemp = dx[i__ + 2];
|
|
kusano |
7d535a |
dx[i__ + 2] = dy[i__ + 2];
|
|
kusano |
7d535a |
dy[i__ + 2] = dtemp;
|
|
kusano |
7d535a |
/* L50: */
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
return 0;
|
|
kusano |
7d535a |
} /* dswap_ */
|