2329
|
1 DOUBLE PRECISION FUNCTION DLAPY3( X, Y, Z ) |
|
2 * |
7034
|
3 * -- LAPACK auxiliary routine (version 3.1) -- |
|
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. |
|
5 * November 2006 |
2329
|
6 * |
|
7 * .. Scalar Arguments .. |
|
8 DOUBLE PRECISION X, Y, Z |
|
9 * .. |
|
10 * |
|
11 * Purpose |
|
12 * ======= |
|
13 * |
|
14 * DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause |
|
15 * unnecessary overflow. |
|
16 * |
|
17 * Arguments |
|
18 * ========= |
|
19 * |
|
20 * X (input) DOUBLE PRECISION |
|
21 * Y (input) DOUBLE PRECISION |
|
22 * Z (input) DOUBLE PRECISION |
|
23 * X, Y and Z specify the values x, y and z. |
|
24 * |
|
25 * ===================================================================== |
|
26 * |
|
27 * .. Parameters .. |
|
28 DOUBLE PRECISION ZERO |
|
29 PARAMETER ( ZERO = 0.0D0 ) |
|
30 * .. |
|
31 * .. Local Scalars .. |
|
32 DOUBLE PRECISION 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 |
7034
|
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 DLAPY3 = XABS + YABS + ZABS |
2329
|
48 ELSE |
|
49 DLAPY3 = W*SQRT( ( XABS / W )**2+( YABS / W )**2+ |
|
50 $ ( ZABS / W )**2 ) |
|
51 END IF |
|
52 RETURN |
|
53 * |
|
54 * End of DLAPY3 |
|
55 * |
|
56 END |