1 |
afe |
1.1 |
subroutine sscal(n,sa,sx,incx) |
2 |
|
|
c |
3 |
|
|
c scales a vector by a constant. |
4 |
|
|
c uses unrolled loops for increment equal to 1. |
5 |
|
|
c jack dongarra, linpack, 3/11/78. |
6 |
|
|
c modified 3/93 to return if incx .le. 0. |
7 |
|
|
c |
8 |
|
|
real sa,sx(1) |
9 |
|
|
integer i,incx,m,mp1,n,nincx |
10 |
|
|
c |
11 |
|
|
if( n.le.0 .or. incx.le.0 )return |
12 |
|
|
if(incx.eq.1)go to 20 |
13 |
|
|
c |
14 |
|
|
c code for increment not equal to 1 |
15 |
|
|
c |
16 |
|
|
nincx = n*incx |
17 |
|
|
do 10 i = 1,nincx,incx |
18 |
|
|
sx(i) = sa*sx(i) |
19 |
|
|
10 continue |
20 |
|
|
return |
21 |
|
|
c |
22 |
|
|
c code for increment equal to 1 |
23 |
|
|
c |
24 |
|
|
c |
25 |
|
|
c clean-up loop |
26 |
|
|
c |
27 |
|
|
20 m = mod(n,5) |
28 |
|
|
if( m .eq. 0 ) go to 40 |
29 |
|
|
do 30 i = 1,m |
30 |
|
|
sx(i) = sa*sx(i) |
31 |
|
|
30 continue |
32 |
|
|
if( n .lt. 5 ) return |
33 |
|
|
40 mp1 = m + 1 |
34 |
|
|
do 50 i = mp1,n,5 |
35 |
|
|
sx(i) = sa*sx(i) |
36 |
|
|
sx(i + 1) = sa*sx(i + 1) |
37 |
|
|
sx(i + 2) = sa*sx(i + 2) |
38 |
|
|
sx(i + 3) = sa*sx(i + 3) |
39 |
|
|
sx(i + 4) = sa*sx(i + 4) |
40 |
|
|
50 continue |
41 |
|
|
return |
42 |
|
|
end |