template_lapack_labad.h

Go to the documentation of this file.
00001 /* Ergo, version 3.2, a program for linear scaling electronic structure
00002  * calculations.
00003  * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  * 
00018  * Primary academic reference:
00019  * Kohn−Sham Density Functional Theory Electronic Structure Calculations 
00020  * with Linearly Scaling Computational Time and Memory Usage,
00021  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
00022  * J. Chem. Theory Comput. 7, 340 (2011),
00023  * <http://dx.doi.org/10.1021/ct100611z>
00024  * 
00025  * For further information about Ergo, see <http://www.ergoscf.org>.
00026  */
00027  
00028  /* This file belongs to the template_lapack part of the Ergo source 
00029   * code. The source files in the template_lapack directory are modified
00030   * versions of files originally distributed as CLAPACK, see the
00031   * Copyright/license notice in the file template_lapack/COPYING.
00032   */
00033  
00034 
00035 #ifndef TEMPLATE_LAPACK_LABAD_HEADER
00036 #define TEMPLATE_LAPACK_LABAD_HEADER
00037 
00038 
00039 template<class Treal>
00040 int template_lapack_labad(Treal *small, Treal *large)
00041 {
00042 /*  -- LAPACK auxiliary routine (version 3.0) --   
00043        Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
00044        Courant Institute, Argonne National Lab, and Rice University   
00045        October 31, 1992   
00046 
00047 
00048     Purpose   
00049     =======   
00050 
00051     DLABAD takes as input the values computed by DLAMCH for underflow and   
00052     overflow, and returns the square root of each of these values if the   
00053     log of LARGE is sufficiently large.  This subroutine is intended to   
00054     identify machines with a large exponent range, such as the Crays, and   
00055     redefine the underflow and overflow limits to be the square roots of   
00056     the values computed by DLAMCH.  This subroutine is needed because   
00057     DLAMCH does not compensate for poor arithmetic in the upper half of   
00058     the exponent range, as is found on a Cray.   
00059 
00060     Arguments   
00061     =========   
00062 
00063     SMALL   (input/output) DOUBLE PRECISION   
00064             On entry, the underflow threshold as computed by DLAMCH.   
00065             On exit, if LOG10(LARGE) is sufficiently large, the square   
00066             root of SMALL, otherwise unchanged.   
00067 
00068     LARGE   (input/output) DOUBLE PRECISION   
00069             On entry, the overflow threshold as computed by DLAMCH.   
00070             On exit, if LOG10(LARGE) is sufficiently large, the square   
00071             root of LARGE, otherwise unchanged.   
00072 
00073     =====================================================================   
00074 
00075 
00076        If it looks like we're on a Cray, take the square root of   
00077        SMALL and LARGE to avoid overflow and underflow problems. */
00078 
00079 
00080   if (template_blas_lg10(large) > 2e3) {
00081     *small = template_blas_sqrt(*small);
00082     *large = template_blas_sqrt(*large);
00083   }
00084   
00085   return 0;
00086 
00087   /*     End of DLABAD */
00088   
00089 } /* dlabad_ */
00090 
00091 #endif

Generated on Wed Nov 21 09:32:11 2012 for ergo by  doxygen 1.4.7