LAPACK  3.8.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 *> \date November 2017
70 *
71 *> \ingroup single_blas_level1
72 *
73 *> \par Further Details:
74 * =====================
75 *>
76 *> \verbatim
77 *>
78 *> jack dongarra, linpack, 3/11/78.
79 *> modified 12/3/93, array(1) declarations changed to array(*)
80 *> \endverbatim
81 *>
82 * =====================================================================
83  SUBROUTINE sswap(N,SX,INCX,SY,INCY)
84 *
85 * -- Reference BLAS level1 routine (version 3.8.0) --
86 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
87 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
88 * November 2017
89 *
90 * .. Scalar Arguments ..
91  INTEGER INCX,INCY,N
92 * ..
93 * .. Array Arguments ..
94  REAL SX(*),SY(*)
95 * ..
96 *
97 * =====================================================================
98 *
99 * .. Local Scalars ..
100  REAL STEMP
101  INTEGER I,IX,IY,M,MP1
102 * ..
103 * .. Intrinsic Functions ..
104  INTRINSIC mod
105 * ..
106  IF (n.LE.0) RETURN
107  IF (incx.EQ.1 .AND. incy.EQ.1) THEN
108 *
109 * code for both increments equal to 1
110 *
111 *
112 * clean-up loop
113 *
114  m = mod(n,3)
115  IF (m.NE.0) THEN
116  DO i = 1,m
117  stemp = sx(i)
118  sx(i) = sy(i)
119  sy(i) = stemp
120  END DO
121  IF (n.LT.3) RETURN
122  END IF
123  mp1 = m + 1
124  DO i = mp1,n,3
125  stemp = sx(i)
126  sx(i) = sy(i)
127  sy(i) = stemp
128  stemp = sx(i+1)
129  sx(i+1) = sy(i+1)
130  sy(i+1) = stemp
131  stemp = sx(i+2)
132  sx(i+2) = sy(i+2)
133  sy(i+2) = stemp
134  END DO
135  ELSE
136 *
137 * code for unequal increments or equal increments not equal
138 * to 1
139 *
140  ix = 1
141  iy = 1
142  IF (incx.LT.0) ix = (-n+1)*incx + 1
143  IF (incy.LT.0) iy = (-n+1)*incy + 1
144  DO i = 1,n
145  stemp = sx(ix)
146  sx(ix) = sy(iy)
147  sy(iy) = stemp
148  ix = ix + incx
149  iy = iy + incy
150  END DO
151  END IF
152  RETURN
153  END
subroutine sswap(N, SX, INCX, SY, INCY)
SSWAP
Definition: sswap.f:84