LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ slapy2()

real function slapy2 ( real  X,
real  Y 
)

SLAPY2 returns sqrt(x2+y2).

Download SLAPY2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 SLAPY2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
 overflow.
Parameters
[in]X
          X is REAL
[in]Y
          Y is REAL
          X and Y specify the values x and y.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2017

Definition at line 65 of file slapy2.f.

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  REAL x, y
73 * ..
74 *
75 * =====================================================================
76 *
77 * .. Parameters ..
78  REAL zero
79  parameter( zero = 0.0e0 )
80  REAL one
81  parameter( one = 1.0e0 )
82 * ..
83 * .. Local Scalars ..
84  REAL w, xabs, yabs, z
85  LOGICAL x_is_nan, y_is_nan
86 * ..
87 * .. External Functions ..
88  LOGICAL sisnan
89  EXTERNAL sisnan
90 * ..
91 * .. Intrinsic Functions ..
92  INTRINSIC abs, max, min, sqrt
93 * ..
94 * .. Executable Statements ..
95 *
96 * ..
97 * .. Executable Statements ..
98 *
99  x_is_nan = sisnan( x )
100  y_is_nan = sisnan( y )
101  IF ( x_is_nan ) slapy2 = x
102  IF ( y_is_nan ) slapy2 = y
103 *
104  IF ( .NOT.( x_is_nan.OR.y_is_nan ) ) THEN
105  xabs = abs( x )
106  yabs = abs( y )
107  w = max( xabs, yabs )
108  z = min( xabs, yabs )
109  IF( z.EQ.zero ) THEN
110  slapy2 = w
111  ELSE
112  slapy2 = w*sqrt( one+( z / w )**2 )
113  END IF
114  END IF
115  RETURN
116 *
117 * End of SLAPY2
118 *
logical function sisnan(SIN)
SISNAN tests input for NaN.
Definition: sisnan.f:61
real function slapy2(X, Y)
SLAPY2 returns sqrt(x2+y2).
Definition: slapy2.f:65