LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
 All Classes Files Functions Variables Typedefs Macros
saxpy.f
Go to the documentation of this file.
1 *> \brief \b SAXPY
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 SAXPY(N,SA,SX,INCX,SY,INCY)
12 *
13 * .. Scalar Arguments ..
14 * REAL SA
15 * INTEGER INCX,INCY,N
16 * ..
17 * .. Array Arguments ..
18 * REAL SX(*),SY(*)
19 * ..
20 *
21 *
22 *> \par Purpose:
23 * =============
24 *>
25 *> \verbatim
26 *>
27 *> SAXPY 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 single_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 saxpy(N,SA,SX,INCX,SY,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  REAL sa
62  INTEGER incx,incy,n
63 * ..
64 * .. Array Arguments ..
65  REAL sx(*),sy(*)
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 (sa.EQ.0.0) 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  sy(i) = sy(i) + sa*sx(i)
89  END DO
90  END IF
91  IF (n.LT.4) RETURN
92  mp1 = m + 1
93  DO i = mp1,n,4
94  sy(i) = sy(i) + sa*sx(i)
95  sy(i+1) = sy(i+1) + sa*sx(i+1)
96  sy(i+2) = sy(i+2) + sa*sx(i+2)
97  sy(i+3) = sy(i+3) + sa*sx(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  sy(iy) = sy(iy) + sa*sx(ix)
110  ix = ix + incx
111  iy = iy + incy
112  END DO
113  END IF
114  RETURN
115  END