3 /* Subroutine */ int slaev2_(real *a, real *b, real *c__, real *rt1, real *
4 rt2, real *cs1, real *sn1)
6 /* System generated locals */
9 /* Builtin functions */
10 double sqrt(doublereal);
13 real ab, df, cs, ct, tb, sm, tn, rt, adf, acs;
18 /* -- LAPACK auxiliary routine (version 3.1) -- */
19 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
22 /* .. Scalar Arguments .. */
28 /* SLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix */
31 /* On return, RT1 is the eigenvalue of larger absolute value, RT2 is the */
32 /* eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right */
33 /* eigenvector for RT1, giving the decomposition */
35 /* [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ] */
36 /* [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ]. */
42 /* The (1,1) element of the 2-by-2 matrix. */
45 /* The (1,2) element and the conjugate of the (2,1) element of */
46 /* the 2-by-2 matrix. */
49 /* The (2,2) element of the 2-by-2 matrix. */
51 /* RT1 (output) REAL */
52 /* The eigenvalue of larger absolute value. */
54 /* RT2 (output) REAL */
55 /* The eigenvalue of smaller absolute value. */
57 /* CS1 (output) REAL */
58 /* SN1 (output) REAL */
59 /* The vector (CS1, SN1) is a unit right eigenvector for RT1. */
64 /* RT1 is accurate to a few ulps barring over/underflow. */
66 /* RT2 may be inaccurate if there is massive cancellation in the */
67 /* determinant A*C-B*B; higher precision or correctly rounded or */
68 /* correctly truncated arithmetic would be needed to compute RT2 */
69 /* accurately in all cases. */
71 /* CS1 and SN1 are accurate to a few ulps barring over/underflow. */
73 /* Overflow is possible only if RT1 is within a factor of 5 of overflow. */
74 /* Underflow is harmless if the input data is 0 or exceeds */
75 /* underflow_threshold / macheps. */
77 /* ===================================================================== */
79 /* .. Parameters .. */
81 /* .. Local Scalars .. */
83 /* .. Intrinsic Functions .. */
85 /* .. Executable Statements .. */
87 /* Compute the eigenvalues */
94 if (dabs(*a) > dabs(*c__)) {
102 /* Computing 2nd power */
104 rt = adf * sqrt(r__1 * r__1 + 1.f);
105 } else if (adf < ab) {
106 /* Computing 2nd power */
108 rt = ab * sqrt(r__1 * r__1 + 1.f);
111 /* Includes case AB=ADF=0 */
116 *rt1 = (sm - rt) * .5f;
119 /* Order of execution important. */
120 /* To get fully accurate smaller eigenvalue, */
121 /* next line needs to be executed in higher precision. */
123 *rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b;
124 } else if (sm > 0.f) {
125 *rt1 = (sm + rt) * .5f;
128 /* Order of execution important. */
129 /* To get fully accurate smaller eigenvalue, */
130 /* next line needs to be executed in higher precision. */
132 *rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b;
135 /* Includes case RT1 = RT2 = 0 */
142 /* Compute the eigenvector */
154 *sn1 = 1.f / sqrt(ct * ct + 1.f);
162 *cs1 = 1.f / sqrt(tn * tn + 1.f);