SASUM takes the sum of the absolute values. uses unrolled loops for increment equal to one.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ilp), | intent(in) | :: | n | |||
real(kind=sp), | intent(in) | :: | sx(*) | |||
integer(kind=ilp), | intent(in) | :: | incx |
pure real(sp) function stdlib_sasum(n,sx,incx) !! SASUM takes the sum of the absolute values. !! uses unrolled loops for increment equal to one. ! -- reference blas level1 routine -- ! -- reference blas is a software package provided by univ. of tennessee, -- ! -- univ. of california berkeley, univ. of colorado denver and nag ltd..-- ! Scalar Arguments integer(ilp), intent(in) :: incx, n ! Array Arguments real(sp), intent(in) :: sx(*) ! ===================================================================== ! Local Scalars real(sp) :: stemp integer(ilp) :: i, m, mp1, nincx ! Intrinsic Functions intrinsic :: abs,mod stdlib_sasum = zero stemp = zero if (n<=0 .or. incx<=0) return if (incx==1) then ! code for increment equal to 1 ! clean-up loop m = mod(n,6) if (m/=0) then do i = 1,m stemp = stemp + abs(sx(i)) end do if (n<6) then stdlib_sasum = stemp return end if end if mp1 = m + 1 do 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)) end do else ! code for increment not equal to 1 nincx = n*incx do i = 1,nincx,incx stemp = stemp + abs(sx(i)) end do end if stdlib_sasum = stemp return end function stdlib_sasum