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_AXPY_HEADER 00038 #define TEMPLATE_BLAS_AXPY_HEADER 00039 00040 #include "template_blas_common.h" 00041 00042 template<class Treal> 00043 int template_blas_axpy(const integer *n, const Treal *da, const Treal *dx, 00044 const integer *incx, Treal *dy, const integer *incy) 00045 { 00046 /* System generated locals */ 00047 integer i__1; 00048 /* Local variables */ 00049 integer i__, m, ix, iy, mp1; 00050 /* constant times a vector plus a vector. 00051 uses unrolled loops for increments equal to one. 00052 jack dongarra, linpack, 3/11/78. 00053 modified 12/3/93, array(1) declarations changed to array(*) 00054 Parameter adjustments */ 00055 --dy; 00056 --dx; 00057 /* Function Body */ 00058 if (*n <= 0) { 00059 return 0; 00060 } 00061 if (*da == 0.) { 00062 return 0; 00063 } 00064 if (*incx == 1 && *incy == 1) { 00065 goto L20; 00066 } 00067 /* code for unequal increments or equal increments 00068 not equal to 1 */ 00069 ix = 1; 00070 iy = 1; 00071 if (*incx < 0) { 00072 ix = (-(*n) + 1) * *incx + 1; 00073 } 00074 if (*incy < 0) { 00075 iy = (-(*n) + 1) * *incy + 1; 00076 } 00077 i__1 = *n; 00078 for (i__ = 1; i__ <= i__1; ++i__) { 00079 dy[iy] += *da * dx[ix]; 00080 ix += *incx; 00081 iy += *incy; 00082 /* L10: */ 00083 } 00084 return 0; 00085 /* code for both increments equal to 1 00086 clean-up loop */ 00087 L20: 00088 m = *n % 4; 00089 if (m == 0) { 00090 goto L40; 00091 } 00092 i__1 = m; 00093 for (i__ = 1; i__ <= i__1; ++i__) { 00094 dy[i__] += *da * dx[i__]; 00095 /* L30: */ 00096 } 00097 if (*n < 4) { 00098 return 0; 00099 } 00100 L40: 00101 mp1 = m + 1; 00102 i__1 = *n; 00103 for (i__ = mp1; i__ <= i__1; i__ += 4) { 00104 dy[i__] += *da * dx[i__]; 00105 dy[i__ + 1] += *da * dx[i__ + 1]; 00106 dy[i__ + 2] += *da * dx[i__ + 2]; 00107 dy[i__ + 3] += *da * dx[i__ + 3]; 00108 /* L50: */ 00109 } 00110 return 0; 00111 } /* daxpy_ */ 00112 00113 #endif