LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
 All Classes Files Functions Variables Typedefs Macros
dasum.f
Go to the documentation of this file.
1 *> \brief \b DASUM
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * DOUBLE PRECISION FUNCTION DASUM(N,DX,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,N
15 * ..
16 * .. Array Arguments ..
17 * DOUBLE PRECISION DX(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> DASUM takes the sum of the absolute values.
27 *> \endverbatim
28 *
29 * Authors:
30 * ========
31 *
32 *> \author Univ. of Tennessee
33 *> \author Univ. of California Berkeley
34 *> \author Univ. of Colorado Denver
35 *> \author NAG Ltd.
36 *
37 *> \date November 2011
38 *
39 *> \ingroup double_blas_level1
40 *
41 *> \par Further Details:
42 * =====================
43 *>
44 *> \verbatim
45 *>
46 *> jack dongarra, linpack, 3/11/78.
47 *> modified 3/93 to return if incx .le. 0.
48 *> modified 12/3/93, array(1) declarations changed to array(*)
49 *> \endverbatim
50 *>
51 * =====================================================================
52  DOUBLE PRECISION FUNCTION dasum(N,DX,INCX)
53 *
54 * -- Reference BLAS level1 routine (version 3.4.0) --
55 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
56 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
57 * November 2011
58 *
59 * .. Scalar Arguments ..
60  INTEGER incx,n
61 * ..
62 * .. Array Arguments ..
63  DOUBLE PRECISION dx(*)
64 * ..
65 *
66 * =====================================================================
67 *
68 * .. Local Scalars ..
69  DOUBLE PRECISION dtemp
70  INTEGER i,m,mp1,nincx
71 * ..
72 * .. Intrinsic Functions ..
73  INTRINSIC dabs,mod
74 * ..
75  dasum = 0.0d0
76  dtemp = 0.0d0
77  IF (n.LE.0 .OR. incx.LE.0) RETURN
78  IF (incx.EQ.1) THEN
79 * code for increment equal to 1
80 *
81 *
82 * clean-up loop
83 *
84  m = mod(n,6)
85  IF (m.NE.0) THEN
86  DO i = 1,m
87  dtemp = dtemp + dabs(dx(i))
88  END DO
89  IF (n.LT.6) THEN
90  dasum = dtemp
91  RETURN
92  END IF
93  END IF
94  mp1 = m + 1
95  DO i = mp1,n,6
96  dtemp = dtemp + dabs(dx(i)) + dabs(dx(i+1)) +
97  $ dabs(dx(i+2)) + dabs(dx(i+3)) +
98  $ dabs(dx(i+4)) + dabs(dx(i+5))
99  END DO
100  ELSE
101 *
102 * code for increment not equal to 1
103 *
104  nincx = n*incx
105  DO i = 1,nincx,incx
106  dtemp = dtemp + dabs(dx(i))
107  END DO
108  END IF
109  dasum = dtemp
110  RETURN
111  END