ergo
template_lapack_lapy3.h
Go to the documentation of this file.
1/* Ergo, version 3.8.2, a program for linear scaling electronic structure
2 * calculations.
3 * Copyright (C) 2023 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_LAPY3_HEADER
38#define TEMPLATE_LAPACK_LAPY3_HEADER
39
40
41template<class Treal>
42Treal template_lapack_lapy3(Treal *x, Treal *y, Treal *z__)
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 DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause
54 unnecessary overflow.
55
56 Arguments
57 =========
58
59 X (input) DOUBLE PRECISION
60 Y (input) DOUBLE PRECISION
61 Z (input) DOUBLE PRECISION
62 X, Y and Z specify the values x, y and z.
63
64 ===================================================================== */
65 /* System generated locals */
66 Treal ret_val, d__1, d__2, d__3;
67 /* Local variables */
68 Treal xabs, yabs, zabs, w;
69
70
71
72 xabs = absMACRO(*x);
73 yabs = absMACRO(*y);
74 zabs = absMACRO(*z__);
75/* Computing MAX */
76 d__1 = maxMACRO(xabs,yabs);
77 w = maxMACRO(d__1,zabs);
78 if (w == 0.) {
79 ret_val = 0.;
80 } else {
81/* Computing 2nd power */
82 d__1 = xabs / w;
83/* Computing 2nd power */
84 d__2 = yabs / w;
85/* Computing 2nd power */
86 d__3 = zabs / w;
87 ret_val = w * template_blas_sqrt(d__1 * d__1 + d__2 * d__2 + d__3 * d__3);
88 }
89 return ret_val;
90
91/* End of DLAPY3 */
92
93} /* dlapy3_ */
94
95#endif
Treal template_blas_sqrt(Treal x)
#define absMACRO(x)
Definition: template_blas_common.h:47
#define maxMACRO(a, b)
Definition: template_blas_common.h:45
Treal template_lapack_lapy3(Treal *x, Treal *y, Treal *z__)
Definition: template_lapack_lapy3.h:42