LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
sswap.f
Go to the documentation of this file.
1 *> \brief \b SSWAP
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE SSWAP(N,SX,INCX,SY,INCY)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,INCY,N
15 * ..
16 * .. Array Arguments ..
17 * REAL SX(*),SY(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> SSWAP interchanges two vectors.
27 *> uses unrolled loops for increments equal to 1.
28 *> \endverbatim
29 *
30 * Arguments:
31 * ==========
32 *
33 *> \param[in] N
34 *> \verbatim
35 *> N is INTEGER
36 *> number of elements in input vector(s)
37 *> \endverbatim
38 *>
39 *> \param[in,out] SX
40 *> \verbatim
41 *> SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
42 *> \endverbatim
43 *>
44 *> \param[in] INCX
45 *> \verbatim
46 *> INCX is INTEGER
47 *> storage spacing between elements of SX
48 *> \endverbatim
49 *>
50 *> \param[in,out] SY
51 *> \verbatim
52 *> SY is REAL array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
53 *> \endverbatim
54 *>
55 *> \param[in] INCY
56 *> \verbatim
57 *> INCY is INTEGER
58 *> storage spacing between elements of SY
59 *> \endverbatim
60 *
61 * Authors:
62 * ========
63 *
64 *> \author Univ. of Tennessee
65 *> \author Univ. of California Berkeley
66 *> \author Univ. of Colorado Denver
67 *> \author NAG Ltd.
68 *
69 *> \ingroup single_blas_level1
70 *
71 *> \par Further Details:
72 * =====================
73 *>
74 *> \verbatim
75 *>
76 *> jack dongarra, linpack, 3/11/78.
77 *> modified 12/3/93, array(1) declarations changed to array(*)
78 *> \endverbatim
79 *>
80 * =====================================================================
81  SUBROUTINE sswap(N,SX,INCX,SY,INCY)
82 *
83 * -- Reference BLAS level1 routine --
84 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
85 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
86 *
87 * .. Scalar Arguments ..
88  INTEGER INCX,INCY,N
89 * ..
90 * .. Array Arguments ..
91  REAL SX(*),SY(*)
92 * ..
93 *
94 * =====================================================================
95 *
96 * .. Local Scalars ..
97  REAL STEMP
98  INTEGER I,IX,IY,M,MP1
99 * ..
100 * .. Intrinsic Functions ..
101  INTRINSIC mod
102 * ..
103  IF (n.LE.0) RETURN
104  IF (incx.EQ.1 .AND. incy.EQ.1) THEN
105 *
106 * code for both increments equal to 1
107 *
108 *
109 * clean-up loop
110 *
111  m = mod(n,3)
112  IF (m.NE.0) THEN
113  DO i = 1,m
114  stemp = sx(i)
115  sx(i) = sy(i)
116  sy(i) = stemp
117  END DO
118  IF (n.LT.3) RETURN
119  END IF
120  mp1 = m + 1
121  DO i = mp1,n,3
122  stemp = sx(i)
123  sx(i) = sy(i)
124  sy(i) = stemp
125  stemp = sx(i+1)
126  sx(i+1) = sy(i+1)
127  sy(i+1) = stemp
128  stemp = sx(i+2)
129  sx(i+2) = sy(i+2)
130  sy(i+2) = stemp
131  END DO
132  ELSE
133 *
134 * code for unequal increments or equal increments not equal
135 * to 1
136 *
137  ix = 1
138  iy = 1
139  IF (incx.LT.0) ix = (-n+1)*incx + 1
140  IF (incy.LT.0) iy = (-n+1)*incy + 1
141  DO i = 1,n
142  stemp = sx(ix)
143  sx(ix) = sy(iy)
144  sy(iy) = stemp
145  ix = ix + incx
146  iy = iy + incy
147  END DO
148  END IF
149  RETURN
150 *
151 * End of SSWAP
152 *
153  END
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:82