LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
sasum.f
Go to the documentation of this file.
1 *> \brief \b SASUM
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * REAL FUNCTION SASUM(N,SX,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,N
15 * ..
16 * .. Array Arguments ..
17 * REAL SX(*)
18 * ..
19 *
20 *
21 *> \par Purpose:
22 * =============
23 *>
24 *> \verbatim
25 *>
26 *> SASUM takes the sum of the absolute values.
27 *> uses unrolled loops for increment equal to one.
28 *> \endverbatim
29 *
30 * Arguments:
31 * ==========
32 *
33 *> \param[in] N
34 *> \verbatim
35 *> N is INTEGER
36 *> number of elements in input vector(s)
37 *> \endverbatim
38 *>
39 *> \param[in] SX
40 *> \verbatim
41 *> SX is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
42 *> \endverbatim
43 *>
44 *> \param[in] INCX
45 *> \verbatim
46 *> INCX is INTEGER
47 *> storage spacing between elements of SX
48 *> \endverbatim
49 *
50 * Authors:
51 * ========
52 *
53 *> \author Univ. of Tennessee
54 *> \author Univ. of California Berkeley
55 *> \author Univ. of Colorado Denver
56 *> \author NAG Ltd.
57 *
58 *> \ingroup single_blas_level1
59 *
60 *> \par Further Details:
61 * =====================
62 *>
63 *> \verbatim
64 *>
65 *> jack dongarra, linpack, 3/11/78.
66 *> modified 3/93 to return if incx .le. 0.
67 *> modified 12/3/93, array(1) declarations changed to array(*)
68 *> \endverbatim
69 *>
70 * =====================================================================
71  REAL function sasum(n,sx,incx)
72 *
73 * -- Reference BLAS level1 routine --
74 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
75 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
76 *
77 * .. Scalar Arguments ..
78  INTEGER incx,n
79 * ..
80 * .. Array Arguments ..
81  REAL sx(*)
82 * ..
83 *
84 * =====================================================================
85 *
86 * .. Local Scalars ..
87  REAL stemp
88  INTEGER i,m,mp1,nincx
89 * ..
90 * .. Intrinsic Functions ..
91  INTRINSIC abs,mod
92 * ..
93  sasum = 0.0e0
94  stemp = 0.0e0
95  IF (n.LE.0 .OR. incx.LE.0) RETURN
96  IF (incx.EQ.1) THEN
97 * code for increment equal to 1
98 *
99 *
100 * clean-up loop
101 *
102  m = mod(n,6)
103  IF (m.NE.0) THEN
104  DO i = 1,m
105  stemp = stemp + abs(sx(i))
106  END DO
107  IF (n.LT.6) THEN
108  sasum = stemp
109  RETURN
110  END IF
111  END IF
112  mp1 = m + 1
113  DO i = mp1,n,6
114  stemp = stemp + abs(sx(i)) + abs(sx(i+1)) +
115  $ abs(sx(i+2)) + abs(sx(i+3)) +
116  $ abs(sx(i+4)) + abs(sx(i+5))
117  END DO
118  ELSE
119 *
120 * code for increment not equal to 1
121 *
122  nincx = n*incx
123  DO i = 1,nincx,incx
124  stemp = stemp + abs(sx(i))
125  END DO
126  END IF
127  sasum = stemp
128  RETURN
129 *
130 * End of SASUM
131 *
132  END
real function sasum(N, SX, INCX)
SASUM
Definition: sasum.f:72