3 /* Table of constant values */
5 static real c_b3 = 2.f;
6 static real c_b4 = 1.f;
8 /* Subroutine */ int slasv2_(real *f, real *g, real *h__, real *ssmin, real *
9 ssmax, real *snr, real *csr, real *snl, real *csl)
11 /* System generated locals */
14 /* Builtin functions */
15 double sqrt(doublereal), r_sign(real *, real *);
18 real a, d__, l, m, r__, s, t, fa, ga, ha, ft, gt, ht, mm, tt, clt, crt,
25 extern doublereal slamch_(char *);
28 /* -- LAPACK auxiliary routine (version 3.1) -- */
29 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
32 /* .. Scalar Arguments .. */
38 /* SLASV2 computes the singular value decomposition of a 2-by-2 */
39 /* triangular matrix */
42 /* On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the */
43 /* smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and */
44 /* right singular vectors for abs(SSMAX), giving the decomposition */
46 /* [ CSL SNL ] [ F G ] [ CSR -SNR ] = [ SSMAX 0 ] */
47 /* [-SNL CSL ] [ 0 H ] [ SNR CSR ] [ 0 SSMIN ]. */
53 /* The (1,1) element of the 2-by-2 matrix. */
56 /* The (1,2) element of the 2-by-2 matrix. */
59 /* The (2,2) element of the 2-by-2 matrix. */
61 /* SSMIN (output) REAL */
62 /* abs(SSMIN) is the smaller singular value. */
64 /* SSMAX (output) REAL */
65 /* abs(SSMAX) is the larger singular value. */
67 /* SNL (output) REAL */
68 /* CSL (output) REAL */
69 /* The vector (CSL, SNL) is a unit left singular vector for the */
70 /* singular value abs(SSMAX). */
72 /* SNR (output) REAL */
73 /* CSR (output) REAL */
74 /* The vector (CSR, SNR) is a unit right singular vector for the */
75 /* singular value abs(SSMAX). */
80 /* Any input parameter may be aliased with any output parameter. */
82 /* Barring over/underflow and assuming a guard digit in subtraction, all */
83 /* output quantities are correct to within a few units in the last */
86 /* In IEEE arithmetic, the code works correctly if one matrix element is */
89 /* Overflow will not occur unless the largest singular value itself */
90 /* overflows or is within a few ulps of overflow. (On machines with */
91 /* partial overflow, like the Cray, overflow may occur if the largest */
92 /* singular value is within a factor of 2 of overflow.) */
94 /* Underflow is harmless if underflow is gradual. Otherwise, results */
95 /* may correspond to a matrix modified by perturbations of size near */
96 /* the underflow threshold. */
98 /* ===================================================================== */
100 /* .. Parameters .. */
102 /* .. Local Scalars .. */
104 /* .. Intrinsic Functions .. */
106 /* .. External Functions .. */
108 /* .. Executable Statements .. */
115 /* PMAX points to the maximum absolute element of matrix */
116 /* PMAX = 1 if F largest in absolute values */
117 /* PMAX = 2 if G largest in absolute values */
118 /* PMAX = 3 if H largest in absolute values */
138 /* Diagonal matrix */
150 if (fa / ga < slamch_("EPS")) {
152 /* Case of very large GA */
157 *ssmin = fa / (ga / ha);
159 *ssmin = fa / ga * ha;
174 /* Copes with infinite F or H */
181 /* Note that 0 .le. L .le. 1 */
185 /* Note that abs(M) .le. 1/macheps */
189 /* Note that T .ge. 1 */
195 /* Note that 1 .le. S .le. 1 + 1/macheps */
200 r__ = sqrt(l * l + mm);
203 /* Note that 0 .le. R .le. 1 + 1/macheps */
207 /* Note that 1 .le. A .le. 1 + abs(M) */
213 /* Note that M is very tiny */
216 t = r_sign(&c_b3, &ft) * r_sign(&c_b4, >);
218 t = gt / r_sign(&d__, &ft) + m / t;
221 t = (m / (s + t) + m / (r__ + l)) * (a + 1.f);
223 l = sqrt(t * t + 4.f);
226 clt = (crt + srt * m) / a;
227 slt = ht / ft * srt / a;
242 /* Correct signs of SSMAX and SSMIN */
245 tsign = r_sign(&c_b4, csr) * r_sign(&c_b4, csl) * r_sign(&c_b4, f);
248 tsign = r_sign(&c_b4, snr) * r_sign(&c_b4, csl) * r_sign(&c_b4, g);
251 tsign = r_sign(&c_b4, snr) * r_sign(&c_b4, snl) * r_sign(&c_b4, h__);
253 *ssmax = r_sign(ssmax, &tsign);
254 r__1 = tsign * r_sign(&c_b4, f) * r_sign(&c_b4, h__);
255 *ssmin = r_sign(ssmin, &r__1);