2 SUBROUTINE DAXPY
(N
, DA
, DX
, INCX
, DY
, INCY
)
3 C***BEGIN PROLOGUE DAXPY
4 C***PURPOSE Compute a constant times a vector plus a vector.
6 C***TYPE DOUBLE PRECISION (SAXPY-S, DAXPY-D, CAXPY-C)
7 C***KEYWORDS BLAS, LINEAR ALGEBRA, TRIAD, VECTOR
8 C***AUTHOR Lawson, C. L., (JPL)
9 C Hanson, R. J., (SNLA)
10 C Kincaid, D. R., (U. of Texas)
15 C Description of Parameters
18 C N number of elements in input vector(s)
19 C DA double precision scalar multiplier
20 C DX double precision vector with N elements
21 C INCX storage spacing between elements of DX
22 C DY double precision vector with N elements
23 C INCY storage spacing between elements of DY
26 C DY double precision result (unchanged if N .LE. 0)
28 C Overwrite double precision DY with double precision DA*DX + DY.
29 C For I = 0 to N-1, replace DY(LY+I*INCY) with DA*DX(LX+I*INCX) +
31 C where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
32 C defined in a similar way using INCY.
34 C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
35 C Krogh, Basic linear algebra subprograms for Fortran
36 C usage, Algorithm No. 539, Transactions on Mathematical
37 C Software 5, 3 (September 1979), pp. 308-323.
38 C***ROUTINES CALLED (NONE)
39 C***REVISION HISTORY (YYMMDD)
41 C 890831 Modified array declarations. (WRB)
42 C 890831 REVISION DATE from Version 3.2
43 C 891214 Prologue converted to Version 4.0 format. (BAB)
44 C 920310 Corrected definition of LX in DESCRIPTION. (WRB)
45 C 920501 Reformatted the REFERENCES section. (WRB)
46 C***END PROLOGUE DAXPY
47 DOUBLE PRECISION DX
(*), DY
(*), DA
48 C***FIRST EXECUTABLE STATEMENT DAXPY
49 IF (N
.LE
.0 .OR
. DA
.EQ
.0.0D0
) RETURN
50 IF (INCX
.EQ
. INCY
) IF (INCX
-1) 5,20,60
52 C Code for unequal or nonpositive increments.
56 IF (INCX
.LT
. 0) IX
= (-N
+1)*INCX
+ 1
57 IF (INCY
.LT
. 0) IY
= (-N
+1)*INCY
+ 1
59 DY
(IY
) = DY
(IY
) + DA*DX
(IX
)
65 C Code for both increments equal to 1.
67 C Clean-up loop so remaining vector length is a multiple of 4.
70 IF (M
.EQ
. 0) GO TO 40
72 DY
(I
) = DY
(I
) + DA*DX
(I
)
77 DY
(I
) = DY
(I
) + DA*DX
(I
)
78 DY
(I
+1) = DY
(I
+1) + DA*DX
(I
+1)
79 DY
(I
+2) = DY
(I
+2) + DA*DX
(I
+2)
80 DY
(I
+3) = DY
(I
+3) + DA*DX
(I
+3)
84 C Code for equal, positive, non-unit increments.
88 DY
(I
) = DA*DX
(I
) + DY
(I
)