1 |
C daxpy.f |
2 |
C is freely available from netlib. It is not subject to any GNU License |
3 |
C set by the authors of the ASCEND math programming system. |
4 |
C $Date: 1996/04/30 18:14:07 $ $Revision: 1.1.1.1 $ |
5 |
C |
6 |
subroutine daxpy(n,da,dx,incx,dy,incy) |
7 |
c |
8 |
c constant times a vector plus a vector. |
9 |
c uses unrolled loops for increments equal to one. |
10 |
c jack dongarra, linpack, 3/11/78. |
11 |
c |
12 |
double precision dx(*),dy(*),da |
13 |
integer i,incx,incy,ix,iy,m,mp1,n |
14 |
c |
15 |
if(n.le.0)return |
16 |
if (da .eq. 0.0d0) return |
17 |
if(incx.eq.1.and.incy.eq.1)go to 20 |
18 |
c |
19 |
c code for unequal increments or equal increments |
20 |
c not equal to 1 |
21 |
c |
22 |
ix = 1 |
23 |
iy = 1 |
24 |
if(incx.lt.0)ix = (-n+1)*incx + 1 |
25 |
if(incy.lt.0)iy = (-n+1)*incy + 1 |
26 |
do 10 i = 1,n |
27 |
dy(iy) = dy(iy) + da*dx(ix) |
28 |
ix = ix + incx |
29 |
iy = iy + incy |
30 |
10 continue |
31 |
return |
32 |
c |
33 |
c code for both increments equal to 1 |
34 |
c |
35 |
c |
36 |
c clean-up loop |
37 |
c |
38 |
20 m = mod(n,4) |
39 |
if( m .eq. 0 ) go to 40 |
40 |
do 30 i = 1,m |
41 |
dy(i) = dy(i) + da*dx(i) |
42 |
30 continue |
43 |
if( n .lt. 4 ) return |
44 |
40 mp1 = m + 1 |
45 |
do 50 i = mp1,n,4 |
46 |
dy(i) = dy(i) + da*dx(i) |
47 |
dy(i + 1) = dy(i + 1) + da*dx(i + 1) |
48 |
dy(i + 2) = dy(i + 2) + da*dx(i + 2) |
49 |
dy(i + 3) = dy(i + 3) + da*dx(i + 3) |
50 |
50 continue |
51 |
return |
52 |
end |
53 |
|