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