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