dasum Function

public pure function dasum(n, dx, incx)

NAME

dasum(3f) - [BLAS:DOUBLE_BLAS_LEVEL1] takes the sum of the absolute values.

SYNOPSIS

 double precision function dasum(n,dx,incx)

   .. Scalar Arguments ..
   integer,intent(in) :: incx,n
   ..
   .. Array Arguments ..
   double precision,intent(in) :: dx(*)
   ..

DEFINITION

 DASUM takes the sum of the absolute values.

OPTIONS

N

       N is INTEGER
      number of elements in input vector(s)

DX

       DX is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )

INCX

       INCX is INTEGER
      storage spacing between elements of DX

AUTHORS

  • Univ. of Tennessee
  • Univ. of California Berkeley
  • Univ. of Colorado Denver
  • NAG Ltd.

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(*)

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
double precision, intent(in) :: dx(*)
integer, intent(in) :: incx

Return Value doubleprecision


Contents

Source Code


Variables

Type Visibility Attributes Name Initial
double precision, public :: dtemp
integer, public :: i
integer, public :: m
integer, public :: mp1
integer, public :: nincx

Source Code

pure double precision function dasum(n,dx,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 ..
      double precision,intent(in) :: dx(*)
!     ..
!
!  =====================================================================
!
!     .. Local Scalars ..
      double precision dtemp
      integer i,m,mp1,nincx
!     ..
!     .. Intrinsic Functions ..
      intrinsic dabs,mod
!     ..
      dasum = 0.0d0
      dtemp = 0.0d0
      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
               dtemp = dtemp + dabs(dx(i))
            enddo
            if (n.lt.6) then
               dasum = dtemp
               return
            endif
         endif
         mp1 = m + 1
         do i = mp1,n,6
            dtemp = dtemp + dabs(dx(i)) + dabs(dx(i+1)) + dabs(dx(i+2)) + dabs(dx(i+3)) + dabs(dx(i+4)) + dabs(dx(i+5))
         enddo
      else
!
!        code for increment not equal to 1
!
         nincx = n*incx
         do i = 1,nincx,incx
            dtemp = dtemp + dabs(dx(i))
         enddo
      endif
      dasum = dtemp

      end function dasum