3 /* Subroutine */ int dlaev2_(doublereal *a, doublereal *b, doublereal *c__,
4 doublereal *rt1, doublereal *rt2, doublereal *cs1, doublereal *sn1)
6 /* System generated locals */
9 /* Builtin functions */
10 double sqrt(doublereal);
13 doublereal ab, df, cs, ct, tb, sm, tn, rt, adf, acs;
15 doublereal acmn, acmx;
18 /* -- LAPACK auxiliary routine (version 3.1) -- */
19 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
22 /* .. Scalar Arguments .. */
28 /* DLAEV2 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 ]. */
41 /* A (input) DOUBLE PRECISION */
42 /* The (1,1) element of the 2-by-2 matrix. */
44 /* B (input) DOUBLE PRECISION */
45 /* The (1,2) element and the conjugate of the (2,1) element of */
46 /* the 2-by-2 matrix. */
48 /* C (input) DOUBLE PRECISION */
49 /* The (2,2) element of the 2-by-2 matrix. */
51 /* RT1 (output) DOUBLE PRECISION */
52 /* The eigenvalue of larger absolute value. */
54 /* RT2 (output) DOUBLE PRECISION */
55 /* The eigenvalue of smaller absolute value. */
57 /* CS1 (output) DOUBLE PRECISION */
58 /* SN1 (output) DOUBLE PRECISION */
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 (abs(*a) > abs(*c__)) {
102 /* Computing 2nd power */
104 rt = adf * sqrt(d__1 * d__1 + 1.);
105 } else if (adf < ab) {
106 /* Computing 2nd power */
108 rt = ab * sqrt(d__1 * d__1 + 1.);
111 /* Includes case AB=ADF=0 */
116 *rt1 = (sm - rt) * .5;
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.) {
125 *rt1 = (sm + rt) * .5;
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. / sqrt(ct * ct + 1.);
162 *cs1 = 1. / sqrt(tn * tn + 1.);