3 /* Table of constant values */
5 static integer c__1 = 1;
6 static real c_b22 = 1.f;
7 static real c_b23 = 0.f;
9 /* Subroutine */ int slaed3_(integer *k, integer *n, integer *n1, real *d__,
10 real *q, integer *ldq, real *rho, real *dlamda, real *q2, integer *
11 indx, integer *ctot, real *w, real *s, integer *info)
13 /* System generated locals */
14 integer q_dim1, q_offset, i__1, i__2;
17 /* Builtin functions */
18 double sqrt(doublereal), r_sign(real *, real *);
21 integer i__, j, n2, n12, ii, n23, iq2;
23 extern doublereal snrm2_(integer *, real *, integer *);
24 extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
25 integer *, real *, real *, integer *, real *, integer *, real *,
26 real *, integer *), scopy_(integer *, real *,
27 integer *, real *, integer *), slaed4_(integer *, integer *, real
28 *, real *, real *, real *, real *, integer *);
29 extern doublereal slamc3_(real *, real *);
30 extern /* Subroutine */ int xerbla_(char *, integer *), slacpy_(
31 char *, integer *, integer *, real *, integer *, real *, integer *
32 ), slaset_(char *, integer *, integer *, real *, real *,
36 /* -- LAPACK routine (version 3.1) -- */
37 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
40 /* .. Scalar Arguments .. */
42 /* .. Array Arguments .. */
48 /* SLAED3 finds the roots of the secular equation, as defined by the */
49 /* values in D, W, and RHO, between 1 and K. It makes the */
50 /* appropriate calls to SLAED4 and then updates the eigenvectors by */
51 /* multiplying the matrix of eigenvectors of the pair of eigensystems */
52 /* being combined by the matrix of eigenvectors of the K-by-K system */
53 /* which is solved here. */
55 /* This code makes very mild assumptions about floating point */
56 /* arithmetic. It will work on machines with a guard digit in */
57 /* add/subtract, or on those binary machines without guard digits */
58 /* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */
59 /* It could conceivably fail on hexadecimal or decimal machines */
60 /* without guard digits, but we know of none. */
65 /* K (input) INTEGER */
66 /* The number of terms in the rational function to be solved by */
69 /* N (input) INTEGER */
70 /* The number of rows and columns in the Q matrix. */
71 /* N >= K (deflation may result in N>K). */
73 /* N1 (input) INTEGER */
74 /* The location of the last eigenvalue in the leading submatrix. */
75 /* min(1,N) <= N1 <= N/2. */
77 /* D (output) REAL array, dimension (N) */
78 /* D(I) contains the updated eigenvalues for */
81 /* Q (output) REAL array, dimension (LDQ,N) */
82 /* Initially the first K columns are used as workspace. */
83 /* On output the columns 1 to K contain */
84 /* the updated eigenvectors. */
86 /* LDQ (input) INTEGER */
87 /* The leading dimension of the array Q. LDQ >= max(1,N). */
89 /* RHO (input) REAL */
90 /* The value of the parameter in the rank one update equation. */
91 /* RHO >= 0 required. */
93 /* DLAMDA (input/output) REAL array, dimension (K) */
94 /* The first K elements of this array contain the old roots */
95 /* of the deflated updating problem. These are the poles */
96 /* of the secular equation. May be changed on output by */
97 /* having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */
98 /* Cray-2, or Cray C-90, as described above. */
100 /* Q2 (input) REAL array, dimension (LDQ2, N) */
101 /* The first K columns of this matrix contain the non-deflated */
102 /* eigenvectors for the split problem. */
104 /* INDX (input) INTEGER array, dimension (N) */
105 /* The permutation used to arrange the columns of the deflated */
106 /* Q matrix into three groups (see SLAED2). */
107 /* The rows of the eigenvectors found by SLAED4 must be likewise */
108 /* permuted before the matrix multiply can take place. */
110 /* CTOT (input) INTEGER array, dimension (4) */
111 /* A count of the total number of the various types of columns */
112 /* in Q, as described in INDX. The fourth column type is any */
113 /* column which has been deflated. */
115 /* W (input/output) REAL array, dimension (K) */
116 /* The first K elements of this array contain the components */
117 /* of the deflation-adjusted updating vector. Destroyed on */
120 /* S (workspace) REAL array, dimension (N1 + 1)*K */
121 /* Will contain the eigenvectors of the repaired matrix which */
122 /* will be multiplied by the previously accumulated eigenvectors */
123 /* to update the system. */
125 /* LDS (input) INTEGER */
126 /* The leading dimension of S. LDS >= max(1,K). */
128 /* INFO (output) INTEGER */
129 /* = 0: successful exit. */
130 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
131 /* > 0: if INFO = 1, an eigenvalue did not converge */
133 /* Further Details */
134 /* =============== */
136 /* Based on contributions by */
137 /* Jeff Rutter, Computer Science Division, University of California */
138 /* at Berkeley, USA */
139 /* Modified by Francoise Tisseur, University of Tennessee. */
141 /* ===================================================================== */
143 /* .. Parameters .. */
145 /* .. Local Scalars .. */
147 /* .. External Functions .. */
149 /* .. External Subroutines .. */
151 /* .. Intrinsic Functions .. */
153 /* .. Executable Statements .. */
155 /* Test the input parameters. */
157 /* Parameter adjustments */
160 q_offset = 1 + q_dim1;
174 } else if (*n < *k) {
176 } else if (*ldq < max(1,*n)) {
181 xerbla_("SLAED3", &i__1);
185 /* Quick return if possible */
191 /* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */
192 /* be computed with high relative accuracy (barring over/underflow). */
193 /* This is a problem on machines without a guard digit in */
194 /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
195 /* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */
196 /* which on any of these machines zeros out the bottommost */
197 /* bit of DLAMDA(I) if it is 1; this makes the subsequent */
198 /* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */
199 /* occurs. On binary machines with a guard digit (almost all */
200 /* machines) it does not change DLAMDA(I) at all. On hexadecimal */
201 /* and decimal machines with a guard digit, it slightly */
202 /* changes the bottommost bits of DLAMDA(I). It does not account */
203 /* for hexadecimal or decimal machines without guard digits */
204 /* (we know of none). We use a subroutine call to compute */
205 /* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */
209 for (i__ = 1; i__ <= i__1; ++i__) {
210 dlamda[i__] = slamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__];
215 for (j = 1; j <= i__1; ++j) {
216 slaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j],
219 /* If the zero finder fails, the computation is terminated. */
232 for (j = 1; j <= i__1; ++j) {
233 w[1] = q[j * q_dim1 + 1];
234 w[2] = q[j * q_dim1 + 2];
236 q[j * q_dim1 + 1] = w[ii];
238 q[j * q_dim1 + 2] = w[ii];
244 /* Compute updated W. */
246 scopy_(k, &w[1], &c__1, &s[1], &c__1);
248 /* Initialize W(I) = Q(I,I) */
251 scopy_(k, &q[q_offset], &i__1, &w[1], &c__1);
253 for (j = 1; j <= i__1; ++j) {
255 for (i__ = 1; i__ <= i__2; ++i__) {
256 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
260 for (i__ = j + 1; i__ <= i__2; ++i__) {
261 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
267 for (i__ = 1; i__ <= i__1; ++i__) {
268 r__1 = sqrt(-w[i__]);
269 w[i__] = r_sign(&r__1, &s[i__]);
273 /* Compute eigenvectors of the modified rank-1 modification. */
276 for (j = 1; j <= i__1; ++j) {
278 for (i__ = 1; i__ <= i__2; ++i__) {
279 s[i__] = w[i__] / q[i__ + j * q_dim1];
282 temp = snrm2_(k, &s[1], &c__1);
284 for (i__ = 1; i__ <= i__2; ++i__) {
286 q[i__ + j * q_dim1] = s[ii] / temp;
292 /* Compute the updated eigenvectors. */
297 n12 = ctot[1] + ctot[2];
298 n23 = ctot[2] + ctot[3];
300 slacpy_("A", &n23, k, &q[ctot[1] + 1 + q_dim1], ldq, &s[1], &n23);
303 sgemm_("N", "N", &n2, k, &n23, &c_b22, &q2[iq2], &n2, &s[1], &n23, &
304 c_b23, &q[*n1 + 1 + q_dim1], ldq);
306 slaset_("A", &n2, k, &c_b23, &c_b23, &q[*n1 + 1 + q_dim1], ldq);
309 slacpy_("A", &n12, k, &q[q_offset], ldq, &s[1], &n12);
311 sgemm_("N", "N", n1, k, &n12, &c_b22, &q2[1], n1, &s[1], &n12, &c_b23,
314 slaset_("A", n1, k, &c_b23, &c_b23, &q[q_dim1 + 1], ldq);