00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00030 /* This file belongs to the template_lapack part of the Ergo source 00031 * code. The source files in the template_lapack directory are modified 00032 * versions of files originally distributed as CLAPACK, see the 00033 * Copyright/license notice in the file template_lapack/COPYING. 00034 */ 00035 00036 00037 #ifndef TEMPLATE_BLAS_ASUM_HEADER 00038 #define TEMPLATE_BLAS_ASUM_HEADER 00039 00040 00041 template<class Treal> 00042 Treal template_blas_asum(const integer *n, const Treal *dx, const integer *incx) 00043 { 00044 /* System generated locals */ 00045 integer i__1, i__2; 00046 Treal ret_val, d__1, d__2, d__3, d__4, d__5, d__6; 00047 /* Local variables */ 00048 integer i__, m; 00049 Treal dtemp; 00050 integer nincx, mp1; 00051 /* takes the sum of the absolute values. 00052 jack dongarra, linpack, 3/11/78. 00053 modified 3/93 to return if incx .le. 0. 00054 modified 12/3/93, array(1) declarations changed to array(*) 00055 Parameter adjustments */ 00056 --dx; 00057 /* Function Body */ 00058 ret_val = 0.; 00059 dtemp = 0.; 00060 if (*n <= 0 || *incx <= 0) { 00061 return ret_val; 00062 } 00063 if (*incx == 1) { 00064 goto L20; 00065 } 00066 /* code for increment not equal to 1 */ 00067 nincx = *n * *incx; 00068 i__1 = nincx; 00069 i__2 = *incx; 00070 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { 00071 dtemp += (d__1 = dx[i__], absMACRO(d__1)); 00072 /* L10: */ 00073 } 00074 ret_val = dtemp; 00075 return ret_val; 00076 /* code for increment equal to 1 00077 clean-up loop */ 00078 L20: 00079 m = *n % 6; 00080 if (m == 0) { 00081 goto L40; 00082 } 00083 i__2 = m; 00084 for (i__ = 1; i__ <= i__2; ++i__) { 00085 dtemp += (d__1 = dx[i__], absMACRO(d__1)); 00086 /* L30: */ 00087 } 00088 if (*n < 6) { 00089 goto L60; 00090 } 00091 L40: 00092 mp1 = m + 1; 00093 i__2 = *n; 00094 for (i__ = mp1; i__ <= i__2; i__ += 6) { 00095 dtemp = dtemp + (d__1 = dx[i__], absMACRO(d__1)) + (d__2 = dx[i__ + 1], 00096 absMACRO(d__2)) + (d__3 = dx[i__ + 2], absMACRO(d__3)) + (d__4 = dx[i__ 00097 + 3], absMACRO(d__4)) + (d__5 = dx[i__ + 4], absMACRO(d__5)) + (d__6 = 00098 dx[i__ + 5], absMACRO(d__6)); 00099 /* L50: */ 00100 } 00101 L60: 00102 ret_val = dtemp; 00103 return ret_val; 00104 } /* dasum_ */ 00105 00106 #endif