BLAS / dasum.f

Fortran project BLAS, source module dasum.f.

Source module last modified on Thu, 2 Jul 1998, 23:17;
HTML image of Fortran source automatically generated by for2html on Sun, 23 Jun 2002, 15:10.


      double precision function dasum(n,dx,incx)
#
#     takes the sum of the absolute values.
#     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(*)
#
      double precision dx(*),dtemp
      integer i,incx,m,mp1,n,nincx
#
      dasum = 0.0d0
      dtemp = 0.0d0
      if( n<=0 || incx<=0 )return
      if(incx==1)go to 20
#
#        code for increment not equal to 1
#
      nincx = n*incx
      do 10 i = 1,nincx,incx
        dtemp = dtemp + dabs(dx(i))
   10 continue
      dasum = dtemp
      return
#
#        code for increment equal to 1
#
#
#        clean-up loop
#
   20 m = mod(n,6)
      if( m == 0 ) go to 40
      do 30 i = 1,m
        dtemp = dtemp + dabs(dx(i))
   30 continue
      if( n < 6 ) go to 60
   40 mp1 = m + 1
      do 50 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))
   50 continue
   60 dasum = dtemp
      return
      end