LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
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* Arguments:
32* ==========
33*
34*> \param[in] N
35*> \verbatim
36*> N is INTEGER
37*> number of elements in input vector(s)
38*> \endverbatim
39*>
40*> \param[in] SA
41*> \verbatim
42*> SA is REAL
43*> On entry, SA specifies the scalar alpha.
44*> \endverbatim
45*>
46*> \param[in] SX
47*> \verbatim
48*> SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
49*> \endverbatim
50*>
51*> \param[in] INCX
52*> \verbatim
53*> INCX is INTEGER
54*> storage spacing between elements of SX
55*> \endverbatim
56*>
57*> \param[in,out] SY
58*> \verbatim
59*> SY is REAL array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
60*> \endverbatim
61*>
62*> \param[in] INCY
63*> \verbatim
64*> INCY is INTEGER
65*> storage spacing between elements of SY
66*> \endverbatim
67*
68* Authors:
69* ========
70*
71*> \author Univ. of Tennessee
72*> \author Univ. of California Berkeley
73*> \author Univ. of Colorado Denver
74*> \author NAG Ltd.
75*
76*> \ingroup axpy
77*
78*> \par Further Details:
79* =====================
80*>
81*> \verbatim
82*>
83*> jack dongarra, linpack, 3/11/78.
84*> modified 12/3/93, array(1) declarations changed to array(*)
85*> \endverbatim
86*>
87* =====================================================================
88 SUBROUTINE saxpy(N,SA,SX,INCX,SY,INCY)
89*
90* -- Reference BLAS level1 routine --
91* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
92* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
93*
94* .. Scalar Arguments ..
95 REAL SA
96 INTEGER INCX,INCY,N
97* ..
98* .. Array Arguments ..
99 REAL SX(*),SY(*)
100* ..
101*
102* =====================================================================
103*
104* .. Local Scalars ..
105 INTEGER I,IX,IY,M,MP1
106* ..
107* .. Intrinsic Functions ..
108 INTRINSIC mod
109* ..
110 IF (n.LE.0) RETURN
111 IF (sa.EQ.0.0) RETURN
112 IF (incx.EQ.1 .AND. incy.EQ.1) THEN
113*
114* code for both increments equal to 1
115*
116*
117* clean-up loop
118*
119 m = mod(n,4)
120 IF (m.NE.0) THEN
121 DO i = 1,m
122 sy(i) = sy(i) + sa*sx(i)
123 END DO
124 END IF
125 IF (n.LT.4) RETURN
126 mp1 = m + 1
127 DO i = mp1,n,4
128 sy(i) = sy(i) + sa*sx(i)
129 sy(i+1) = sy(i+1) + sa*sx(i+1)
130 sy(i+2) = sy(i+2) + sa*sx(i+2)
131 sy(i+3) = sy(i+3) + sa*sx(i+3)
132 END DO
133 ELSE
134*
135* code for unequal increments or equal increments
136* not equal to 1
137*
138 ix = 1
139 iy = 1
140 IF (incx.LT.0) ix = (-n+1)*incx + 1
141 IF (incy.LT.0) iy = (-n+1)*incy + 1
142 DO i = 1,n
143 sy(iy) = sy(iy) + sa*sx(ix)
144 ix = ix + incx
145 iy = iy + incy
146 END DO
147 END IF
148 RETURN
149*
150* End of SAXPY
151*
152 END
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
Definition saxpy.f:89