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


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