template_lapack_lapy2.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_LAPY2_HEADER
00036 #define TEMPLATE_LAPACK_LAPY2_HEADER
00037 
00038 
00039 template<class Treal>
00040 Treal template_lapack_lapy2(Treal *x, Treal *y)
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     DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary   
00052     overflow.   
00053 
00054     Arguments   
00055     =========   
00056 
00057     X       (input) DOUBLE PRECISION   
00058     Y       (input) DOUBLE PRECISION   
00059             X and Y specify the values x and y.   
00060 
00061     ===================================================================== */
00062     /* System generated locals */
00063     Treal ret_val, d__1;
00064     /* Local variables */
00065      Treal xabs, yabs, w, z__;
00066 
00067 
00068 
00069     xabs = absMACRO(*x);
00070     yabs = absMACRO(*y);
00071     w = maxMACRO(xabs,yabs);
00072     z__ = minMACRO(xabs,yabs);
00073     if (z__ == 0.) {
00074         ret_val = w;
00075     } else {
00076 /* Computing 2nd power */
00077         d__1 = z__ / w;
00078         ret_val = w * template_blas_sqrt(d__1 * d__1 + 1.);
00079     }
00080     return ret_val;
00081 
00082 /*     End of DLAPY2 */
00083 
00084 } /* dlapy2_ */
00085 
00086 #endif

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