LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE CSWAP(N,CX,INCX,CY,INCY) 00002 * .. Scalar Arguments .. 00003 INTEGER INCX,INCY,N 00004 * .. 00005 * .. Array Arguments .. 00006 COMPLEX CX(*),CY(*) 00007 * .. 00008 * 00009 * Purpose 00010 * ======= 00011 * 00012 * CSWAP interchanges two vectors. 00013 * 00014 * Further Details 00015 * =============== 00016 * 00017 * jack dongarra, linpack, 3/11/78. 00018 * modified 12/3/93, array(1) declarations changed to array(*) 00019 * 00020 * ===================================================================== 00021 * 00022 * .. Local Scalars .. 00023 COMPLEX CTEMP 00024 INTEGER I,IX,IY 00025 * .. 00026 IF (N.LE.0) RETURN 00027 IF (INCX.EQ.1 .AND. INCY.EQ.1) THEN 00028 * 00029 * code for both increments equal to 1 00030 DO I = 1,N 00031 CTEMP = CX(I) 00032 CX(I) = CY(I) 00033 CY(I) = CTEMP 00034 END DO 00035 ELSE 00036 * 00037 * code for unequal increments or equal increments not equal 00038 * to 1 00039 * 00040 IX = 1 00041 IY = 1 00042 IF (INCX.LT.0) IX = (-N+1)*INCX + 1 00043 IF (INCY.LT.0) IY = (-N+1)*INCY + 1 00044 DO I = 1,N 00045 CTEMP = CX(IX) 00046 CX(IX) = CY(IY) 00047 CY(IY) = CTEMP 00048 IX = IX + INCX 00049 IY = IY + INCY 00050 END DO 00051 END IF 00052 RETURN 00053 END