LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ sswap()

subroutine sswap ( integer  N,
real, dimension(*)  SX,
integer  INCX,
real, dimension(*)  SY,
integer  INCY 
)

SSWAP

Purpose:
    SSWAP interchanges two vectors.
    uses unrolled loops for increments equal to 1.
Parameters
[in]N
          N is INTEGER
         number of elements in input vector(s)
[in,out]SX
          SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
[in]INCX
          INCX is INTEGER
         storage spacing between elements of SX
[in,out]SY
          SY is REAL array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
[in]INCY
          INCY is INTEGER
         storage spacing between elements of SY
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2017
Further Details:
     jack dongarra, linpack, 3/11/78.
     modified 12/3/93, array(1) declarations changed to array(*)

Definition at line 84 of file sswap.f.

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