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_IDAMAX_HEADER 00038 #define TEMPLATE_BLAS_IDAMAX_HEADER 00039 00040 00041 template<class Treal> 00042 integer template_blas_idamax(const integer *n, const Treal *dx, const integer *incx) 00043 { 00044 /* System generated locals */ 00045 integer ret_val, i__1; 00046 Treal d__1; 00047 /* Local variables */ 00048 Treal dmax__; 00049 integer i__, ix; 00050 /* finds the index of element having max. absolute value. 00051 jack dongarra, linpack, 3/11/78. 00052 modified 3/93 to return if incx .le. 0. 00053 modified 12/3/93, array(1) declarations changed to array(*) 00054 Parameter adjustments */ 00055 --dx; 00056 /* Function Body */ 00057 ret_val = 0; 00058 if (*n < 1 || *incx <= 0) { 00059 return ret_val; 00060 } 00061 ret_val = 1; 00062 if (*n == 1) { 00063 return ret_val; 00064 } 00065 if (*incx == 1) { 00066 goto L20; 00067 } 00068 /* code for increment not equal to 1 */ 00069 ix = 1; 00070 dmax__ = absMACRO(dx[1]); 00071 ix += *incx; 00072 i__1 = *n; 00073 for (i__ = 2; i__ <= i__1; ++i__) { 00074 if ((d__1 = dx[ix], absMACRO(d__1)) <= dmax__) { 00075 goto L5; 00076 } 00077 ret_val = i__; 00078 dmax__ = (d__1 = dx[ix], absMACRO(d__1)); 00079 L5: 00080 ix += *incx; 00081 /* L10: */ 00082 } 00083 return ret_val; 00084 /* code for increment equal to 1 */ 00085 L20: 00086 dmax__ = absMACRO(dx[1]); 00087 i__1 = *n; 00088 for (i__ = 2; i__ <= i__1; ++i__) { 00089 if ((d__1 = dx[i__], absMACRO(d__1)) <= dmax__) { 00090 goto L30; 00091 } 00092 ret_val = i__; 00093 dmax__ = (d__1 = dx[i__], absMACRO(d__1)); 00094 L30: 00095 ; 00096 } 00097 return ret_val; 00098 } /* idamax_ */ 00099 00100 #endif