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_LAPACK_LABAD_HEADER 00038 #define TEMPLATE_LAPACK_LABAD_HEADER 00039 00040 00041 template<class Treal> 00042 int template_lapack_labad(Treal *small, Treal *large) 00043 { 00044 /* -- LAPACK auxiliary routine (version 3.0) -- 00045 Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 00046 Courant Institute, Argonne National Lab, and Rice University 00047 October 31, 1992 00048 00049 00050 Purpose 00051 ======= 00052 00053 DLABAD takes as input the values computed by DLAMCH for underflow and 00054 overflow, and returns the square root of each of these values if the 00055 log of LARGE is sufficiently large. This subroutine is intended to 00056 identify machines with a large exponent range, such as the Crays, and 00057 redefine the underflow and overflow limits to be the square roots of 00058 the values computed by DLAMCH. This subroutine is needed because 00059 DLAMCH does not compensate for poor arithmetic in the upper half of 00060 the exponent range, as is found on a Cray. 00061 00062 Arguments 00063 ========= 00064 00065 SMALL (input/output) DOUBLE PRECISION 00066 On entry, the underflow threshold as computed by DLAMCH. 00067 On exit, if LOG10(LARGE) is sufficiently large, the square 00068 root of SMALL, otherwise unchanged. 00069 00070 LARGE (input/output) DOUBLE PRECISION 00071 On entry, the overflow threshold as computed by DLAMCH. 00072 On exit, if LOG10(LARGE) is sufficiently large, the square 00073 root of LARGE, otherwise unchanged. 00074 00075 ===================================================================== 00076 00077 00078 If it looks like we're on a Cray, take the square root of 00079 SMALL and LARGE to avoid overflow and underflow problems. */ 00080 00081 00082 if (template_blas_lg10(large) > 2e3) { 00083 *small = template_blas_sqrt(*small); 00084 *large = template_blas_sqrt(*large); 00085 } 00086 00087 return 0; 00088 00089 /* End of DLABAD */ 00090 00091 } /* dlabad_ */ 00092 00093 #endif