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


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