sasum(3f) - [BLAS:SINGLE_BLAS_LEVEL1] SASUM:=sum of absolute values of SX.
real function sasum(n,sx,incx)
.. Scalar Arguments ..
integer,intent(in) :: incx,n
..
.. Array Arguments ..
real,intent(in) :: sx(*)
..
SASUM takes the sum of the absolute values.
uses unrolled loops for increment equal to one.
N
N is INTEGER
number of elements in input vector(s)
SX
SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
INCX
INCX is INTEGER
storage spacing between elements of SX
date:November 2017
FURTHER DETAILS
jack dongarra, linpack, 3/11/78.
modified 3/93 to return if incx .le. 0.
modified 12/3/93, array(1) declarations changed to array(*)
Online html documentation available at
http://www.netlib.org/lapack/explore-html/
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real, | intent(in) | :: | sx(*) | |||
integer, | intent(in) | :: | incx |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | i | ||||
integer, | public | :: | m | ||||
integer, | public | :: | mp1 | ||||
integer, | public | :: | nincx | ||||
real, | public | :: | stemp |
pure real function sasum(n,sx,incx)
implicit none
!
! -- Reference BLAS level1 routine (version 3.8.0) --
! -- Reference BLAS is a software package provided by Univ. of Tennessee, --
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! November 2017
!
! .. Scalar Arguments ..
integer,intent(in) :: incx,n
! ..
! .. Array Arguments ..
real,intent(in) :: sx(*)
! ..
!
! =====================================================================
!
! .. Local Scalars ..
real stemp
integer i,m,mp1,nincx
! ..
! .. Intrinsic Functions ..
intrinsic abs,mod
! ..
sasum = 0.0e0
stemp = 0.0e0
if (n.le.0 .or. incx.le.0) return
if (incx.eq.1) then
! code for increment equal to 1
!
!
! clean-up loop
!
m = mod(n,6)
if (m.ne.0) then
do i = 1,m
stemp = stemp + abs(sx(i))
enddo
if (n.lt.6) then
sasum = stemp
return
endif
endif
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))
enddo
else
!
! code for increment not equal to 1
!
nincx = n*incx
do i = 1,nincx,incx
stemp = stemp + abs(sx(i))
enddo
endif
sasum = stemp
end function sasum