1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
real function sasum(n,sx,incx)
c
c takes the sum of the absolute values.
c uses unrolled loops for increment equal to one.
c jack dongarra, linpack, 3/11/78.
c modified to correct problem with negative increment, 8/21/90.
c
real sx(1),stemp
integer i,incx,ix,m,mp1,n
c
sasum = 0.0e0
stemp = 0.0e0
if(n.le.0)return
if(incx.eq.1)go to 20
c
c code for increment not equal to 1
c
ix = 1
if(incx.lt.0)ix = (-n+1)*incx + 1
do 10 i = 1,n
stemp = stemp + abs(sx(ix))
ix = ix + incx
10 continue
sasum = stemp
return
c
c code for increment equal to 1
c
c
c clean-up loop
c
20 m = mod(n,6)
if( m .eq. 0 ) go to 40
do 30 i = 1,m
stemp = stemp + abs(sx(i))
30 continue
if( n .lt. 6 ) go to 60
40 mp1 = m + 1
do 50 i = mp1,n,6
stemp = stemp + abs(sx(i)) + abs(sx(i + 1)) + abs(sx(i + 2))
* + abs(sx(i + 3)) + abs(sx(i + 4)) + abs(sx(i + 5))
50 continue
60 sasum = stemp
return
end
|