1 real function sdot(n,sx,incx,sy,incy) 2c 3c forms the dot product of two vectors. 4c uses unrolled loops for increments equal to one. 5c jack dongarra, linpack, 3/11/78. 6c modified 12/3/93, array(1) declarations changed to array(*) 7c 8 real sx(*),sy(*),stemp 9 integer i,incx,incy,ix,iy,m,mp1,n 10c 11 stemp = 0.0e0 12 sdot = 0.0e0 13 if(n.le.0)return 14 if(incx.eq.1.and.incy.eq.1)go to 20 15c 16c code for unequal increments or equal increments 17c not equal to 1 18c 19 ix = 1 20 iy = 1 21 if(incx.lt.0)ix = (-n+1)*incx + 1 22 if(incy.lt.0)iy = (-n+1)*incy + 1 23 do 10 i = 1,n 24 stemp = stemp + sx(ix)*sy(iy) 25 ix = ix + incx 26 iy = iy + incy 27 10 continue 28 sdot = stemp 29 return 30c 31c code for both increments equal to 1 32c 33c 34c clean-up loop 35c 36 20 m = mod(n,5) 37 if( m .eq. 0 ) go to 40 38 do 30 i = 1,m 39 stemp = stemp + sx(i)*sy(i) 40 30 continue 41 if( n .lt. 5 ) go to 60 42 40 mp1 = m + 1 43 do 50 i = mp1,n,5 44 stemp = stemp + sx(i)*sy(i) + sx(i + 1)*sy(i + 1) + 45 * sx(i + 2)*sy(i + 2) + sx(i + 3)*sy(i + 3) + sx(i + 4)*sy(i + 4) 46 50 continue 47 60 sdot = stemp 48 return 49 end 50