dlaed7.c
Go to the documentation of this file.
00001 /* dlaed7.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__2 = 2;
00019 static integer c__1 = 1;
00020 static doublereal c_b10 = 1.;
00021 static doublereal c_b11 = 0.;
00022 static integer c_n1 = -1;
00023 
00024 /* Subroutine */ int dlaed7_(integer *icompq, integer *n, integer *qsiz, 
00025         integer *tlvls, integer *curlvl, integer *curpbm, doublereal *d__, 
00026         doublereal *q, integer *ldq, integer *indxq, doublereal *rho, integer 
00027         *cutpnt, doublereal *qstore, integer *qptr, integer *prmptr, integer *
00028         perm, integer *givptr, integer *givcol, doublereal *givnum, 
00029         doublereal *work, integer *iwork, integer *info)
00030 {
00031     /* System generated locals */
00032     integer q_dim1, q_offset, i__1, i__2;
00033 
00034     /* Builtin functions */
00035     integer pow_ii(integer *, integer *);
00036 
00037     /* Local variables */
00038     integer i__, k, n1, n2, is, iw, iz, iq2, ptr, ldq2, indx, curr;
00039     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00040             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00041             integer *, doublereal *, doublereal *, integer *);
00042     integer indxc, indxp;
00043     extern /* Subroutine */ int dlaed8_(integer *, integer *, integer *, 
00044             integer *, doublereal *, doublereal *, integer *, integer *, 
00045             doublereal *, integer *, doublereal *, doublereal *, doublereal *, 
00046              integer *, doublereal *, integer *, integer *, integer *, 
00047             doublereal *, integer *, integer *, integer *), dlaed9_(integer *, 
00048              integer *, integer *, integer *, doublereal *, doublereal *, 
00049             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00050              integer *, integer *), dlaeda_(integer *, integer *, integer *, 
00051             integer *, integer *, integer *, integer *, integer *, doublereal 
00052             *, doublereal *, integer *, doublereal *, doublereal *, integer *)
00053             ;
00054     integer idlmda;
00055     extern /* Subroutine */ int dlamrg_(integer *, integer *, doublereal *, 
00056             integer *, integer *, integer *), xerbla_(char *, integer *);
00057     integer coltyp;
00058 
00059 
00060 /*  -- LAPACK routine (version 3.2) -- */
00061 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00062 /*     November 2006 */
00063 
00064 /*     .. Scalar Arguments .. */
00065 /*     .. */
00066 /*     .. Array Arguments .. */
00067 /*     .. */
00068 
00069 /*  Purpose */
00070 /*  ======= */
00071 
00072 /*  DLAED7 computes the updated eigensystem of a diagonal */
00073 /*  matrix after modification by a rank-one symmetric matrix. This */
00074 /*  routine is used only for the eigenproblem which requires all */
00075 /*  eigenvalues and optionally eigenvectors of a dense symmetric matrix */
00076 /*  that has been reduced to tridiagonal form.  DLAED1 handles */
00077 /*  the case in which all eigenvalues and eigenvectors of a symmetric */
00078 /*  tridiagonal matrix are desired. */
00079 
00080 /*    T = Q(in) ( D(in) + RHO * Z*Z' ) Q'(in) = Q(out) * D(out) * Q'(out) */
00081 
00082 /*     where Z = Q'u, u is a vector of length N with ones in the */
00083 /*     CUTPNT and CUTPNT + 1 th elements and zeros elsewhere. */
00084 
00085 /*     The eigenvectors of the original matrix are stored in Q, and the */
00086 /*     eigenvalues are in D.  The algorithm consists of three stages: */
00087 
00088 /*        The first stage consists of deflating the size of the problem */
00089 /*        when there are multiple eigenvalues or if there is a zero in */
00090 /*        the Z vector.  For each such occurence the dimension of the */
00091 /*        secular equation problem is reduced by one.  This stage is */
00092 /*        performed by the routine DLAED8. */
00093 
00094 /*        The second stage consists of calculating the updated */
00095 /*        eigenvalues. This is done by finding the roots of the secular */
00096 /*        equation via the routine DLAED4 (as called by DLAED9). */
00097 /*        This routine also calculates the eigenvectors of the current */
00098 /*        problem. */
00099 
00100 /*        The final stage consists of computing the updated eigenvectors */
00101 /*        directly using the updated eigenvalues.  The eigenvectors for */
00102 /*        the current problem are multiplied with the eigenvectors from */
00103 /*        the overall problem. */
00104 
00105 /*  Arguments */
00106 /*  ========= */
00107 
00108 /*  ICOMPQ  (input) INTEGER */
00109 /*          = 0:  Compute eigenvalues only. */
00110 /*          = 1:  Compute eigenvectors of original dense symmetric matrix */
00111 /*                also.  On entry, Q contains the orthogonal matrix used */
00112 /*                to reduce the original matrix to tridiagonal form. */
00113 
00114 /*  N      (input) INTEGER */
00115 /*         The dimension of the symmetric tridiagonal matrix.  N >= 0. */
00116 
00117 /*  QSIZ   (input) INTEGER */
00118 /*         The dimension of the orthogonal matrix used to reduce */
00119 /*         the full matrix to tridiagonal form.  QSIZ >= N if ICOMPQ = 1. */
00120 
00121 /*  TLVLS  (input) INTEGER */
00122 /*         The total number of merging levels in the overall divide and */
00123 /*         conquer tree. */
00124 
00125 /*  CURLVL (input) INTEGER */
00126 /*         The current level in the overall merge routine, */
00127 /*         0 <= CURLVL <= TLVLS. */
00128 
00129 /*  CURPBM (input) INTEGER */
00130 /*         The current problem in the current level in the overall */
00131 /*         merge routine (counting from upper left to lower right). */
00132 
00133 /*  D      (input/output) DOUBLE PRECISION array, dimension (N) */
00134 /*         On entry, the eigenvalues of the rank-1-perturbed matrix. */
00135 /*         On exit, the eigenvalues of the repaired matrix. */
00136 
00137 /*  Q      (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */
00138 /*         On entry, the eigenvectors of the rank-1-perturbed matrix. */
00139 /*         On exit, the eigenvectors of the repaired tridiagonal matrix. */
00140 
00141 /*  LDQ    (input) INTEGER */
00142 /*         The leading dimension of the array Q.  LDQ >= max(1,N). */
00143 
00144 /*  INDXQ  (output) INTEGER array, dimension (N) */
00145 /*         The permutation which will reintegrate the subproblem just */
00146 /*         solved back into sorted order, i.e., D( INDXQ( I = 1, N ) ) */
00147 /*         will be in ascending order. */
00148 
00149 /*  RHO    (input) DOUBLE PRECISION */
00150 /*         The subdiagonal element used to create the rank-1 */
00151 /*         modification. */
00152 
00153 /*  CUTPNT (input) INTEGER */
00154 /*         Contains the location of the last eigenvalue in the leading */
00155 /*         sub-matrix.  min(1,N) <= CUTPNT <= N. */
00156 
00157 /*  QSTORE (input/output) DOUBLE PRECISION array, dimension (N**2+1) */
00158 /*         Stores eigenvectors of submatrices encountered during */
00159 /*         divide and conquer, packed together. QPTR points to */
00160 /*         beginning of the submatrices. */
00161 
00162 /*  QPTR   (input/output) INTEGER array, dimension (N+2) */
00163 /*         List of indices pointing to beginning of submatrices stored */
00164 /*         in QSTORE. The submatrices are numbered starting at the */
00165 /*         bottom left of the divide and conquer tree, from left to */
00166 /*         right and bottom to top. */
00167 
00168 /*  PRMPTR (input) INTEGER array, dimension (N lg N) */
00169 /*         Contains a list of pointers which indicate where in PERM a */
00170 /*         level's permutation is stored.  PRMPTR(i+1) - PRMPTR(i) */
00171 /*         indicates the size of the permutation and also the size of */
00172 /*         the full, non-deflated problem. */
00173 
00174 /*  PERM   (input) INTEGER array, dimension (N lg N) */
00175 /*         Contains the permutations (from deflation and sorting) to be */
00176 /*         applied to each eigenblock. */
00177 
00178 /*  GIVPTR (input) INTEGER array, dimension (N lg N) */
00179 /*         Contains a list of pointers which indicate where in GIVCOL a */
00180 /*         level's Givens rotations are stored.  GIVPTR(i+1) - GIVPTR(i) */
00181 /*         indicates the number of Givens rotations. */
00182 
00183 /*  GIVCOL (input) INTEGER array, dimension (2, N lg N) */
00184 /*         Each pair of numbers indicates a pair of columns to take place */
00185 /*         in a Givens rotation. */
00186 
00187 /*  GIVNUM (input) DOUBLE PRECISION array, dimension (2, N lg N) */
00188 /*         Each number indicates the S value to be used in the */
00189 /*         corresponding Givens rotation. */
00190 
00191 /*  WORK   (workspace) DOUBLE PRECISION array, dimension (3*N+QSIZ*N) */
00192 
00193 /*  IWORK  (workspace) INTEGER array, dimension (4*N) */
00194 
00195 /*  INFO   (output) INTEGER */
00196 /*          = 0:  successful exit. */
00197 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00198 /*          > 0:  if INFO = 1, an eigenvalue did not converge */
00199 
00200 /*  Further Details */
00201 /*  =============== */
00202 
00203 /*  Based on contributions by */
00204 /*     Jeff Rutter, Computer Science Division, University of California */
00205 /*     at Berkeley, USA */
00206 
00207 /*  ===================================================================== */
00208 
00209 /*     .. Parameters .. */
00210 /*     .. */
00211 /*     .. Local Scalars .. */
00212 /*     .. */
00213 /*     .. External Subroutines .. */
00214 /*     .. */
00215 /*     .. Intrinsic Functions .. */
00216 /*     .. */
00217 /*     .. Executable Statements .. */
00218 
00219 /*     Test the input parameters. */
00220 
00221     /* Parameter adjustments */
00222     --d__;
00223     q_dim1 = *ldq;
00224     q_offset = 1 + q_dim1;
00225     q -= q_offset;
00226     --indxq;
00227     --qstore;
00228     --qptr;
00229     --prmptr;
00230     --perm;
00231     --givptr;
00232     givcol -= 3;
00233     givnum -= 3;
00234     --work;
00235     --iwork;
00236 
00237     /* Function Body */
00238     *info = 0;
00239 
00240     if (*icompq < 0 || *icompq > 1) {
00241         *info = -1;
00242     } else if (*n < 0) {
00243         *info = -2;
00244     } else if (*icompq == 1 && *qsiz < *n) {
00245         *info = -4;
00246     } else if (*ldq < max(1,*n)) {
00247         *info = -9;
00248     } else if (min(1,*n) > *cutpnt || *n < *cutpnt) {
00249         *info = -12;
00250     }
00251     if (*info != 0) {
00252         i__1 = -(*info);
00253         xerbla_("DLAED7", &i__1);
00254         return 0;
00255     }
00256 
00257 /*     Quick return if possible */
00258 
00259     if (*n == 0) {
00260         return 0;
00261     }
00262 
00263 /*     The following values are for bookkeeping purposes only.  They are */
00264 /*     integer pointers which indicate the portion of the workspace */
00265 /*     used by a particular array in DLAED8 and DLAED9. */
00266 
00267     if (*icompq == 1) {
00268         ldq2 = *qsiz;
00269     } else {
00270         ldq2 = *n;
00271     }
00272 
00273     iz = 1;
00274     idlmda = iz + *n;
00275     iw = idlmda + *n;
00276     iq2 = iw + *n;
00277     is = iq2 + *n * ldq2;
00278 
00279     indx = 1;
00280     indxc = indx + *n;
00281     coltyp = indxc + *n;
00282     indxp = coltyp + *n;
00283 
00284 /*     Form the z-vector which consists of the last row of Q_1 and the */
00285 /*     first row of Q_2. */
00286 
00287     ptr = pow_ii(&c__2, tlvls) + 1;
00288     i__1 = *curlvl - 1;
00289     for (i__ = 1; i__ <= i__1; ++i__) {
00290         i__2 = *tlvls - i__;
00291         ptr += pow_ii(&c__2, &i__2);
00292 /* L10: */
00293     }
00294     curr = ptr + *curpbm;
00295     dlaeda_(n, tlvls, curlvl, curpbm, &prmptr[1], &perm[1], &givptr[1], &
00296             givcol[3], &givnum[3], &qstore[1], &qptr[1], &work[iz], &work[iz 
00297             + *n], info);
00298 
00299 /*     When solving the final problem, we no longer need the stored data, */
00300 /*     so we will overwrite the data from this level onto the previously */
00301 /*     used storage space. */
00302 
00303     if (*curlvl == *tlvls) {
00304         qptr[curr] = 1;
00305         prmptr[curr] = 1;
00306         givptr[curr] = 1;
00307     }
00308 
00309 /*     Sort and Deflate eigenvalues. */
00310 
00311     dlaed8_(icompq, &k, n, qsiz, &d__[1], &q[q_offset], ldq, &indxq[1], rho, 
00312             cutpnt, &work[iz], &work[idlmda], &work[iq2], &ldq2, &work[iw], &
00313             perm[prmptr[curr]], &givptr[curr + 1], &givcol[(givptr[curr] << 1)
00314              + 1], &givnum[(givptr[curr] << 1) + 1], &iwork[indxp], &iwork[
00315             indx], info);
00316     prmptr[curr + 1] = prmptr[curr] + *n;
00317     givptr[curr + 1] += givptr[curr];
00318 
00319 /*     Solve Secular Equation. */
00320 
00321     if (k != 0) {
00322         dlaed9_(&k, &c__1, &k, n, &d__[1], &work[is], &k, rho, &work[idlmda], 
00323                 &work[iw], &qstore[qptr[curr]], &k, info);
00324         if (*info != 0) {
00325             goto L30;
00326         }
00327         if (*icompq == 1) {
00328             dgemm_("N", "N", qsiz, &k, &k, &c_b10, &work[iq2], &ldq2, &qstore[
00329                     qptr[curr]], &k, &c_b11, &q[q_offset], ldq);
00330         }
00331 /* Computing 2nd power */
00332         i__1 = k;
00333         qptr[curr + 1] = qptr[curr] + i__1 * i__1;
00334 
00335 /*     Prepare the INDXQ sorting permutation. */
00336 
00337         n1 = k;
00338         n2 = *n - k;
00339         dlamrg_(&n1, &n2, &d__[1], &c__1, &c_n1, &indxq[1]);
00340     } else {
00341         qptr[curr + 1] = qptr[curr];
00342         i__1 = *n;
00343         for (i__ = 1; i__ <= i__1; ++i__) {
00344             indxq[i__] = i__;
00345 /* L20: */
00346         }
00347     }
00348 
00349 L30:
00350     return 0;
00351 
00352 /*     End of DLAED7 */
00353 
00354 } /* dlaed7_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:46