45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Fortran
		
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Fortran
		
	
	
	
|       real function sasumf(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 3/93 to return if incx .le. 0.
 | |
| c     modified 12/3/93, array(1) declarations changed to array(*)
 | |
| c
 | |
|       real sx(*),stemp
 | |
|       integer i,incx,m,mp1,n,nincx
 | |
| c
 | |
|       sasumf = 0.0e0
 | |
|       stemp = 0.0e0
 | |
|       if( n.le.0 .or. incx.le.0 )return
 | |
|       if(incx.eq.1)go to 20
 | |
| c
 | |
| c        code for increment not equal to 1
 | |
| c
 | |
|       nincx = n*incx
 | |
|       do 10 i = 1,nincx,incx
 | |
|         stemp = stemp + abs(sx(i))
 | |
|    10 continue
 | |
|       sasumf = 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 sasumf = stemp
 | |
|       return
 | |
|       end
 |