3 /* Table of constant values */
5 static integer c__2 = 2;
6 static integer c__1 = 1;
7 static doublereal c_b10 = 1.;
8 static doublereal c_b11 = 0.;
9 static integer c_n1 = -1;
11 /* Subroutine */ int dlaed7_(integer *icompq, integer *n, integer *qsiz,
12 integer *tlvls, integer *curlvl, integer *curpbm, doublereal *d__,
13 doublereal *q, integer *ldq, integer *indxq, doublereal *rho, integer
14 *cutpnt, doublereal *qstore, integer *qptr, integer *prmptr, integer *
15 perm, integer *givptr, integer *givcol, doublereal *givnum,
16 doublereal *work, integer *iwork, integer *info)
18 /* System generated locals */
19 integer q_dim1, q_offset, i__1, i__2;
21 /* Builtin functions */
22 integer pow_ii(integer *, integer *);
25 integer i__, k, n1, n2, is, iw, iz, iq2, ptr, ldq2, indx, curr;
26 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
27 integer *, doublereal *, doublereal *, integer *, doublereal *,
28 integer *, doublereal *, doublereal *, integer *);
30 extern /* Subroutine */ int dlaed8_(integer *, integer *, integer *,
31 integer *, doublereal *, doublereal *, integer *, integer *,
32 doublereal *, integer *, doublereal *, doublereal *, doublereal *,
33 integer *, doublereal *, integer *, integer *, integer *,
34 doublereal *, integer *, integer *, integer *), dlaed9_(integer *,
35 integer *, integer *, integer *, doublereal *, doublereal *,
36 integer *, doublereal *, doublereal *, doublereal *, doublereal *,
37 integer *, integer *), dlaeda_(integer *, integer *, integer *,
38 integer *, integer *, integer *, integer *, integer *, doublereal
39 *, doublereal *, integer *, doublereal *, doublereal *, integer *)
42 extern /* Subroutine */ int dlamrg_(integer *, integer *, doublereal *,
43 integer *, integer *, integer *), xerbla_(char *, integer *);
47 /* -- LAPACK routine (version 3.1) -- */
48 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
51 /* .. Scalar Arguments .. */
53 /* .. Array Arguments .. */
59 /* DLAED7 computes the updated eigensystem of a diagonal */
60 /* matrix after modification by a rank-one symmetric matrix. This */
61 /* routine is used only for the eigenproblem which requires all */
62 /* eigenvalues and optionally eigenvectors of a dense symmetric matrix */
63 /* that has been reduced to tridiagonal form. DLAED1 handles */
64 /* the case in which all eigenvalues and eigenvectors of a symmetric */
65 /* tridiagonal matrix are desired. */
67 /* T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out) */
69 /* where Z = Q'u, u is a vector of length N with ones in the */
70 /* CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */
72 /* The eigenvectors of the original matrix are stored in Q, and the */
73 /* eigenvalues are in D. The algorithm consists of three stages: */
75 /* The first stage consists of deflating the size of the problem */
76 /* when there are multiple eigenvalues or if there is a zero in */
77 /* the Z vector. For each such occurence the dimension of the */
78 /* secular equation problem is reduced by one. This stage is */
79 /* performed by the routine DLAED8. */
81 /* The second stage consists of calculating the updated */
82 /* eigenvalues. This is done by finding the roots of the secular */
83 /* equation via the routine DLAED4 (as called by DLAED9). */
84 /* This routine also calculates the eigenvectors of the current */
87 /* The final stage consists of computing the updated eigenvectors */
88 /* directly using the updated eigenvalues. The eigenvectors for */
89 /* the current problem are multiplied with the eigenvectors from */
90 /* the overall problem. */
95 /* ICOMPQ (input) INTEGER */
96 /* = 0: Compute eigenvalues only. */
97 /* = 1: Compute eigenvectors of original dense symmetric matrix */
98 /* also. On entry, Q contains the orthogonal matrix used */
99 /* to reduce the original matrix to tridiagonal form. */
101 /* N (input) INTEGER */
102 /* The dimension of the symmetric tridiagonal matrix. N >= 0. */
104 /* QSIZ (input) INTEGER */
105 /* The dimension of the orthogonal matrix used to reduce */
106 /* the full matrix to tridiagonal form. QSIZ >= N if ICOMPQ = 1. */
108 /* TLVLS (input) INTEGER */
109 /* The total number of merging levels in the overall divide and */
112 /* CURLVL (input) INTEGER */
113 /* The current level in the overall merge routine, */
114 /* 0 <= CURLVL <= TLVLS. */
116 /* CURPBM (input) INTEGER */
117 /* The current problem in the current level in the overall */
118 /* merge routine (counting from upper left to lower right). */
120 /* D (input/output) DOUBLE PRECISION array, dimension (N) */
121 /* On entry, the eigenvalues of the rank-1-perturbed matrix. */
122 /* On exit, the eigenvalues of the repaired matrix. */
124 /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */
125 /* On entry, the eigenvectors of the rank-1-perturbed matrix. */
126 /* On exit, the eigenvectors of the repaired tridiagonal matrix. */
128 /* LDQ (input) INTEGER */
129 /* The leading dimension of the array Q. LDQ >= max(1,N). */
131 /* INDXQ (output) INTEGER array, dimension (N) */
132 /* The permutation which will reintegrate the subproblem just */
133 /* solved back into sorted order, i.e., D( INDXQ( I = 1, N ) ) */
134 /* will be in ascending order. */
136 /* RHO (input) DOUBLE PRECISION */
137 /* The subdiagonal element used to create the rank-1 */
140 /* CUTPNT (input) INTEGER */
141 /* Contains the location of the last eigenvalue in the leading */
142 /* sub-matrix. min(1,N) <= CUTPNT <= N. */
144 /* QSTORE (input/output) DOUBLE PRECISION array, dimension (N**2+1) */
145 /* Stores eigenvectors of submatrices encountered during */
146 /* divide and conquer, packed together. QPTR points to */
147 /* beginning of the submatrices. */
149 /* QPTR (input/output) INTEGER array, dimension (N+2) */
150 /* List of indices pointing to beginning of submatrices stored */
151 /* in QSTORE. The submatrices are numbered starting at the */
152 /* bottom left of the divide and conquer tree, from left to */
153 /* right and bottom to top. */
155 /* PRMPTR (input) INTEGER array, dimension (N lg N) */
156 /* Contains a list of pointers which indicate where in PERM a */
157 /* level's permutation is stored. PRMPTR(i+1) - PRMPTR(i) */
158 /* indicates the size of the permutation and also the size of */
159 /* the full, non-deflated problem. */
161 /* PERM (input) INTEGER array, dimension (N lg N) */
162 /* Contains the permutations (from deflation and sorting) to be */
163 /* applied to each eigenblock. */
165 /* GIVPTR (input) INTEGER array, dimension (N lg N) */
166 /* Contains a list of pointers which indicate where in GIVCOL a */
167 /* level's Givens rotations are stored. GIVPTR(i+1) - GIVPTR(i) */
168 /* indicates the number of Givens rotations. */
170 /* GIVCOL (input) INTEGER array, dimension (2, N lg N) */
171 /* Each pair of numbers indicates a pair of columns to take place */
172 /* in a Givens rotation. */
174 /* GIVNUM (input) DOUBLE PRECISION array, dimension (2, N lg N) */
175 /* Each number indicates the S value to be used in the */
176 /* corresponding Givens rotation. */
178 /* WORK (workspace) DOUBLE PRECISION array, dimension (3*N+QSIZ*N) */
180 /* IWORK (workspace) INTEGER array, dimension (4*N) */
182 /* INFO (output) INTEGER */
183 /* = 0: successful exit. */
184 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
185 /* > 0: if INFO = 1, an eigenvalue did not converge */
187 /* Further Details */
188 /* =============== */
190 /* Based on contributions by */
191 /* Jeff Rutter, Computer Science Division, University of California */
192 /* at Berkeley, USA */
194 /* ===================================================================== */
196 /* .. Parameters .. */
198 /* .. Local Scalars .. */
200 /* .. External Subroutines .. */
202 /* .. Intrinsic Functions .. */
204 /* .. Executable Statements .. */
206 /* Test the input parameters. */
208 /* Parameter adjustments */
211 q_offset = 1 + q_dim1;
227 if (*icompq < 0 || *icompq > 1) {
231 } else if (*icompq == 1 && *qsiz < *n) {
233 } else if (*ldq < max(1,*n)) {
235 } else if (min(1,*n) > *cutpnt || *n < *cutpnt) {
240 xerbla_("DLAED7", &i__1);
244 /* Quick return if possible */
250 /* The following values are for bookkeeping purposes only. They are */
251 /* integer pointers which indicate the portion of the workspace */
252 /* used by a particular array in DLAED8 and DLAED9. */
264 is = iq2 + *n * ldq2;
271 /* Form the z-vector which consists of the last row of Q_1 and the */
272 /* first row of Q_2. */
274 ptr = pow_ii(&c__2, tlvls) + 1;
276 for (i__ = 1; i__ <= i__1; ++i__) {
278 ptr += pow_ii(&c__2, &i__2);
281 curr = ptr + *curpbm;
282 dlaeda_(n, tlvls, curlvl, curpbm, &prmptr[1], &perm[1], &givptr[1], &
283 givcol[3], &givnum[3], &qstore[1], &qptr[1], &work[iz], &work[iz
286 /* When solving the final problem, we no longer need the stored data, */
287 /* so we will overwrite the data from this level onto the previously */
288 /* used storage space. */
290 if (*curlvl == *tlvls) {
296 /* Sort and Deflate eigenvalues. */
298 dlaed8_(icompq, &k, n, qsiz, &d__[1], &q[q_offset], ldq, &indxq[1], rho,
299 cutpnt, &work[iz], &work[idlmda], &work[iq2], &ldq2, &work[iw], &
300 perm[prmptr[curr]], &givptr[curr + 1], &givcol[(givptr[curr] << 1)
301 + 1], &givnum[(givptr[curr] << 1) + 1], &iwork[indxp], &iwork[
303 prmptr[curr + 1] = prmptr[curr] + *n;
304 givptr[curr + 1] += givptr[curr];
306 /* Solve Secular Equation. */
309 dlaed9_(&k, &c__1, &k, n, &d__[1], &work[is], &k, rho, &work[idlmda],
310 &work[iw], &qstore[qptr[curr]], &k, info);
315 dgemm_("N", "N", qsiz, &k, &k, &c_b10, &work[iq2], &ldq2, &qstore[
316 qptr[curr]], &k, &c_b11, &q[q_offset], ldq);
318 /* Computing 2nd power */
320 qptr[curr + 1] = qptr[curr] + i__1 * i__1;
322 /* Prepare the INDXQ sorting permutation. */
326 dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]);
328 qptr[curr + 1] = qptr[curr];
330 for (i__ = 1; i__ <= i__1; ++i__) {