ergo
template_blas_asum.h
Go to the documentation of this file.
1 /* Ergo, version 3.7, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
30  /* This file belongs to the template_lapack part of the Ergo source
31  * code. The source files in the template_lapack directory are modified
32  * versions of files originally distributed as CLAPACK, see the
33  * Copyright/license notice in the file template_lapack/COPYING.
34  */
35 
36 
37 #ifndef TEMPLATE_BLAS_ASUM_HEADER
38 #define TEMPLATE_BLAS_ASUM_HEADER
39 
40 
41 template<class Treal>
42 Treal template_blas_asum(const integer *n, const Treal *dx, const integer *incx)
43 {
44  /* System generated locals */
45  integer i__1, i__2;
46  Treal ret_val, d__1, d__2, d__3, d__4, d__5, d__6;
47  /* Local variables */
48  integer i__, m;
49  Treal dtemp;
50  integer nincx, mp1;
51 /* takes the sum of the absolute values.
52  jack dongarra, linpack, 3/11/78.
53  modified 3/93 to return if incx .le. 0.
54  modified 12/3/93, array(1) declarations changed to array(*)
55  Parameter adjustments */
56  --dx;
57  /* Function Body */
58  ret_val = 0.;
59  dtemp = 0.;
60  if (*n <= 0 || *incx <= 0) {
61  return ret_val;
62  }
63  if (*incx == 1) {
64  goto L20;
65  }
66 /* code for increment not equal to 1 */
67  nincx = *n * *incx;
68  i__1 = nincx;
69  i__2 = *incx;
70  for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
71  dtemp += (d__1 = dx[i__], absMACRO(d__1));
72 /* L10: */
73  }
74  ret_val = dtemp;
75  return ret_val;
76 /* code for increment equal to 1
77  clean-up loop */
78 L20:
79  m = *n % 6;
80  if (m == 0) {
81  goto L40;
82  }
83  i__2 = m;
84  for (i__ = 1; i__ <= i__2; ++i__) {
85  dtemp += (d__1 = dx[i__], absMACRO(d__1));
86 /* L30: */
87  }
88  if (*n < 6) {
89  goto L60;
90  }
91 L40:
92  mp1 = m + 1;
93  i__2 = *n;
94  for (i__ = mp1; i__ <= i__2; i__ += 6) {
95  dtemp = dtemp + (d__1 = dx[i__], absMACRO(d__1)) + (d__2 = dx[i__ + 1],
96  absMACRO(d__2)) + (d__3 = dx[i__ + 2], absMACRO(d__3)) + (d__4 = dx[i__
97  + 3], absMACRO(d__4)) + (d__5 = dx[i__ + 4], absMACRO(d__5)) + (d__6 =
98  dx[i__ + 5], absMACRO(d__6));
99 /* L50: */
100  }
101 L60:
102  ret_val = dtemp;
103  return ret_val;
104 } /* dasum_ */
105 
106 #endif
#define absMACRO(x)
Definition: template_blas_common.h:47
int integer
Definition: template_blas_common.h:40
Treal template_blas_asum(const integer *n, const Treal *dx, const integer *incx)
Definition: template_blas_asum.h:42