KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlas2.f
Go to the documentation of this file.
1  SUBROUTINE dlas2( F, G, H, SSMIN, SSMAX )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * September 30, 1994
7 *
8 * .. Scalar Arguments ..
9  DOUBLE PRECISION F, G, H, SSMAX, SSMIN
10 * ..
11 *
12 * Purpose
13 * =======
14 *
15 * DLAS2 computes the singular values of the 2-by-2 matrix
16 * [ F G ]
17 * [ 0 H ].
18 * On return, SSMIN is the smaller singular value and SSMAX is the
19 * larger singular value.
20 *
21 * Arguments
22 * =========
23 *
24 * F (input) DOUBLE PRECISION
25 * The (1,1) element of the 2-by-2 matrix.
26 *
27 * G (input) DOUBLE PRECISION
28 * The (1,2) element of the 2-by-2 matrix.
29 *
30 * H (input) DOUBLE PRECISION
31 * The (2,2) element of the 2-by-2 matrix.
32 *
33 * SSMIN (output) DOUBLE PRECISION
34 * The smaller singular value.
35 *
36 * SSMAX (output) DOUBLE PRECISION
37 * The larger singular value.
38 *
39 * Further Details
40 * ===============
41 *
42 * Barring over/underflow, all output quantities are correct to within
43 * a few units in the last place (ulps), even in the absence of a guard
44 * digit in addition/subtraction.
45 *
46 * In IEEE arithmetic, the code works correctly if one matrix element is
47 * infinite.
48 *
49 * Overflow will not occur unless the largest singular value itself
50 * overflows, or is within a few ulps of overflow. (On machines with
51 * partial overflow, like the Cray, overflow may occur if the largest
52 * singular value is within a factor of 2 of overflow.)
53 *
54 * Underflow is harmless if underflow is gradual. Otherwise, results
55 * may correspond to a matrix modified by perturbations of size near
56 * the underflow threshold.
57 *
58 * ====================================================================
59 *
60 * .. Parameters ..
61  DOUBLE PRECISION ZERO
62  parameter( zero = 0.0d0 )
63  DOUBLE PRECISION ONE
64  parameter( one = 1.0d0 )
65  DOUBLE PRECISION TWO
66  parameter( two = 2.0d0 )
67 * ..
68 * .. Local Scalars ..
69  DOUBLE PRECISION AS, AT, AU, C, FA, FHMN, FHMX, GA, HA
70 * ..
71 * .. Intrinsic Functions ..
72  INTRINSIC abs, max, min, sqrt
73 * ..
74 * .. Executable Statements ..
75 *
76  fa = abs( f )
77  ga = abs( g )
78  ha = abs( h )
79  fhmn = min( fa, ha )
80  fhmx = max( fa, ha )
81  IF( fhmn.EQ.zero ) THEN
82  ssmin = zero
83  IF( fhmx.EQ.zero ) THEN
84  ssmax = ga
85  ELSE
86  ssmax = max( fhmx, ga )*sqrt( one+
87  $ ( min( fhmx, ga ) / max( fhmx, ga ) )**2 )
88  END IF
89  ELSE
90  IF( ga.LT.fhmx ) THEN
91  as = one + fhmn / fhmx
92  at = ( fhmx-fhmn ) / fhmx
93  au = ( ga / fhmx )**2
94  c = two / ( sqrt( as*as+au )+sqrt( at*at+au ) )
95  ssmin = fhmn*c
96  ssmax = fhmx / c
97  ELSE
98  au = fhmx / ga
99  IF( au.EQ.zero ) THEN
100 *
101 * Avoid possible harmful underflow if exponent range
102 * asymmetric (true SSMIN may not underflow even if
103 * AU underflows)
104 *
105  ssmin = ( fhmn*fhmx ) / ga
106  ssmax = ga
107  ELSE
108  as = one + fhmn / fhmx
109  at = ( fhmx-fhmn ) / fhmx
110  c = one / ( sqrt( one+( as*au )**2 )+
111  $ sqrt( one+( at*au )**2 ) )
112  ssmin = ( fhmn*c )*au
113  ssmin = ssmin + ssmin
114  ssmax = ga / ( c+c )
115  END IF
116  END IF
117  END IF
118  RETURN
119 *
120 * End of DLAS2
121 *
122  END
subroutine dlas2(F, G, H, SSMIN, SSMAX)
Definition: dlas2.f:2