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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:40