3 /* Table of constant values */
5 static integer c__1 = 1;
6 static doublereal c_b22 = 1.;
7 static doublereal c_b23 = 0.;
9 /* Subroutine */ int dlaed3_(integer *k, integer *n, integer *n1, doublereal *
10 d__, doublereal *q, integer *ldq, doublereal *rho, doublereal *dlamda,
11 doublereal *q2, integer *indx, integer *ctot, doublereal *w,
12 doublereal *s, integer *info)
14 /* System generated locals */
15 integer q_dim1, q_offset, i__1, i__2;
18 /* Builtin functions */
19 double sqrt(doublereal), d_sign(doublereal *, doublereal *);
22 integer i__, j, n2, n12, ii, n23, iq2;
24 extern doublereal dnrm2_(integer *, doublereal *, integer *);
25 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
26 integer *, doublereal *, doublereal *, integer *, doublereal *,
27 integer *, doublereal *, doublereal *, integer *),
28 dcopy_(integer *, doublereal *, integer *, doublereal *, integer
29 *), dlaed4_(integer *, integer *, doublereal *, doublereal *,
30 doublereal *, doublereal *, doublereal *, integer *);
31 extern doublereal dlamc3_(doublereal *, doublereal *);
32 extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
33 doublereal *, integer *, doublereal *, integer *),
34 dlaset_(char *, integer *, integer *, doublereal *, doublereal *,
35 doublereal *, integer *), xerbla_(char *, integer *);
38 /* -- LAPACK routine (version 3.1) -- */
39 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
42 /* .. Scalar Arguments .. */
44 /* .. Array Arguments .. */
50 /* DLAED3 finds the roots of the secular equation, as defined by the */
51 /* values in D, W, and RHO, between 1 and K. It makes the */
52 /* appropriate calls to DLAED4 and then updates the eigenvectors by */
53 /* multiplying the matrix of eigenvectors of the pair of eigensystems */
54 /* being combined by the matrix of eigenvectors of the K-by-K system */
55 /* which is solved here. */
57 /* This code makes very mild assumptions about floating point */
58 /* arithmetic. It will work on machines with a guard digit in */
59 /* add/subtract, or on those binary machines without guard digits */
60 /* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */
61 /* It could conceivably fail on hexadecimal or decimal machines */
62 /* without guard digits, but we know of none. */
67 /* K (input) INTEGER */
68 /* The number of terms in the rational function to be solved by */
71 /* N (input) INTEGER */
72 /* The number of rows and columns in the Q matrix. */
73 /* N >= K (deflation may result in N>K). */
75 /* N1 (input) INTEGER */
76 /* The location of the last eigenvalue in the leading submatrix. */
77 /* min(1,N) <= N1 <= N/2. */
79 /* D (output) DOUBLE PRECISION array, dimension (N) */
80 /* D(I) contains the updated eigenvalues for */
83 /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */
84 /* Initially the first K columns are used as workspace. */
85 /* On output the columns 1 to K contain */
86 /* the updated eigenvectors. */
88 /* LDQ (input) INTEGER */
89 /* The leading dimension of the array Q. LDQ >= max(1,N). */
91 /* RHO (input) DOUBLE PRECISION */
92 /* The value of the parameter in the rank one update equation. */
93 /* RHO >= 0 required. */
95 /* DLAMDA (input/output) DOUBLE PRECISION array, dimension (K) */
96 /* The first K elements of this array contain the old roots */
97 /* of the deflated updating problem. These are the poles */
98 /* of the secular equation. May be changed on output by */
99 /* having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */
100 /* Cray-2, or Cray C-90, as described above. */
102 /* Q2 (input) DOUBLE PRECISION array, dimension (LDQ2, N) */
103 /* The first K columns of this matrix contain the non-deflated */
104 /* eigenvectors for the split problem. */
106 /* INDX (input) INTEGER array, dimension (N) */
107 /* The permutation used to arrange the columns of the deflated */
108 /* Q matrix into three groups (see DLAED2). */
109 /* The rows of the eigenvectors found by DLAED4 must be likewise */
110 /* permuted before the matrix multiply can take place. */
112 /* CTOT (input) INTEGER array, dimension (4) */
113 /* A count of the total number of the various types of columns */
114 /* in Q, as described in INDX. The fourth column type is any */
115 /* column which has been deflated. */
117 /* W (input/output) DOUBLE PRECISION array, dimension (K) */
118 /* The first K elements of this array contain the components */
119 /* of the deflation-adjusted updating vector. Destroyed on */
122 /* S (workspace) DOUBLE PRECISION array, dimension (N1 + 1)*K */
123 /* Will contain the eigenvectors of the repaired matrix which */
124 /* will be multiplied by the previously accumulated eigenvectors */
125 /* to update the system. */
127 /* LDS (input) INTEGER */
128 /* The leading dimension of S. LDS >= max(1,K). */
130 /* INFO (output) INTEGER */
131 /* = 0: successful exit. */
132 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
133 /* > 0: if INFO = 1, an eigenvalue did not converge */
135 /* Further Details */
136 /* =============== */
138 /* Based on contributions by */
139 /* Jeff Rutter, Computer Science Division, University of California */
140 /* at Berkeley, USA */
141 /* Modified by Francoise Tisseur, University of Tennessee. */
143 /* ===================================================================== */
145 /* .. Parameters .. */
147 /* .. Local Scalars .. */
149 /* .. External Functions .. */
151 /* .. External Subroutines .. */
153 /* .. Intrinsic Functions .. */
155 /* .. Executable Statements .. */
157 /* Test the input parameters. */
159 /* Parameter adjustments */
162 q_offset = 1 + q_dim1;
176 } else if (*n < *k) {
178 } else if (*ldq < max(1,*n)) {
183 xerbla_("DLAED3", &i__1);
187 /* Quick return if possible */
193 /* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */
194 /* be computed with high relative accuracy (barring over/underflow). */
195 /* This is a problem on machines without a guard digit in */
196 /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
197 /* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */
198 /* which on any of these machines zeros out the bottommost */
199 /* bit of DLAMDA(I) if it is 1; this makes the subsequent */
200 /* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */
201 /* occurs. On binary machines with a guard digit (almost all */
202 /* machines) it does not change DLAMDA(I) at all. On hexadecimal */
203 /* and decimal machines with a guard digit, it slightly */
204 /* changes the bottommost bits of DLAMDA(I). It does not account */
205 /* for hexadecimal or decimal machines without guard digits */
206 /* (we know of none). We use a subroutine call to compute */
207 /* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */
211 for (i__ = 1; i__ <= i__1; ++i__) {
212 dlamda[i__] = dlamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__];
217 for (j = 1; j <= i__1; ++j) {
218 dlaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j],
221 /* If the zero finder fails, the computation is terminated. */
234 for (j = 1; j <= i__1; ++j) {
235 w[1] = q[j * q_dim1 + 1];
236 w[2] = q[j * q_dim1 + 2];
238 q[j * q_dim1 + 1] = w[ii];
240 q[j * q_dim1 + 2] = w[ii];
246 /* Compute updated W. */
248 dcopy_(k, &w[1], &c__1, &s[1], &c__1);
250 /* Initialize W(I) = Q(I,I) */
253 dcopy_(k, &q[q_offset], &i__1, &w[1], &c__1);
255 for (j = 1; j <= i__1; ++j) {
257 for (i__ = 1; i__ <= i__2; ++i__) {
258 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
262 for (i__ = j + 1; i__ <= i__2; ++i__) {
263 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
269 for (i__ = 1; i__ <= i__1; ++i__) {
270 d__1 = sqrt(-w[i__]);
271 w[i__] = d_sign(&d__1, &s[i__]);
275 /* Compute eigenvectors of the modified rank-1 modification. */
278 for (j = 1; j <= i__1; ++j) {
280 for (i__ = 1; i__ <= i__2; ++i__) {
281 s[i__] = w[i__] / q[i__ + j * q_dim1];
284 temp = dnrm2_(k, &s[1], &c__1);
286 for (i__ = 1; i__ <= i__2; ++i__) {
288 q[i__ + j * q_dim1] = s[ii] / temp;
294 /* Compute the updated eigenvectors. */
299 n12 = ctot[1] + ctot[2];
300 n23 = ctot[2] + ctot[3];
302 dlacpy_("A", &n23, k, &q[ctot[1] + 1 + q_dim1], ldq, &s[1], &n23);
305 dgemm_("N", "N", &n2, k, &n23, &c_b22, &q2[iq2], &n2, &s[1], &n23, &
306 c_b23, &q[*n1 + 1 + q_dim1], ldq);
308 dlaset_("A", &n2, k, &c_b23, &c_b23, &q[*n1 + 1 + q_dim1], ldq);
311 dlacpy_("A", &n12, k, &q[q_offset], ldq, &s[1], &n12);
313 dgemm_("N", "N", n1, k, &n12, &c_b22, &q2[1], n1, &s[1], &n12, &c_b23,
316 dlaset_("A", n1, k, &c_b23, &c_b23, &q[q_dim1 + 1], ldq);