slaed3.c
Go to the documentation of this file.
00001 /* slaed3.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__1 = 1;
00019 static real c_b22 = 1.f;
00020 static real c_b23 = 0.f;
00021 
00022 /* Subroutine */ int slaed3_(integer *k, integer *n, integer *n1, real *d__, 
00023         real *q, integer *ldq, real *rho, real *dlamda, real *q2, integer *
00024         indx, integer *ctot, real *w, real *s, integer *info)
00025 {
00026     /* System generated locals */
00027     integer q_dim1, q_offset, i__1, i__2;
00028     real r__1;
00029 
00030     /* Builtin functions */
00031     double sqrt(doublereal), r_sign(real *, real *);
00032 
00033     /* Local variables */
00034     integer i__, j, n2, n12, ii, n23, iq2;
00035     real temp;
00036     extern doublereal snrm2_(integer *, real *, integer *);
00037     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00038             integer *, real *, real *, integer *, real *, integer *, real *, 
00039             real *, integer *), scopy_(integer *, real *, 
00040             integer *, real *, integer *), slaed4_(integer *, integer *, real 
00041             *, real *, real *, real *, real *, integer *);
00042     extern doublereal slamc3_(real *, real *);
00043     extern /* Subroutine */ int xerbla_(char *, integer *), slacpy_(
00044             char *, integer *, integer *, real *, integer *, real *, integer *
00045 ), slaset_(char *, integer *, integer *, real *, real *, 
00046             real *, integer *);
00047 
00048 
00049 /*  -- LAPACK routine (version 3.2) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*  SLAED3 finds the roots of the secular equation, as defined by the */
00062 /*  values in D, W, and RHO, between 1 and K.  It makes the */
00063 /*  appropriate calls to SLAED4 and then updates the eigenvectors by */
00064 /*  multiplying the matrix of eigenvectors of the pair of eigensystems */
00065 /*  being combined by the matrix of eigenvectors of the K-by-K system */
00066 /*  which is solved here. */
00067 
00068 /*  This code makes very mild assumptions about floating point */
00069 /*  arithmetic. It will work on machines with a guard digit in */
00070 /*  add/subtract, or on those binary machines without guard digits */
00071 /*  which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */
00072 /*  It could conceivably fail on hexadecimal or decimal machines */
00073 /*  without guard digits, but we know of none. */
00074 
00075 /*  Arguments */
00076 /*  ========= */
00077 
00078 /*  K       (input) INTEGER */
00079 /*          The number of terms in the rational function to be solved by */
00080 /*          SLAED4.  K >= 0. */
00081 
00082 /*  N       (input) INTEGER */
00083 /*          The number of rows and columns in the Q matrix. */
00084 /*          N >= K (deflation may result in N>K). */
00085 
00086 /*  N1      (input) INTEGER */
00087 /*          The location of the last eigenvalue in the leading submatrix. */
00088 /*          min(1,N) <= N1 <= N/2. */
00089 
00090 /*  D       (output) REAL array, dimension (N) */
00091 /*          D(I) contains the updated eigenvalues for */
00092 /*          1 <= I <= K. */
00093 
00094 /*  Q       (output) REAL array, dimension (LDQ,N) */
00095 /*          Initially the first K columns are used as workspace. */
00096 /*          On output the columns 1 to K contain */
00097 /*          the updated eigenvectors. */
00098 
00099 /*  LDQ     (input) INTEGER */
00100 /*          The leading dimension of the array Q.  LDQ >= max(1,N). */
00101 
00102 /*  RHO     (input) REAL */
00103 /*          The value of the parameter in the rank one update equation. */
00104 /*          RHO >= 0 required. */
00105 
00106 /*  DLAMDA  (input/output) REAL array, dimension (K) */
00107 /*          The first K elements of this array contain the old roots */
00108 /*          of the deflated updating problem.  These are the poles */
00109 /*          of the secular equation. May be changed on output by */
00110 /*          having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */
00111 /*          Cray-2, or Cray C-90, as described above. */
00112 
00113 /*  Q2      (input) REAL array, dimension (LDQ2, N) */
00114 /*          The first K columns of this matrix contain the non-deflated */
00115 /*          eigenvectors for the split problem. */
00116 
00117 /*  INDX    (input) INTEGER array, dimension (N) */
00118 /*          The permutation used to arrange the columns of the deflated */
00119 /*          Q matrix into three groups (see SLAED2). */
00120 /*          The rows of the eigenvectors found by SLAED4 must be likewise */
00121 /*          permuted before the matrix multiply can take place. */
00122 
00123 /*  CTOT    (input) INTEGER array, dimension (4) */
00124 /*          A count of the total number of the various types of columns */
00125 /*          in Q, as described in INDX.  The fourth column type is any */
00126 /*          column which has been deflated. */
00127 
00128 /*  W       (input/output) REAL array, dimension (K) */
00129 /*          The first K elements of this array contain the components */
00130 /*          of the deflation-adjusted updating vector. Destroyed on */
00131 /*          output. */
00132 
00133 /*  S       (workspace) REAL array, dimension (N1 + 1)*K */
00134 /*          Will contain the eigenvectors of the repaired matrix which */
00135 /*          will be multiplied by the previously accumulated eigenvectors */
00136 /*          to update the system. */
00137 
00138 /*  LDS     (input) INTEGER */
00139 /*          The leading dimension of S.  LDS >= max(1,K). */
00140 
00141 /*  INFO    (output) INTEGER */
00142 /*          = 0:  successful exit. */
00143 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00144 /*          > 0:  if INFO = 1, an eigenvalue did not converge */
00145 
00146 /*  Further Details */
00147 /*  =============== */
00148 
00149 /*  Based on contributions by */
00150 /*     Jeff Rutter, Computer Science Division, University of California */
00151 /*     at Berkeley, USA */
00152 /*  Modified by Francoise Tisseur, University of Tennessee. */
00153 
00154 /*  ===================================================================== */
00155 
00156 /*     .. Parameters .. */
00157 /*     .. */
00158 /*     .. Local Scalars .. */
00159 /*     .. */
00160 /*     .. External Functions .. */
00161 /*     .. */
00162 /*     .. External Subroutines .. */
00163 /*     .. */
00164 /*     .. Intrinsic Functions .. */
00165 /*     .. */
00166 /*     .. Executable Statements .. */
00167 
00168 /*     Test the input parameters. */
00169 
00170     /* Parameter adjustments */
00171     --d__;
00172     q_dim1 = *ldq;
00173     q_offset = 1 + q_dim1;
00174     q -= q_offset;
00175     --dlamda;
00176     --q2;
00177     --indx;
00178     --ctot;
00179     --w;
00180     --s;
00181 
00182     /* Function Body */
00183     *info = 0;
00184 
00185     if (*k < 0) {
00186         *info = -1;
00187     } else if (*n < *k) {
00188         *info = -2;
00189     } else if (*ldq < max(1,*n)) {
00190         *info = -6;
00191     }
00192     if (*info != 0) {
00193         i__1 = -(*info);
00194         xerbla_("SLAED3", &i__1);
00195         return 0;
00196     }
00197 
00198 /*     Quick return if possible */
00199 
00200     if (*k == 0) {
00201         return 0;
00202     }
00203 
00204 /*     Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */
00205 /*     be computed with high relative accuracy (barring over/underflow). */
00206 /*     This is a problem on machines without a guard digit in */
00207 /*     add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
00208 /*     The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */
00209 /*     which on any of these machines zeros out the bottommost */
00210 /*     bit of DLAMDA(I) if it is 1; this makes the subsequent */
00211 /*     subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */
00212 /*     occurs. On binary machines with a guard digit (almost all */
00213 /*     machines) it does not change DLAMDA(I) at all. On hexadecimal */
00214 /*     and decimal machines with a guard digit, it slightly */
00215 /*     changes the bottommost bits of DLAMDA(I). It does not account */
00216 /*     for hexadecimal or decimal machines without guard digits */
00217 /*     (we know of none). We use a subroutine call to compute */
00218 /*     2*DLAMBDA(I) to prevent optimizing compilers from eliminating */
00219 /*     this code. */
00220 
00221     i__1 = *k;
00222     for (i__ = 1; i__ <= i__1; ++i__) {
00223         dlamda[i__] = slamc3_(&dlamda[i__], &dlamda[i__]) - dlamda[i__];
00224 /* L10: */
00225     }
00226 
00227     i__1 = *k;
00228     for (j = 1; j <= i__1; ++j) {
00229         slaed4_(k, &j, &dlamda[1], &w[1], &q[j * q_dim1 + 1], rho, &d__[j], 
00230                 info);
00231 
00232 /*        If the zero finder fails, the computation is terminated. */
00233 
00234         if (*info != 0) {
00235             goto L120;
00236         }
00237 /* L20: */
00238     }
00239 
00240     if (*k == 1) {
00241         goto L110;
00242     }
00243     if (*k == 2) {
00244         i__1 = *k;
00245         for (j = 1; j <= i__1; ++j) {
00246             w[1] = q[j * q_dim1 + 1];
00247             w[2] = q[j * q_dim1 + 2];
00248             ii = indx[1];
00249             q[j * q_dim1 + 1] = w[ii];
00250             ii = indx[2];
00251             q[j * q_dim1 + 2] = w[ii];
00252 /* L30: */
00253         }
00254         goto L110;
00255     }
00256 
00257 /*     Compute updated W. */
00258 
00259     scopy_(k, &w[1], &c__1, &s[1], &c__1);
00260 
00261 /*     Initialize W(I) = Q(I,I) */
00262 
00263     i__1 = *ldq + 1;
00264     scopy_(k, &q[q_offset], &i__1, &w[1], &c__1);
00265     i__1 = *k;
00266     for (j = 1; j <= i__1; ++j) {
00267         i__2 = j - 1;
00268         for (i__ = 1; i__ <= i__2; ++i__) {
00269             w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
00270 /* L40: */
00271         }
00272         i__2 = *k;
00273         for (i__ = j + 1; i__ <= i__2; ++i__) {
00274             w[i__] *= q[i__ + j * q_dim1] / (dlamda[i__] - dlamda[j]);
00275 /* L50: */
00276         }
00277 /* L60: */
00278     }
00279     i__1 = *k;
00280     for (i__ = 1; i__ <= i__1; ++i__) {
00281         r__1 = sqrt(-w[i__]);
00282         w[i__] = r_sign(&r__1, &s[i__]);
00283 /* L70: */
00284     }
00285 
00286 /*     Compute eigenvectors of the modified rank-1 modification. */
00287 
00288     i__1 = *k;
00289     for (j = 1; j <= i__1; ++j) {
00290         i__2 = *k;
00291         for (i__ = 1; i__ <= i__2; ++i__) {
00292             s[i__] = w[i__] / q[i__ + j * q_dim1];
00293 /* L80: */
00294         }
00295         temp = snrm2_(k, &s[1], &c__1);
00296         i__2 = *k;
00297         for (i__ = 1; i__ <= i__2; ++i__) {
00298             ii = indx[i__];
00299             q[i__ + j * q_dim1] = s[ii] / temp;
00300 /* L90: */
00301         }
00302 /* L100: */
00303     }
00304 
00305 /*     Compute the updated eigenvectors. */
00306 
00307 L110:
00308 
00309     n2 = *n - *n1;
00310     n12 = ctot[1] + ctot[2];
00311     n23 = ctot[2] + ctot[3];
00312 
00313     slacpy_("A", &n23, k, &q[ctot[1] + 1 + q_dim1], ldq, &s[1], &n23);
00314     iq2 = *n1 * n12 + 1;
00315     if (n23 != 0) {
00316         sgemm_("N", "N", &n2, k, &n23, &c_b22, &q2[iq2], &n2, &s[1], &n23, &
00317                 c_b23, &q[*n1 + 1 + q_dim1], ldq);
00318     } else {
00319         slaset_("A", &n2, k, &c_b23, &c_b23, &q[*n1 + 1 + q_dim1], ldq);
00320     }
00321 
00322     slacpy_("A", &n12, k, &q[q_offset], ldq, &s[1], &n12);
00323     if (n12 != 0) {
00324         sgemm_("N", "N", n1, k, &n12, &c_b22, &q2[1], n1, &s[1], &n12, &c_b23, 
00325                  &q[q_offset], ldq);
00326     } else {
00327         slaset_("A", n1, k, &c_b23, &c_b23, &q[q_dim1 + 1], ldq);
00328     }
00329 
00330 
00331 L120:
00332     return 0;
00333 
00334 /*     End of SLAED3 */
00335 
00336 } /* slaed3_ */


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