01:       REAL             FUNCTION SLAPY3( X, Y, Z )
02: *
03: *  -- LAPACK auxiliary routine (version 3.2) --
04: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
05: *     November 2006
06: *
07: *     .. Scalar Arguments ..
08:       REAL               X, Y, Z
09: *     ..
10: *
11: *  Purpose
12: *  =======
13: *
14: *  SLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause
15: *  unnecessary overflow.
16: *
17: *  Arguments
18: *  =========
19: *
20: *  X       (input) REAL
21: *  Y       (input) REAL
22: *  Z       (input) REAL
23: *          X, Y and Z specify the values x, y and z.
24: *
25: *  =====================================================================
26: *
27: *     .. Parameters ..
28:       REAL               ZERO
29:       PARAMETER          ( ZERO = 0.0E0 )
30: *     ..
31: *     .. Local Scalars ..
32:       REAL               W, XABS, YABS, ZABS
33: *     ..
34: *     .. Intrinsic Functions ..
35:       INTRINSIC          ABS, MAX, SQRT
36: *     ..
37: *     .. Executable Statements ..
38: *
39:       XABS = ABS( X )
40:       YABS = ABS( Y )
41:       ZABS = ABS( Z )
42:       W = MAX( XABS, YABS, ZABS )
43:       IF( W.EQ.ZERO ) THEN
44: *     W can be zero for max(0,nan,0)
45: *     adding all three entries together will make sure
46: *     NaN will not disappear.
47:          SLAPY3 =  XABS + YABS + ZABS
48:       ELSE
49:          SLAPY3 = W*SQRT( ( XABS / W )**2+( YABS / W )**2+
50:      $            ( ZABS / W )**2 )
51:       END IF
52:       RETURN
53: *
54: *     End of SLAPY3
55: *
56:       END
57: