LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
daxpy.f
Go to the documentation of this file.
1 *> \brief \b DAXPY
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY)
12 *
13 * .. Scalar Arguments ..
14 * DOUBLE PRECISION DA
15 * INTEGER INCX,INCY,N
16 * ..
17 * .. Array Arguments ..
18 * DOUBLE PRECISION DX(*),DY(*)
19 * ..
20 *
21 *
22 *> \par Purpose:
23 * =============
24 *>
25 *> \verbatim
26 *>
27 *> DAXPY constant times a vector plus a vector.
28 *> uses unrolled loops for increments equal to one.
29 *> \endverbatim
30 *
31 * Authors:
32 * ========
33 *
34 *> \author Univ. of Tennessee
35 *> \author Univ. of California Berkeley
36 *> \author Univ. of Colorado Denver
37 *> \author NAG Ltd.
38 *
39 *> \date November 2011
40 *
41 *> \ingroup double_blas_level1
42 *
43 *> \par Further Details:
44 * =====================
45 *>
46 *> \verbatim
47 *>
48 *> jack dongarra, linpack, 3/11/78.
49 *> modified 12/3/93, array(1) declarations changed to array(*)
50 *> \endverbatim
51 *>
52 * =====================================================================
53  SUBROUTINE daxpy(N,DA,DX,INCX,DY,INCY)
54 *
55 * -- Reference BLAS level1 routine (version 3.4.0) --
56 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
57 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
58 * November 2011
59 *
60 * .. Scalar Arguments ..
61  DOUBLE PRECISION da
62  INTEGER incx,incy,n
63 * ..
64 * .. Array Arguments ..
65  DOUBLE PRECISION dx(*),dy(*)
66 * ..
67 *
68 * =====================================================================
69 *
70 * .. Local Scalars ..
71  INTEGER i,ix,iy,m,mp1
72 * ..
73 * .. Intrinsic Functions ..
74  INTRINSIC mod
75 * ..
76  IF (n.LE.0) return
77  IF (da.EQ.0.0d0) return
78  IF (incx.EQ.1 .AND. incy.EQ.1) THEN
79 *
80 * code for both increments equal to 1
81 *
82 *
83 * clean-up loop
84 *
85  m = mod(n,4)
86  IF (m.NE.0) THEN
87  DO i = 1,m
88  dy(i) = dy(i) + da*dx(i)
89  END DO
90  END IF
91  IF (n.LT.4) return
92  mp1 = m + 1
93  DO i = mp1,n,4
94  dy(i) = dy(i) + da*dx(i)
95  dy(i+1) = dy(i+1) + da*dx(i+1)
96  dy(i+2) = dy(i+2) + da*dx(i+2)
97  dy(i+3) = dy(i+3) + da*dx(i+3)
98  END DO
99  ELSE
100 *
101 * code for unequal increments or equal increments
102 * not equal to 1
103 *
104  ix = 1
105  iy = 1
106  IF (incx.LT.0) ix = (-n+1)*incx + 1
107  IF (incy.LT.0) iy = (-n+1)*incy + 1
108  DO i = 1,n
109  dy(iy) = dy(iy) + da*dx(ix)
110  ix = ix + incx
111  iy = iy + incy
112  END DO
113  END IF
114  return
115  END