LAPACK 3.3.1
Linear Algebra PACKage

saxpy.f

Go to the documentation of this file.
00001       SUBROUTINE SAXPY(N,SA,SX,INCX,SY,INCY)
00002 *     .. Scalar Arguments ..
00003       REAL SA
00004       INTEGER INCX,INCY,N
00005 *     ..
00006 *     .. Array Arguments ..
00007       REAL SX(*),SY(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *     SAXPY constant times a vector plus a vector.
00014 *     uses unrolled loops for increments equal to one.
00015 *
00016 *  Further Details
00017 *  ===============
00018 *
00019 *     jack dongarra, linpack, 3/11/78.
00020 *     modified 12/3/93, array(1) declarations changed to array(*)
00021 *
00022 *  =====================================================================
00023 *
00024 *     .. Local Scalars ..
00025       INTEGER I,IX,IY,M,MP1
00026 *     ..
00027 *     .. Intrinsic Functions ..
00028       INTRINSIC MOD
00029 *     ..
00030       IF (N.LE.0) RETURN
00031       IF (SA.EQ.0.0) RETURN
00032       IF (INCX.EQ.1 .AND. INCY.EQ.1) THEN
00033 *
00034 *        code for both increments equal to 1
00035 *
00036 *
00037 *        clean-up loop
00038 *
00039          M = MOD(N,4)
00040          IF (M.NE.0) THEN
00041             DO I = 1,M
00042                SY(I) = SY(I) + SA*SX(I)
00043             END DO
00044          END IF
00045          IF (N.LT.4) RETURN
00046          MP1 = M + 1
00047          DO I = MP1,N,4
00048             SY(I) = SY(I) + SA*SX(I)
00049             SY(I+1) = SY(I+1) + SA*SX(I+1)
00050             SY(I+2) = SY(I+2) + SA*SX(I+2)
00051             SY(I+3) = SY(I+3) + SA*SX(I+3)
00052          END DO
00053       ELSE
00054 *
00055 *        code for unequal increments or equal increments
00056 *          not equal to 1
00057 *
00058          IX = 1
00059          IY = 1
00060          IF (INCX.LT.0) IX = (-N+1)*INCX + 1
00061          IF (INCY.LT.0) IY = (-N+1)*INCY + 1
00062          DO I = 1,N
00063           SY(IY) = SY(IY) + SA*SX(IX)
00064           IX = IX + INCX
00065           IY = IY + INCY
00066          END DO
00067       END IF
00068       RETURN
00069       END
 All Files Functions