LAPACK 3.3.0

sscal.f

Go to the documentation of this file.
00001       SUBROUTINE SSCAL(N,SA,SX,INCX)
00002 *     .. Scalar Arguments ..
00003       REAL SA
00004       INTEGER INCX,N
00005 *     ..
00006 *     .. Array Arguments ..
00007       REAL SX(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *     scales a vector by a constant.
00014 *     uses unrolled loops for increment equal to 1.
00015 *
00016 *  Further Details
00017 *  ===============
00018 *
00019 *     jack dongarra, linpack, 3/11/78.
00020 *     modified 3/93 to return if incx .le. 0.
00021 *     modified 12/3/93, array(1) declarations changed to array(*)
00022 *
00023 *  =====================================================================
00024 *
00025 *     .. Local Scalars ..
00026       INTEGER I,M,MP1,NINCX
00027 *     ..
00028 *     .. Intrinsic Functions ..
00029       INTRINSIC MOD
00030 *     ..
00031       IF (N.LE.0 .OR. INCX.LE.0) RETURN
00032       IF (INCX.EQ.1) GO TO 20
00033 *
00034 *        code for increment not equal to 1
00035 *
00036       NINCX = N*INCX
00037       DO 10 I = 1,NINCX,INCX
00038           SX(I) = SA*SX(I)
00039    10 CONTINUE
00040       RETURN
00041 *
00042 *        code for increment equal to 1
00043 *
00044 *
00045 *        clean-up loop
00046 *
00047    20 M = MOD(N,5)
00048       IF (M.EQ.0) GO TO 40
00049       DO 30 I = 1,M
00050           SX(I) = SA*SX(I)
00051    30 CONTINUE
00052       IF (N.LT.5) RETURN
00053    40 MP1 = M + 1
00054       DO 50 I = MP1,N,5
00055           SX(I) = SA*SX(I)
00056           SX(I+1) = SA*SX(I+1)
00057           SX(I+2) = SA*SX(I+2)
00058           SX(I+3) = SA*SX(I+3)
00059           SX(I+4) = SA*SX(I+4)
00060    50 CONTINUE
00061       RETURN
00062       END
 All Files Functions