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