LAPACK  3.10.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
9 *> Download DLAPY2 + dependencies
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 and unnecessary underflow.
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 *> \ingroup OTHERauxiliary
60 *
61 * =====================================================================
62  DOUBLE PRECISION FUNCTION dlapy2( X, Y )
63 *
64 * -- LAPACK auxiliary routine --
65 * -- LAPACK is a software package provided by Univ. of Tennessee, --
66 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
67 *
68 * .. Scalar Arguments ..
69  DOUBLE PRECISION x, y
70 * ..
71 *
72 * =====================================================================
73 *
74 * .. Parameters ..
75  DOUBLE PRECISION zero
76  parameter( zero = 0.0d0 )
77  DOUBLE PRECISION one
78  parameter( one = 1.0d0 )
79 * ..
80 * .. Local Scalars ..
81  DOUBLE PRECISION w, xabs, yabs, z
82  LOGICAL x_is_nan, y_is_nan
83 * ..
84 * .. External Functions ..
85  LOGICAL disnan
86  EXTERNAL disnan
87 * ..
88 * .. Intrinsic Functions ..
89  INTRINSIC abs, max, min, sqrt
90 * ..
91 * .. Executable Statements ..
92 *
93  x_is_nan = disnan( x )
94  y_is_nan = disnan( y )
95  IF ( x_is_nan ) dlapy2 = x
96  IF ( y_is_nan ) dlapy2 = y
97 *
98  IF ( .NOT.( x_is_nan.OR.y_is_nan ) ) THEN
99  xabs = abs( x )
100  yabs = abs( y )
101  w = max( xabs, yabs )
102  z = min( xabs, yabs )
103  IF( z.EQ.zero ) THEN
104  dlapy2 = w
105  ELSE
106  dlapy2 = w*sqrt( one+( z / w )**2 )
107  END IF
108  END IF
109  RETURN
110 *
111 * End of DLAPY2
112 *
113  END
logical function disnan(DIN)
DISNAN tests input for NaN.
Definition: disnan.f:59
double precision function dlapy2(X, Y)
DLAPY2 returns sqrt(x2+y2).
Definition: dlapy2.f:63