ergo
template_lapack_lapy2.h
Go to the documentation of this file.
1/* Ergo, version 3.8, a program for linear scaling electronic structure
2 * calculations.
3 * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4 * and Anastasia Kruchinina.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Primary academic reference:
20 * Ergo: An open-source program for linear-scaling electronic structure
21 * calculations,
22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23 * Kruchinina,
24 * SoftwareX 7, 107 (2018),
25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26 *
27 * For further information about Ergo, see <http://www.ergoscf.org>.
28 */
29
30 /* This file belongs to the template_lapack part of the Ergo source
31 * code. The source files in the template_lapack directory are modified
32 * versions of files originally distributed as CLAPACK, see the
33 * Copyright/license notice in the file template_lapack/COPYING.
34 */
35
36
37#ifndef TEMPLATE_LAPACK_LAPY2_HEADER
38#define TEMPLATE_LAPACK_LAPY2_HEADER
39
40
41template<class Treal>
42Treal template_lapack_lapy2(Treal *x, Treal *y)
43{
44/* -- LAPACK auxiliary routine (version 3.0) --
45 Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
46 Courant Institute, Argonne National Lab, and Rice University
47 October 31, 1992
48
49
50 Purpose
51 =======
52
53 DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
54 overflow.
55
56 Arguments
57 =========
58
59 X (input) DOUBLE PRECISION
60 Y (input) DOUBLE PRECISION
61 X and Y specify the values x and y.
62
63 ===================================================================== */
64 /* System generated locals */
65 Treal ret_val, d__1;
66 /* Local variables */
67 Treal xabs, yabs, w, z__;
68
69
70
71 xabs = absMACRO(*x);
72 yabs = absMACRO(*y);
73 w = maxMACRO(xabs,yabs);
74 z__ = minMACRO(xabs,yabs);
75 if (z__ == 0.) {
76 ret_val = w;
77 } else {
78/* Computing 2nd power */
79 d__1 = z__ / w;
80 ret_val = w * template_blas_sqrt(d__1 * d__1 + 1.);
81 }
82 return ret_val;
83
84/* End of DLAPY2 */
85
86} /* dlapy2_ */
87
88#endif
Treal template_blas_sqrt(Treal x)
#define absMACRO(x)
Definition: template_blas_common.h:47
#define minMACRO(a, b)
Definition: template_blas_common.h:46
#define maxMACRO(a, b)
Definition: template_blas_common.h:45
Treal template_lapack_lapy2(Treal *x, Treal *y)
Definition: template_lapack_lapy2.h:42