LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ saxpy()

subroutine saxpy ( integer  N,
real  SA,
real, dimension(*)  SX,
integer  INCX,
real, dimension(*)  SY,
integer  INCY 
)

SAXPY

Purpose:
    SAXPY constant times a vector plus a vector.
    uses unrolled loops for increments equal to one.
Parameters
[in]N
          N is INTEGER
         number of elements in input vector(s)
[in]SA
          SA is REAL
           On entry, SA specifies the scalar alpha.
[in]SX
          SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
[in]INCX
          INCX is INTEGER
         storage spacing between elements of SX
[in,out]SY
          SY is REAL array, dimension ( 1 + ( N - 1 )*abs( INCY ) )
[in]INCY
          INCY is INTEGER
         storage spacing between elements of SY
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2017
Further Details:
     jack dongarra, linpack, 3/11/78.
     modified 12/3/93, array(1) declarations changed to array(*)

Definition at line 91 of file saxpy.f.

91 *
92 * -- Reference BLAS level1 routine (version 3.8.0) --
93 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
94 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
95 * November 2017
96 *
97 * .. Scalar Arguments ..
98  REAL SA
99  INTEGER INCX,INCY,N
100 * ..
101 * .. Array Arguments ..
102  REAL SX(*),SY(*)
103 * ..
104 *
105 * =====================================================================
106 *
107 * .. Local Scalars ..
108  INTEGER I,IX,IY,M,MP1
109 * ..
110 * .. Intrinsic Functions ..
111  INTRINSIC mod
112 * ..
113  IF (n.LE.0) RETURN
114  IF (sa.EQ.0.0) RETURN
115  IF (incx.EQ.1 .AND. incy.EQ.1) THEN
116 *
117 * code for both increments equal to 1
118 *
119 *
120 * clean-up loop
121 *
122  m = mod(n,4)
123  IF (m.NE.0) THEN
124  DO i = 1,m
125  sy(i) = sy(i) + sa*sx(i)
126  END DO
127  END IF
128  IF (n.LT.4) RETURN
129  mp1 = m + 1
130  DO i = mp1,n,4
131  sy(i) = sy(i) + sa*sx(i)
132  sy(i+1) = sy(i+1) + sa*sx(i+1)
133  sy(i+2) = sy(i+2) + sa*sx(i+2)
134  sy(i+3) = sy(i+3) + sa*sx(i+3)
135  END DO
136  ELSE
137 *
138 * code for unequal increments or equal increments
139 * not equal to 1
140 *
141  ix = 1
142  iy = 1
143  IF (incx.LT.0) ix = (-n+1)*incx + 1
144  IF (incy.LT.0) iy = (-n+1)*incy + 1
145  DO i = 1,n
146  sy(iy) = sy(iy) + sa*sx(ix)
147  ix = ix + incx
148  iy = iy + incy
149  END DO
150  END IF
151  RETURN