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_SWAP_HEADER 00038 #define TEMPLATE_BLAS_SWAP_HEADER 00039 00040 00041 template<class Treal> 00042 int template_blas_swap(const integer *n, Treal *dx, const integer *incx, 00043 Treal *dy, const integer *incy) 00044 { 00045 /* System generated locals */ 00046 integer i__1; 00047 /* Local variables */ 00048 integer i__, m; 00049 Treal dtemp; 00050 integer ix, iy, mp1; 00051 /* interchanges two vectors. 00052 uses unrolled loops for increments equal one. 00053 jack dongarra, linpack, 3/11/78. 00054 modified 12/3/93, array(1) declarations changed to array(*) 00055 Parameter adjustments */ 00056 --dy; 00057 --dx; 00058 /* Function Body */ 00059 if (*n <= 0) { 00060 return 0; 00061 } 00062 if (*incx == 1 && *incy == 1) { 00063 goto L20; 00064 } 00065 /* code for unequal increments or equal increments not equal 00066 to 1 */ 00067 ix = 1; 00068 iy = 1; 00069 if (*incx < 0) { 00070 ix = (-(*n) + 1) * *incx + 1; 00071 } 00072 if (*incy < 0) { 00073 iy = (-(*n) + 1) * *incy + 1; 00074 } 00075 i__1 = *n; 00076 for (i__ = 1; i__ <= i__1; ++i__) { 00077 dtemp = dx[ix]; 00078 dx[ix] = dy[iy]; 00079 dy[iy] = dtemp; 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 % 3; 00089 if (m == 0) { 00090 goto L40; 00091 } 00092 i__1 = m; 00093 for (i__ = 1; i__ <= i__1; ++i__) { 00094 dtemp = dx[i__]; 00095 dx[i__] = dy[i__]; 00096 dy[i__] = dtemp; 00097 /* L30: */ 00098 } 00099 if (*n < 3) { 00100 return 0; 00101 } 00102 L40: 00103 mp1 = m + 1; 00104 i__1 = *n; 00105 for (i__ = mp1; i__ <= i__1; i__ += 3) { 00106 dtemp = dx[i__]; 00107 dx[i__] = dy[i__]; 00108 dy[i__] = dtemp; 00109 dtemp = dx[i__ + 1]; 00110 dx[i__ + 1] = dy[i__ + 1]; 00111 dy[i__ + 1] = dtemp; 00112 dtemp = dx[i__ + 2]; 00113 dx[i__ + 2] = dy[i__ + 2]; 00114 dy[i__ + 2] = dtemp; 00115 /* L50: */ 00116 } 00117 return 0; 00118 } /* dswap_ */ 00119 00120 #endif