dswap.c
Go to the documentation of this file.
00001 /* dswap.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx, 
00017         doublereal *dy, integer *incy)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021 
00022     /* Local variables */
00023     integer i__, m, ix, iy, mp1;
00024     doublereal dtemp;
00025 
00026 /*     .. Scalar Arguments .. */
00027 /*     .. */
00028 /*     .. Array Arguments .. */
00029 /*     .. */
00030 
00031 /*  Purpose */
00032 /*  ======= */
00033 
00034 /*     interchanges two vectors. */
00035 /*     uses unrolled loops for increments equal one. */
00036 /*     jack dongarra, linpack, 3/11/78. */
00037 /*     modified 12/3/93, array(1) declarations changed to array(*) */
00038 
00039 
00040 /*     .. Local Scalars .. */
00041 /*     .. */
00042 /*     .. Intrinsic Functions .. */
00043 /*     .. */
00044     /* Parameter adjustments */
00045     --dy;
00046     --dx;
00047 
00048     /* Function Body */
00049     if (*n <= 0) {
00050         return 0;
00051     }
00052     if (*incx == 1 && *incy == 1) {
00053         goto L20;
00054     }
00055 
00056 /*       code for unequal increments or equal increments not equal */
00057 /*         to 1 */
00058 
00059     ix = 1;
00060     iy = 1;
00061     if (*incx < 0) {
00062         ix = (-(*n) + 1) * *incx + 1;
00063     }
00064     if (*incy < 0) {
00065         iy = (-(*n) + 1) * *incy + 1;
00066     }
00067     i__1 = *n;
00068     for (i__ = 1; i__ <= i__1; ++i__) {
00069         dtemp = dx[ix];
00070         dx[ix] = dy[iy];
00071         dy[iy] = dtemp;
00072         ix += *incx;
00073         iy += *incy;
00074 /* L10: */
00075     }
00076     return 0;
00077 
00078 /*       code for both increments equal to 1 */
00079 
00080 
00081 /*       clean-up loop */
00082 
00083 L20:
00084     m = *n % 3;
00085     if (m == 0) {
00086         goto L40;
00087     }
00088     i__1 = m;
00089     for (i__ = 1; i__ <= i__1; ++i__) {
00090         dtemp = dx[i__];
00091         dx[i__] = dy[i__];
00092         dy[i__] = dtemp;
00093 /* L30: */
00094     }
00095     if (*n < 3) {
00096         return 0;
00097     }
00098 L40:
00099     mp1 = m + 1;
00100     i__1 = *n;
00101     for (i__ = mp1; i__ <= i__1; i__ += 3) {
00102         dtemp = dx[i__];
00103         dx[i__] = dy[i__];
00104         dy[i__] = dtemp;
00105         dtemp = dx[i__ + 1];
00106         dx[i__ + 1] = dy[i__ + 1];
00107         dy[i__ + 1] = dtemp;
00108         dtemp = dx[i__ + 2];
00109         dx[i__ + 2] = dy[i__ + 2];
00110         dy[i__ + 2] = dtemp;
00111 /* L50: */
00112     }
00113     return 0;
00114 } /* dswap_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49