3 /* Table of constant values */
5 static integer c__1 = 1;
7 /* Subroutine */ int dlaed9_(integer *k, integer *kstart, integer *kstop,
8 integer *n, doublereal *d__, doublereal *q, integer *ldq, doublereal *
9 rho, doublereal *dlamda, doublereal *w, doublereal *s, integer *lds,
12 /* System generated locals */
13 integer q_dim1, q_offset, s_dim1, s_offset, i__1, i__2;
16 /* Builtin functions */
17 double sqrt(doublereal), d_sign(doublereal *, doublereal *);
22 extern doublereal dnrm2_(integer *, doublereal *, integer *);
23 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
24 doublereal *, integer *), dlaed4_(integer *, integer *,
25 doublereal *, doublereal *, doublereal *, doublereal *,
26 doublereal *, integer *);
27 extern doublereal dlamc3_(doublereal *, doublereal *);
28 extern /* Subroutine */ int xerbla_(char *, integer *);
31 /* -- LAPACK routine (version 3.1) -- */
32 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
35 /* .. Scalar Arguments .. */
37 /* .. Array Arguments .. */
43 /* DLAED9 finds the roots of the secular equation, as defined by the */
44 /* values in D, Z, and RHO, between KSTART and KSTOP. It makes the */
45 /* appropriate calls to DLAED4 and then stores the new matrix of */
46 /* eigenvectors for use in calculating the next level of Z vectors. */
51 /* K (input) INTEGER */
52 /* The number of terms in the rational function to be solved by */
55 /* KSTART (input) INTEGER */
56 /* KSTOP (input) INTEGER */
57 /* The updated eigenvalues Lambda(I), KSTART <= I <= KSTOP */
58 /* are to be computed. 1 <= KSTART <= KSTOP <= K. */
60 /* N (input) INTEGER */
61 /* The number of rows and columns in the Q matrix. */
62 /* N >= K (delation may result in N > K). */
64 /* D (output) DOUBLE PRECISION array, dimension (N) */
65 /* D(I) contains the updated eigenvalues */
66 /* for KSTART <= I <= KSTOP. */
68 /* Q (workspace) DOUBLE PRECISION array, dimension (LDQ,N) */
70 /* LDQ (input) INTEGER */
71 /* The leading dimension of the array Q. LDQ >= max( 1, N ). */
73 /* RHO (input) DOUBLE PRECISION */
74 /* The value of the parameter in the rank one update equation. */
75 /* RHO >= 0 required. */
77 /* DLAMDA (input) DOUBLE PRECISION array, dimension (K) */
78 /* The first K elements of this array contain the old roots */
79 /* of the deflated updating problem. These are the poles */
80 /* of the secular equation. */
82 /* W (input) DOUBLE PRECISION array, dimension (K) */
83 /* The first K elements of this array contain the components */
84 /* of the deflation-adjusted updating vector. */
86 /* S (output) DOUBLE PRECISION array, dimension (LDS, K) */
87 /* Will contain the eigenvectors of the repaired matrix which */
88 /* will be stored for subsequent Z vector calculation and */
89 /* multiplied by the previously accumulated eigenvectors */
90 /* to update the system. */
92 /* LDS (input) INTEGER */
93 /* The leading dimension of S. LDS >= max( 1, K ). */
95 /* INFO (output) INTEGER */
96 /* = 0: successful exit. */
97 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
98 /* > 0: if INFO = 1, an eigenvalue did not converge */
100 /* Further Details */
101 /* =============== */
103 /* Based on contributions by */
104 /* Jeff Rutter, Computer Science Division, University of California */
105 /* at Berkeley, USA */
107 /* ===================================================================== */
109 /* .. Local Scalars .. */
111 /* .. External Functions .. */
113 /* .. External Subroutines .. */
115 /* .. Intrinsic Functions .. */
117 /* .. Executable Statements .. */
119 /* Test the input parameters. */
121 /* Parameter adjustments */
124 q_offset = 1 + q_dim1;
129 s_offset = 1 + s_dim1;
137 } else if (*kstart < 1 || *kstart > max(1,*k)) {
139 } else if (max(1,*kstop) < *kstart || *kstop > max(1,*k)) {
141 } else if (*n < *k) {
143 } else if (*ldq < max(1,*k)) {
145 } else if (*lds < max(1,*k)) {
150 xerbla_("DLAED9", &i__1);
154 /* Quick return if possible */
160 /* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */
161 /* be computed with high relative accuracy (barring over/underflow). */
162 /* This is a problem on machines without a guard digit in */
163 /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
164 /* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */
165 /* which on any of these machines zeros out the bottommost */
166 /* bit of DLAMDA(I) if it is 1; this makes the subsequent */
167 /* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */
168 /* occurs. On binary machines with a guard digit (almost all */
169 /* machines) it does not change DLAMDA(I) at all. On hexadecimal */
170 /* and decimal machines with a guard digit, it slightly */
171 /* changes the bottommost bits of DLAMDA(I). It does not account */
172 /* for hexadecimal or decimal machines without guard digits */
173 /* (we know of none). We use a subroutine call to compute */
174 /* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */
178 for (i__ = 1; i__ <= i__1; ++i__) {
179 dlamda[i__] = dlamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__];
184 for (j = *kstart; j <= i__1; ++j) {
185 dlaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j],
188 /* If the zero finder fails, the computation is terminated. */
196 if (*k == 1 || *k == 2) {
198 for (i__ = 1; i__ <= i__1; ++i__) {
200 for (j = 1; j <= i__2; ++j) {
201 s[j + i__ * s_dim1] = q[j + i__ * q_dim1];
209 /* Compute updated W. */
211 dcopy_(k, &w[1], &c__1, &s[s_offset], &c__1);
213 /* Initialize W(I) = Q(I,I) */
216 dcopy_(k, &q[q_offset], &i__1, &w[1], &c__1);
218 for (j = 1; j <= i__1; ++j) {
220 for (i__ = 1; i__ <= i__2; ++i__) {
221 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
225 for (i__ = j + 1; i__ <= i__2; ++i__) {
226 w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
232 for (i__ = 1; i__ <= i__1; ++i__) {
233 d__1 = sqrt(-w[i__]);
234 w[i__] = d_sign(&d__1, &s[i__ + s_dim1]);
238 /* Compute eigenvectors of the modified rank-1 modification. */
241 for (j = 1; j <= i__1; ++j) {
243 for (i__ = 1; i__ <= i__2; ++i__) {
244 q[i__ + j * q_dim1] = w[i__] / q[i__ + j * q_dim1];
247 temp = dnrm2_(k, &q[j * q_dim1 + 1], &c__1);
249 for (i__ = 1; i__ <= i__2; ++i__) {
250 s[i__ + j * s_dim1] = q[i__ + j * q_dim1] / temp;