1 |
C dscal.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: 1998/04/25 14:18:09 $ $Revision: 1.2 $ |
5 |
C |
6 |
subroutine dscal(n,da,dx,incx) |
7 |
c |
8 |
c scales a vector dx by a constant da. |
9 |
c uses unrolled loops for increment equal to one. |
10 |
c jack dongarra, linpack, 3/11/78. |
11 |
c |
12 |
double precision da,dx(*) |
13 |
integer i,incx,m,mp1,n,nincx |
14 |
c |
15 |
if(n.le.0)return |
16 |
if(incx.eq.1)go to 20 |
17 |
c |
18 |
c code for increment not equal to 1 |
19 |
c |
20 |
nincx = n*incx |
21 |
do 10 i = 1,nincx,incx |
22 |
dx(i) = da*dx(i) |
23 |
10 continue |
24 |
return |
25 |
c |
26 |
c code for increment equal to 1 |
27 |
c |
28 |
c |
29 |
c clean-up loop |
30 |
c |
31 |
20 m = mod(n,5) |
32 |
if( m .eq. 0 ) go to 40 |
33 |
do 30 i = 1,m |
34 |
dx(i) = da*dx(i) |
35 |
30 continue |
36 |
if( n .lt. 5 ) return |
37 |
40 mp1 = m + 1 |
38 |
do 50 i = mp1,n,5 |
39 |
dx(i) = da*dx(i) |
40 |
dx(i + 1) = da*dx(i + 1) |
41 |
dx(i + 2) = da*dx(i + 2) |
42 |
dx(i + 3) = da*dx(i + 3) |
43 |
dx(i + 4) = da*dx(i + 4) |
44 |
50 continue |
45 |
return |
46 |
end |
47 |
|