1 /* ./src_f77/dlaev2.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
dlaev2_(doublereal * a,doublereal * b,doublereal * c__,doublereal * rt1,doublereal * rt2,doublereal * cs1,doublereal * sn1)8 /* Subroutine */ int dlaev2_(doublereal *a, doublereal *b, doublereal *c__,
9 doublereal *rt1, doublereal *rt2, doublereal *cs1, doublereal *sn1)
10 {
11 /* System generated locals */
12 doublereal d__1;
13
14 /* Builtin functions */
15 double sqrt(doublereal);
16
17 /* Local variables */
18 static doublereal ab, df, cs, ct, tb, sm, tn, rt, adf, acs;
19 static integer sgn1, sgn2;
20 static doublereal acmn, acmx;
21
22
23 /* -- LAPACK auxiliary routine (version 3.0) -- */
24 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
25 /* Courant Institute, Argonne National Lab, and Rice University */
26 /* October 31, 1992 */
27
28 /* .. Scalar Arguments .. */
29 /* .. */
30
31 /* Purpose */
32 /* ======= */
33
34 /* DLAEV2 computes the eigendecomposition of a 2-by-2 symmetric matrix */
35 /* [ A B ] */
36 /* [ B C ]. */
37 /* On return, RT1 is the eigenvalue of larger absolute value, RT2 is the */
38 /* eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right */
39 /* eigenvector for RT1, giving the decomposition */
40
41 /* [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ] */
42 /* [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ]. */
43
44 /* Arguments */
45 /* ========= */
46
47 /* A (input) DOUBLE PRECISION */
48 /* The (1,1) element of the 2-by-2 matrix. */
49
50 /* B (input) DOUBLE PRECISION */
51 /* The (1,2) element and the conjugate of the (2,1) element of */
52 /* the 2-by-2 matrix. */
53
54 /* C (input) DOUBLE PRECISION */
55 /* The (2,2) element of the 2-by-2 matrix. */
56
57 /* RT1 (output) DOUBLE PRECISION */
58 /* The eigenvalue of larger absolute value. */
59
60 /* RT2 (output) DOUBLE PRECISION */
61 /* The eigenvalue of smaller absolute value. */
62
63 /* CS1 (output) DOUBLE PRECISION */
64 /* SN1 (output) DOUBLE PRECISION */
65 /* The vector (CS1, SN1) is a unit right eigenvector for RT1. */
66
67 /* Further Details */
68 /* =============== */
69
70 /* RT1 is accurate to a few ulps barring over/underflow. */
71
72 /* RT2 may be inaccurate if there is massive cancellation in the */
73 /* determinant A*C-B*B; higher precision or correctly rounded or */
74 /* correctly truncated arithmetic would be needed to compute RT2 */
75 /* accurately in all cases. */
76
77 /* CS1 and SN1 are accurate to a few ulps barring over/underflow. */
78
79 /* Overflow is possible only if RT1 is within a factor of 5 of overflow. */
80 /* Underflow is harmless if the input data is 0 or exceeds */
81 /* underflow_threshold / macheps. */
82
83 /* ===================================================================== */
84
85 /* .. Parameters .. */
86 /* .. */
87 /* .. Local Scalars .. */
88 /* .. */
89 /* .. Intrinsic Functions .. */
90 /* .. */
91 /* .. Executable Statements .. */
92
93 /* Compute the eigenvalues */
94
95 sm = *a + *c__;
96 df = *a - *c__;
97 adf = abs(df);
98 tb = *b + *b;
99 ab = abs(tb);
100 if (abs(*a) > abs(*c__)) {
101 acmx = *a;
102 acmn = *c__;
103 } else {
104 acmx = *c__;
105 acmn = *a;
106 }
107 if (adf > ab) {
108 /* Computing 2nd power */
109 d__1 = ab / adf;
110 rt = adf * sqrt(d__1 * d__1 + 1.);
111 } else if (adf < ab) {
112 /* Computing 2nd power */
113 d__1 = adf / ab;
114 rt = ab * sqrt(d__1 * d__1 + 1.);
115 } else {
116
117 /* Includes case AB=ADF=0 */
118
119 rt = ab * sqrt(2.);
120 }
121 if (sm < 0.) {
122 *rt1 = (sm - rt) * .5;
123 sgn1 = -1;
124
125 /* Order of execution important. */
126 /* To get fully accurate smaller eigenvalue, */
127 /* next line needs to be executed in higher precision. */
128
129 *rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b;
130 } else if (sm > 0.) {
131 *rt1 = (sm + rt) * .5;
132 sgn1 = 1;
133
134 /* Order of execution important. */
135 /* To get fully accurate smaller eigenvalue, */
136 /* next line needs to be executed in higher precision. */
137
138 *rt2 = acmx / *rt1 * acmn - *b / *rt1 * *b;
139 } else {
140
141 /* Includes case RT1 = RT2 = 0 */
142
143 *rt1 = rt * .5;
144 *rt2 = rt * -.5;
145 sgn1 = 1;
146 }
147
148 /* Compute the eigenvector */
149
150 if (df >= 0.) {
151 cs = df + rt;
152 sgn2 = 1;
153 } else {
154 cs = df - rt;
155 sgn2 = -1;
156 }
157 acs = abs(cs);
158 if (acs > ab) {
159 ct = -tb / cs;
160 *sn1 = 1. / sqrt(ct * ct + 1.);
161 *cs1 = ct * *sn1;
162 } else {
163 if (ab == 0.) {
164 *cs1 = 1.;
165 *sn1 = 0.;
166 } else {
167 tn = -cs / tb;
168 *cs1 = 1. / sqrt(tn * tn + 1.);
169 *sn1 = tn * *cs1;
170 }
171 }
172 if (sgn1 == sgn2) {
173 tn = *cs1;
174 *cs1 = -(*sn1);
175 *sn1 = tn;
176 }
177 return 0;
178
179 /* End of DLAEV2 */
180
181 } /* dlaev2_ */
182
183