LAPACK  3.8.0 LAPACK: Linear Algebra PACKage
dlapy2.f
Go to the documentation of this file.
1 *> \brief \b DLAPY2 returns sqrt(x2+y2).
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlapy2.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlapy2.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlapy2.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * DOUBLE PRECISION FUNCTION DLAPY2( X, Y )
22 *
23 * .. Scalar Arguments ..
24 * DOUBLE PRECISION X, Y
25 * ..
26 *
27 *
28 *> \par Purpose:
29 * =============
30 *>
31 *> \verbatim
32 *>
33 *> DLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
34 *> overflow.
35 *> \endverbatim
36 *
37 * Arguments:
38 * ==========
39 *
40 *> \param[in] X
41 *> \verbatim
42 *> X is DOUBLE PRECISION
43 *> \endverbatim
44 *>
45 *> \param[in] Y
46 *> \verbatim
47 *> Y is DOUBLE PRECISION
48 *> X and Y specify the values x and y.
49 *> \endverbatim
50 *
51 * Authors:
52 * ========
53 *
54 *> \author Univ. of Tennessee
55 *> \author Univ. of California Berkeley
56 *> \author Univ. of Colorado Denver
57 *> \author NAG Ltd.
58 *
59 *> \date June 2017
60 *
61 *> \ingroup OTHERauxiliary
62 *
63 * =====================================================================
64  DOUBLE PRECISION FUNCTION dlapy2( X, Y )
65 *
66 * -- LAPACK auxiliary routine (version 3.7.1) --
67 * -- LAPACK is a software package provided by Univ. of Tennessee, --
68 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
69 * June 2017
70 *
71 * .. Scalar Arguments ..
72  DOUBLE PRECISION X, Y
73 * ..
74 *
75 * =====================================================================
76 *
77 * .. Parameters ..
78  DOUBLE PRECISION ZERO
79  parameter( zero = 0.0d0 )
80  DOUBLE PRECISION ONE
81  parameter( one = 1.0d0 )
82 * ..
83 * .. Local Scalars ..
84  DOUBLE PRECISION W, XABS, YABS, Z
85  LOGICAL X_IS_NAN, Y_IS_NAN
86 * ..
87 * .. External Functions ..
88  LOGICAL DISNAN
89  EXTERNAL disnan
90 * ..
91 * .. Intrinsic Functions ..
92  INTRINSIC abs, max, min, sqrt
93 * ..
94 * .. Executable Statements ..
95 *
96  x_is_nan = disnan( x )
97  y_is_nan = disnan( y )
98  IF ( x_is_nan ) dlapy2 = x
99  IF ( y_is_nan ) dlapy2 = y
100 *
101  IF ( .NOT.( x_is_nan.OR.y_is_nan ) ) THEN
102  xabs = abs( x )
103  yabs = abs( y )
104  w = max( xabs, yabs )
105  z = min( xabs, yabs )
106  IF( z.EQ.zero ) THEN
107  dlapy2 = w
108  ELSE
109  dlapy2 = w*sqrt( one+( z / w )**2 )
110  END IF
111  END IF
112  RETURN
113 *
114 * End of DLAPY2
115 *
116  END
double precision function dlapy2(X, Y)
DLAPY2 returns sqrt(x2+y2).
Definition: dlapy2.f:65