LAPACK 3.3.0

daxpy.f

Go to the documentation of this file.
00001       SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY)
00002 *     .. Scalar Arguments ..
00003       DOUBLE PRECISION DA
00004       INTEGER INCX,INCY,N
00005 *     ..
00006 *     .. Array Arguments ..
00007       DOUBLE PRECISION DX(*),DY(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *     DAXPY 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 (DA.EQ.0.0d0) RETURN
00032       IF (INCX.EQ.1 .AND. INCY.EQ.1) GO TO 20
00033 *
00034 *        code for unequal increments or equal increments
00035 *          not equal to 1
00036 *
00037       IX = 1
00038       IY = 1
00039       IF (INCX.LT.0) IX = (-N+1)*INCX + 1
00040       IF (INCY.LT.0) IY = (-N+1)*INCY + 1
00041       DO 10 I = 1,N
00042           DY(IY) = DY(IY) + DA*DX(IX)
00043           IX = IX + INCX
00044           IY = IY + INCY
00045    10 CONTINUE
00046       RETURN
00047 *
00048 *        code for both increments equal to 1
00049 *
00050 *
00051 *        clean-up loop
00052 *
00053    20 M = MOD(N,4)
00054       IF (M.EQ.0) GO TO 40
00055       DO 30 I = 1,M
00056           DY(I) = DY(I) + DA*DX(I)
00057    30 CONTINUE
00058       IF (N.LT.4) RETURN
00059    40 MP1 = M + 1
00060       DO 50 I = MP1,N,4
00061           DY(I) = DY(I) + DA*DX(I)
00062           DY(I+1) = DY(I+1) + DA*DX(I+1)
00063           DY(I+2) = DY(I+2) + DA*DX(I+2)
00064           DY(I+3) = DY(I+3) + DA*DX(I+3)
00065    50 CONTINUE
00066       RETURN
00067       END
 All Files Functions