Line | |
---|
1 | SUBROUTINE DSWAP(N,DX,INCX,DY,INCY) |
---|
2 | * .. Scalar Arguments .. |
---|
3 | INTEGER INCX,INCY,N |
---|
4 | * .. |
---|
5 | * .. Array Arguments .. |
---|
6 | DOUBLE PRECISION DX(*),DY(*) |
---|
7 | * .. |
---|
8 | * |
---|
9 | * Purpose |
---|
10 | * ======= |
---|
11 | * |
---|
12 | * interchanges two vectors. |
---|
13 | * uses unrolled loops for increments equal one. |
---|
14 | * jack dongarra, linpack, 3/11/78. |
---|
15 | * modified 12/3/93, array(1) declarations changed to array(*) |
---|
16 | * |
---|
17 | * |
---|
18 | * .. Local Scalars .. |
---|
19 | DOUBLE PRECISION DTEMP |
---|
20 | INTEGER I,IX,IY,M,MP1 |
---|
21 | * .. |
---|
22 | * .. Intrinsic Functions .. |
---|
23 | INTRINSIC MOD |
---|
24 | * .. |
---|
25 | IF (N.LE.0) RETURN |
---|
26 | IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20 |
---|
27 | * |
---|
28 | * code for unequal increments or equal increments not equal |
---|
29 | * to 1 |
---|
30 | * |
---|
31 | IX = 1 |
---|
32 | IY = 1 |
---|
33 | IF (INCX.LT.0) IX = (-N+1)*INCX + 1 |
---|
34 | IF (INCY.LT.0) IY = (-N+1)*INCY + 1 |
---|
35 | DO 10 I = 1,N |
---|
36 | DTEMP = DX(IX) |
---|
37 | DX(IX) = DY(IY) |
---|
38 | DY(IY) = DTEMP |
---|
39 | IX = IX + INCX |
---|
40 | IY = IY + INCY |
---|
41 | 10 CONTINUE |
---|
42 | RETURN |
---|
43 | * |
---|
44 | * code for both increments equal to 1 |
---|
45 | * |
---|
46 | * |
---|
47 | * clean-up loop |
---|
48 | * |
---|
49 | 20 M = MOD(N,3) |
---|
50 | IF (M.EQ.0) GO TO 40 |
---|
51 | DO 30 I = 1,M |
---|
52 | DTEMP = DX(I) |
---|
53 | DX(I) = DY(I) |
---|
54 | DY(I) = DTEMP |
---|
55 | 30 CONTINUE |
---|
56 | IF (N.LT.3) RETURN |
---|
57 | 40 MP1 = M + 1 |
---|
58 | DO 50 I = MP1,N,3 |
---|
59 | DTEMP = DX(I) |
---|
60 | DX(I) = DY(I) |
---|
61 | DY(I) = DTEMP |
---|
62 | DTEMP = DX(I+1) |
---|
63 | DX(I+1) = DY(I+1) |
---|
64 | DY(I+1) = DTEMP |
---|
65 | DTEMP = DX(I+2) |
---|
66 | DX(I+2) = DY(I+2) |
---|
67 | DY(I+2) = DTEMP |
---|
68 | 50 CONTINUE |
---|
69 | RETURN |
---|
70 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.