dlaqr2.c
Go to the documentation of this file.
00001 /* dlaqr2.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 integer c_n1 = -1;
00020 static doublereal c_b12 = 0.;
00021 static doublereal c_b13 = 1.;
00022 static logical c_true = TRUE_;
00023 
00024 /* Subroutine */ int dlaqr2_(logical *wantt, logical *wantz, integer *n, 
00025         integer *ktop, integer *kbot, integer *nw, doublereal *h__, integer *
00026         ldh, integer *iloz, integer *ihiz, doublereal *z__, integer *ldz, 
00027         integer *ns, integer *nd, doublereal *sr, doublereal *si, doublereal *
00028         v, integer *ldv, integer *nh, doublereal *t, integer *ldt, integer *
00029         nv, doublereal *wv, integer *ldwv, doublereal *work, integer *lwork)
00030 {
00031     /* System generated locals */
00032     integer h_dim1, h_offset, t_dim1, t_offset, v_dim1, v_offset, wv_dim1, 
00033             wv_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4;
00034     doublereal d__1, d__2, d__3, d__4, d__5, d__6;
00035 
00036     /* Builtin functions */
00037     double sqrt(doublereal);
00038 
00039     /* Local variables */
00040     integer i__, j, k;
00041     doublereal s, aa, bb, cc, dd, cs, sn;
00042     integer jw;
00043     doublereal evi, evk, foo;
00044     integer kln;
00045     doublereal tau, ulp;
00046     integer lwk1, lwk2;
00047     doublereal beta;
00048     integer kend, kcol, info, ifst, ilst, ltop, krow;
00049     extern /* Subroutine */ int dlarf_(char *, integer *, integer *, 
00050             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00051             doublereal *), dgemm_(char *, char *, integer *, integer *
00052 , integer *, doublereal *, doublereal *, integer *, doublereal *, 
00053             integer *, doublereal *, doublereal *, integer *);
00054     logical bulge;
00055     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00056             doublereal *, integer *);
00057     integer infqr, kwtop;
00058     extern /* Subroutine */ int dlanv2_(doublereal *, doublereal *, 
00059             doublereal *, doublereal *, doublereal *, doublereal *, 
00060             doublereal *, doublereal *, doublereal *, doublereal *), dlabad_(
00061             doublereal *, doublereal *);
00062     extern doublereal dlamch_(char *);
00063     extern /* Subroutine */ int dgehrd_(integer *, integer *, integer *, 
00064             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00065             integer *), dlarfg_(integer *, doublereal *, doublereal *, 
00066             integer *, doublereal *), dlahqr_(logical *, logical *, integer *, 
00067              integer *, integer *, doublereal *, integer *, doublereal *, 
00068             doublereal *, integer *, integer *, doublereal *, integer *, 
00069             integer *), dlacpy_(char *, integer *, integer *, doublereal *, 
00070             integer *, doublereal *, integer *);
00071     doublereal safmin;
00072     extern /* Subroutine */ int dlaset_(char *, integer *, integer *, 
00073             doublereal *, doublereal *, doublereal *, integer *);
00074     doublereal safmax;
00075     extern /* Subroutine */ int dtrexc_(char *, integer *, doublereal *, 
00076             integer *, doublereal *, integer *, integer *, integer *, 
00077             doublereal *, integer *), dormhr_(char *, char *, integer 
00078             *, integer *, integer *, integer *, doublereal *, integer *, 
00079             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00080             integer *);
00081     logical sorted;
00082     doublereal smlnum;
00083     integer lwkopt;
00084 
00085 
00086 /*  -- LAPACK auxiliary routine (version 3.2.1)                        -- */
00087 /*     Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
00088 /*  -- April 2009                                                      -- */
00089 
00090 /*     .. Scalar Arguments .. */
00091 /*     .. */
00092 /*     .. Array Arguments .. */
00093 /*     .. */
00094 
00095 /*     This subroutine is identical to DLAQR3 except that it avoids */
00096 /*     recursion by calling DLAHQR instead of DLAQR4. */
00097 
00098 
00099 /*     ****************************************************************** */
00100 /*     Aggressive early deflation: */
00101 
00102 /*     This subroutine accepts as input an upper Hessenberg matrix */
00103 /*     H and performs an orthogonal similarity transformation */
00104 /*     designed to detect and deflate fully converged eigenvalues from */
00105 /*     a trailing principal submatrix.  On output H has been over- */
00106 /*     written by a new Hessenberg matrix that is a perturbation of */
00107 /*     an orthogonal similarity transformation of H.  It is to be */
00108 /*     hoped that the final version of H has many zero subdiagonal */
00109 /*     entries. */
00110 
00111 /*     ****************************************************************** */
00112 /*     WANTT   (input) LOGICAL */
00113 /*          If .TRUE., then the Hessenberg matrix H is fully updated */
00114 /*          so that the quasi-triangular Schur factor may be */
00115 /*          computed (in cooperation with the calling subroutine). */
00116 /*          If .FALSE., then only enough of H is updated to preserve */
00117 /*          the eigenvalues. */
00118 
00119 /*     WANTZ   (input) LOGICAL */
00120 /*          If .TRUE., then the orthogonal matrix Z is updated so */
00121 /*          so that the orthogonal Schur factor may be computed */
00122 /*          (in cooperation with the calling subroutine). */
00123 /*          If .FALSE., then Z is not referenced. */
00124 
00125 /*     N       (input) INTEGER */
00126 /*          The order of the matrix H and (if WANTZ is .TRUE.) the */
00127 /*          order of the orthogonal matrix Z. */
00128 
00129 /*     KTOP    (input) INTEGER */
00130 /*          It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0. */
00131 /*          KBOT and KTOP together determine an isolated block */
00132 /*          along the diagonal of the Hessenberg matrix. */
00133 
00134 /*     KBOT    (input) INTEGER */
00135 /*          It is assumed without a check that either */
00136 /*          KBOT = N or H(KBOT+1,KBOT)=0.  KBOT and KTOP together */
00137 /*          determine an isolated block along the diagonal of the */
00138 /*          Hessenberg matrix. */
00139 
00140 /*     NW      (input) INTEGER */
00141 /*          Deflation window size.  1 .LE. NW .LE. (KBOT-KTOP+1). */
00142 
00143 /*     H       (input/output) DOUBLE PRECISION array, dimension (LDH,N) */
00144 /*          On input the initial N-by-N section of H stores the */
00145 /*          Hessenberg matrix undergoing aggressive early deflation. */
00146 /*          On output H has been transformed by an orthogonal */
00147 /*          similarity transformation, perturbed, and the returned */
00148 /*          to Hessenberg form that (it is to be hoped) has some */
00149 /*          zero subdiagonal entries. */
00150 
00151 /*     LDH     (input) integer */
00152 /*          Leading dimension of H just as declared in the calling */
00153 /*          subroutine.  N .LE. LDH */
00154 
00155 /*     ILOZ    (input) INTEGER */
00156 /*     IHIZ    (input) INTEGER */
00157 /*          Specify the rows of Z to which transformations must be */
00158 /*          applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N. */
00159 
00160 /*     Z       (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */
00161 /*          IF WANTZ is .TRUE., then on output, the orthogonal */
00162 /*          similarity transformation mentioned above has been */
00163 /*          accumulated into Z(ILOZ:IHIZ,ILO:IHI) from the right. */
00164 /*          If WANTZ is .FALSE., then Z is unreferenced. */
00165 
00166 /*     LDZ     (input) integer */
00167 /*          The leading dimension of Z just as declared in the */
00168 /*          calling subroutine.  1 .LE. LDZ. */
00169 
00170 /*     NS      (output) integer */
00171 /*          The number of unconverged (ie approximate) eigenvalues */
00172 /*          returned in SR and SI that may be used as shifts by the */
00173 /*          calling subroutine. */
00174 
00175 /*     ND      (output) integer */
00176 /*          The number of converged eigenvalues uncovered by this */
00177 /*          subroutine. */
00178 
00179 /*     SR      (output) DOUBLE PRECISION array, dimension KBOT */
00180 /*     SI      (output) DOUBLE PRECISION array, dimension KBOT */
00181 /*          On output, the real and imaginary parts of approximate */
00182 /*          eigenvalues that may be used for shifts are stored in */
00183 /*          SR(KBOT-ND-NS+1) through SR(KBOT-ND) and */
00184 /*          SI(KBOT-ND-NS+1) through SI(KBOT-ND), respectively. */
00185 /*          The real and imaginary parts of converged eigenvalues */
00186 /*          are stored in SR(KBOT-ND+1) through SR(KBOT) and */
00187 /*          SI(KBOT-ND+1) through SI(KBOT), respectively. */
00188 
00189 /*     V       (workspace) DOUBLE PRECISION array, dimension (LDV,NW) */
00190 /*          An NW-by-NW work array. */
00191 
00192 /*     LDV     (input) integer scalar */
00193 /*          The leading dimension of V just as declared in the */
00194 /*          calling subroutine.  NW .LE. LDV */
00195 
00196 /*     NH      (input) integer scalar */
00197 /*          The number of columns of T.  NH.GE.NW. */
00198 
00199 /*     T       (workspace) DOUBLE PRECISION array, dimension (LDT,NW) */
00200 
00201 /*     LDT     (input) integer */
00202 /*          The leading dimension of T just as declared in the */
00203 /*          calling subroutine.  NW .LE. LDT */
00204 
00205 /*     NV      (input) integer */
00206 /*          The number of rows of work array WV available for */
00207 /*          workspace.  NV.GE.NW. */
00208 
00209 /*     WV      (workspace) DOUBLE PRECISION array, dimension (LDWV,NW) */
00210 
00211 /*     LDWV    (input) integer */
00212 /*          The leading dimension of W just as declared in the */
00213 /*          calling subroutine.  NW .LE. LDV */
00214 
00215 /*     WORK    (workspace) DOUBLE PRECISION array, dimension LWORK. */
00216 /*          On exit, WORK(1) is set to an estimate of the optimal value */
00217 /*          of LWORK for the given values of N, NW, KTOP and KBOT. */
00218 
00219 /*     LWORK   (input) integer */
00220 /*          The dimension of the work array WORK.  LWORK = 2*NW */
00221 /*          suffices, but greater efficiency may result from larger */
00222 /*          values of LWORK. */
00223 
00224 /*          If LWORK = -1, then a workspace query is assumed; DLAQR2 */
00225 /*          only estimates the optimal workspace size for the given */
00226 /*          values of N, NW, KTOP and KBOT.  The estimate is returned */
00227 /*          in WORK(1).  No error message related to LWORK is issued */
00228 /*          by XERBLA.  Neither H nor Z are accessed. */
00229 
00230 /*     ================================================================ */
00231 /*     Based on contributions by */
00232 /*        Karen Braman and Ralph Byers, Department of Mathematics, */
00233 /*        University of Kansas, USA */
00234 
00235 /*     ================================================================ */
00236 /*     .. Parameters .. */
00237 /*     .. */
00238 /*     .. Local Scalars .. */
00239 /*     .. */
00240 /*     .. External Functions .. */
00241 /*     .. */
00242 /*     .. External Subroutines .. */
00243 /*     .. */
00244 /*     .. Intrinsic Functions .. */
00245 /*     .. */
00246 /*     .. Executable Statements .. */
00247 
00248 /*     ==== Estimate optimal workspace. ==== */
00249 
00250     /* Parameter adjustments */
00251     h_dim1 = *ldh;
00252     h_offset = 1 + h_dim1;
00253     h__ -= h_offset;
00254     z_dim1 = *ldz;
00255     z_offset = 1 + z_dim1;
00256     z__ -= z_offset;
00257     --sr;
00258     --si;
00259     v_dim1 = *ldv;
00260     v_offset = 1 + v_dim1;
00261     v -= v_offset;
00262     t_dim1 = *ldt;
00263     t_offset = 1 + t_dim1;
00264     t -= t_offset;
00265     wv_dim1 = *ldwv;
00266     wv_offset = 1 + wv_dim1;
00267     wv -= wv_offset;
00268     --work;
00269 
00270     /* Function Body */
00271 /* Computing MIN */
00272     i__1 = *nw, i__2 = *kbot - *ktop + 1;
00273     jw = min(i__1,i__2);
00274     if (jw <= 2) {
00275         lwkopt = 1;
00276     } else {
00277 
00278 /*        ==== Workspace query call to DGEHRD ==== */
00279 
00280         i__1 = jw - 1;
00281         dgehrd_(&jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], &work[1], &
00282                 c_n1, &info);
00283         lwk1 = (integer) work[1];
00284 
00285 /*        ==== Workspace query call to DORMHR ==== */
00286 
00287         i__1 = jw - 1;
00288         dormhr_("R", "N", &jw, &jw, &c__1, &i__1, &t[t_offset], ldt, &work[1], 
00289                  &v[v_offset], ldv, &work[1], &c_n1, &info);
00290         lwk2 = (integer) work[1];
00291 
00292 /*        ==== Optimal workspace ==== */
00293 
00294         lwkopt = jw + max(lwk1,lwk2);
00295     }
00296 
00297 /*     ==== Quick return in case of workspace query. ==== */
00298 
00299     if (*lwork == -1) {
00300         work[1] = (doublereal) lwkopt;
00301         return 0;
00302     }
00303 
00304 /*     ==== Nothing to do ... */
00305 /*     ... for an empty active block ... ==== */
00306     *ns = 0;
00307     *nd = 0;
00308     work[1] = 1.;
00309     if (*ktop > *kbot) {
00310         return 0;
00311     }
00312 /*     ... nor for an empty deflation window. ==== */
00313     if (*nw < 1) {
00314         return 0;
00315     }
00316 
00317 /*     ==== Machine constants ==== */
00318 
00319     safmin = dlamch_("SAFE MINIMUM");
00320     safmax = 1. / safmin;
00321     dlabad_(&safmin, &safmax);
00322     ulp = dlamch_("PRECISION");
00323     smlnum = safmin * ((doublereal) (*n) / ulp);
00324 
00325 /*     ==== Setup deflation window ==== */
00326 
00327 /* Computing MIN */
00328     i__1 = *nw, i__2 = *kbot - *ktop + 1;
00329     jw = min(i__1,i__2);
00330     kwtop = *kbot - jw + 1;
00331     if (kwtop == *ktop) {
00332         s = 0.;
00333     } else {
00334         s = h__[kwtop + (kwtop - 1) * h_dim1];
00335     }
00336 
00337     if (*kbot == kwtop) {
00338 
00339 /*        ==== 1-by-1 deflation window: not much to do ==== */
00340 
00341         sr[kwtop] = h__[kwtop + kwtop * h_dim1];
00342         si[kwtop] = 0.;
00343         *ns = 1;
00344         *nd = 0;
00345 /* Computing MAX */
00346         d__2 = smlnum, d__3 = ulp * (d__1 = h__[kwtop + kwtop * h_dim1], abs(
00347                 d__1));
00348         if (abs(s) <= max(d__2,d__3)) {
00349             *ns = 0;
00350             *nd = 1;
00351             if (kwtop > *ktop) {
00352                 h__[kwtop + (kwtop - 1) * h_dim1] = 0.;
00353             }
00354         }
00355         work[1] = 1.;
00356         return 0;
00357     }
00358 
00359 /*     ==== Convert to spike-triangular form.  (In case of a */
00360 /*     .    rare QR failure, this routine continues to do */
00361 /*     .    aggressive early deflation using that part of */
00362 /*     .    the deflation window that converged using INFQR */
00363 /*     .    here and there to keep track.) ==== */
00364 
00365     dlacpy_("U", &jw, &jw, &h__[kwtop + kwtop * h_dim1], ldh, &t[t_offset], 
00366             ldt);
00367     i__1 = jw - 1;
00368     i__2 = *ldh + 1;
00369     i__3 = *ldt + 1;
00370     dcopy_(&i__1, &h__[kwtop + 1 + kwtop * h_dim1], &i__2, &t[t_dim1 + 2], &
00371             i__3);
00372 
00373     dlaset_("A", &jw, &jw, &c_b12, &c_b13, &v[v_offset], ldv);
00374     dlahqr_(&c_true, &c_true, &jw, &c__1, &jw, &t[t_offset], ldt, &sr[kwtop], 
00375             &si[kwtop], &c__1, &jw, &v[v_offset], ldv, &infqr);
00376 
00377 /*     ==== DTREXC needs a clean margin near the diagonal ==== */
00378 
00379     i__1 = jw - 3;
00380     for (j = 1; j <= i__1; ++j) {
00381         t[j + 2 + j * t_dim1] = 0.;
00382         t[j + 3 + j * t_dim1] = 0.;
00383 /* L10: */
00384     }
00385     if (jw > 2) {
00386         t[jw + (jw - 2) * t_dim1] = 0.;
00387     }
00388 
00389 /*     ==== Deflation detection loop ==== */
00390 
00391     *ns = jw;
00392     ilst = infqr + 1;
00393 L20:
00394     if (ilst <= *ns) {
00395         if (*ns == 1) {
00396             bulge = FALSE_;
00397         } else {
00398             bulge = t[*ns + (*ns - 1) * t_dim1] != 0.;
00399         }
00400 
00401 /*        ==== Small spike tip test for deflation ==== */
00402 
00403         if (! bulge) {
00404 
00405 /*           ==== Real eigenvalue ==== */
00406 
00407             foo = (d__1 = t[*ns + *ns * t_dim1], abs(d__1));
00408             if (foo == 0.) {
00409                 foo = abs(s);
00410             }
00411 /* Computing MAX */
00412             d__2 = smlnum, d__3 = ulp * foo;
00413             if ((d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)) <= max(d__2,d__3))
00414                      {
00415 
00416 /*              ==== Deflatable ==== */
00417 
00418                 --(*ns);
00419             } else {
00420 
00421 /*              ==== Undeflatable.   Move it up out of the way. */
00422 /*              .    (DTREXC can not fail in this case.) ==== */
00423 
00424                 ifst = *ns;
00425                 dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, 
00426                          &ilst, &work[1], &info);
00427                 ++ilst;
00428             }
00429         } else {
00430 
00431 /*           ==== Complex conjugate pair ==== */
00432 
00433             foo = (d__3 = t[*ns + *ns * t_dim1], abs(d__3)) + sqrt((d__1 = t[*
00434                     ns + (*ns - 1) * t_dim1], abs(d__1))) * sqrt((d__2 = t[*
00435                     ns - 1 + *ns * t_dim1], abs(d__2)));
00436             if (foo == 0.) {
00437                 foo = abs(s);
00438             }
00439 /* Computing MAX */
00440             d__3 = (d__1 = s * v[*ns * v_dim1 + 1], abs(d__1)), d__4 = (d__2 =
00441                      s * v[(*ns - 1) * v_dim1 + 1], abs(d__2));
00442 /* Computing MAX */
00443             d__5 = smlnum, d__6 = ulp * foo;
00444             if (max(d__3,d__4) <= max(d__5,d__6)) {
00445 
00446 /*              ==== Deflatable ==== */
00447 
00448                 *ns += -2;
00449             } else {
00450 
00451 /*              ==== Undeflatable. Move them up out of the way. */
00452 /*              .    Fortunately, DTREXC does the right thing with */
00453 /*              .    ILST in case of a rare exchange failure. ==== */
00454 
00455                 ifst = *ns;
00456                 dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, 
00457                          &ilst, &work[1], &info);
00458                 ilst += 2;
00459             }
00460         }
00461 
00462 /*        ==== End deflation detection loop ==== */
00463 
00464         goto L20;
00465     }
00466 
00467 /*        ==== Return to Hessenberg form ==== */
00468 
00469     if (*ns == 0) {
00470         s = 0.;
00471     }
00472 
00473     if (*ns < jw) {
00474 
00475 /*        ==== sorting diagonal blocks of T improves accuracy for */
00476 /*        .    graded matrices.  Bubble sort deals well with */
00477 /*        .    exchange failures. ==== */
00478 
00479         sorted = FALSE_;
00480         i__ = *ns + 1;
00481 L30:
00482         if (sorted) {
00483             goto L50;
00484         }
00485         sorted = TRUE_;
00486 
00487         kend = i__ - 1;
00488         i__ = infqr + 1;
00489         if (i__ == *ns) {
00490             k = i__ + 1;
00491         } else if (t[i__ + 1 + i__ * t_dim1] == 0.) {
00492             k = i__ + 1;
00493         } else {
00494             k = i__ + 2;
00495         }
00496 L40:
00497         if (k <= kend) {
00498             if (k == i__ + 1) {
00499                 evi = (d__1 = t[i__ + i__ * t_dim1], abs(d__1));
00500             } else {
00501                 evi = (d__3 = t[i__ + i__ * t_dim1], abs(d__3)) + sqrt((d__1 =
00502                          t[i__ + 1 + i__ * t_dim1], abs(d__1))) * sqrt((d__2 =
00503                          t[i__ + (i__ + 1) * t_dim1], abs(d__2)));
00504             }
00505 
00506             if (k == kend) {
00507                 evk = (d__1 = t[k + k * t_dim1], abs(d__1));
00508             } else if (t[k + 1 + k * t_dim1] == 0.) {
00509                 evk = (d__1 = t[k + k * t_dim1], abs(d__1));
00510             } else {
00511                 evk = (d__3 = t[k + k * t_dim1], abs(d__3)) + sqrt((d__1 = t[
00512                         k + 1 + k * t_dim1], abs(d__1))) * sqrt((d__2 = t[k + 
00513                         (k + 1) * t_dim1], abs(d__2)));
00514             }
00515 
00516             if (evi >= evk) {
00517                 i__ = k;
00518             } else {
00519                 sorted = FALSE_;
00520                 ifst = i__;
00521                 ilst = k;
00522                 dtrexc_("V", &jw, &t[t_offset], ldt, &v[v_offset], ldv, &ifst, 
00523                          &ilst, &work[1], &info);
00524                 if (info == 0) {
00525                     i__ = ilst;
00526                 } else {
00527                     i__ = k;
00528                 }
00529             }
00530             if (i__ == kend) {
00531                 k = i__ + 1;
00532             } else if (t[i__ + 1 + i__ * t_dim1] == 0.) {
00533                 k = i__ + 1;
00534             } else {
00535                 k = i__ + 2;
00536             }
00537             goto L40;
00538         }
00539         goto L30;
00540 L50:
00541         ;
00542     }
00543 
00544 /*     ==== Restore shift/eigenvalue array from T ==== */
00545 
00546     i__ = jw;
00547 L60:
00548     if (i__ >= infqr + 1) {
00549         if (i__ == infqr + 1) {
00550             sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1];
00551             si[kwtop + i__ - 1] = 0.;
00552             --i__;
00553         } else if (t[i__ + (i__ - 1) * t_dim1] == 0.) {
00554             sr[kwtop + i__ - 1] = t[i__ + i__ * t_dim1];
00555             si[kwtop + i__ - 1] = 0.;
00556             --i__;
00557         } else {
00558             aa = t[i__ - 1 + (i__ - 1) * t_dim1];
00559             cc = t[i__ + (i__ - 1) * t_dim1];
00560             bb = t[i__ - 1 + i__ * t_dim1];
00561             dd = t[i__ + i__ * t_dim1];
00562             dlanv2_(&aa, &bb, &cc, &dd, &sr[kwtop + i__ - 2], &si[kwtop + i__ 
00563                     - 2], &sr[kwtop + i__ - 1], &si[kwtop + i__ - 1], &cs, &
00564                     sn);
00565             i__ += -2;
00566         }
00567         goto L60;
00568     }
00569 
00570     if (*ns < jw || s == 0.) {
00571         if (*ns > 1 && s != 0.) {
00572 
00573 /*           ==== Reflect spike back into lower triangle ==== */
00574 
00575             dcopy_(ns, &v[v_offset], ldv, &work[1], &c__1);
00576             beta = work[1];
00577             dlarfg_(ns, &beta, &work[2], &c__1, &tau);
00578             work[1] = 1.;
00579 
00580             i__1 = jw - 2;
00581             i__2 = jw - 2;
00582             dlaset_("L", &i__1, &i__2, &c_b12, &c_b12, &t[t_dim1 + 3], ldt);
00583 
00584             dlarf_("L", ns, &jw, &work[1], &c__1, &tau, &t[t_offset], ldt, &
00585                     work[jw + 1]);
00586             dlarf_("R", ns, ns, &work[1], &c__1, &tau, &t[t_offset], ldt, &
00587                     work[jw + 1]);
00588             dlarf_("R", &jw, ns, &work[1], &c__1, &tau, &v[v_offset], ldv, &
00589                     work[jw + 1]);
00590 
00591             i__1 = *lwork - jw;
00592             dgehrd_(&jw, &c__1, ns, &t[t_offset], ldt, &work[1], &work[jw + 1]
00593 , &i__1, &info);
00594         }
00595 
00596 /*        ==== Copy updated reduced window into place ==== */
00597 
00598         if (kwtop > 1) {
00599             h__[kwtop + (kwtop - 1) * h_dim1] = s * v[v_dim1 + 1];
00600         }
00601         dlacpy_("U", &jw, &jw, &t[t_offset], ldt, &h__[kwtop + kwtop * h_dim1]
00602 , ldh);
00603         i__1 = jw - 1;
00604         i__2 = *ldt + 1;
00605         i__3 = *ldh + 1;
00606         dcopy_(&i__1, &t[t_dim1 + 2], &i__2, &h__[kwtop + 1 + kwtop * h_dim1], 
00607                  &i__3);
00608 
00609 /*        ==== Accumulate orthogonal matrix in order update */
00610 /*        .    H and Z, if requested.  ==== */
00611 
00612         if (*ns > 1 && s != 0.) {
00613             i__1 = *lwork - jw;
00614             dormhr_("R", "N", &jw, ns, &c__1, ns, &t[t_offset], ldt, &work[1], 
00615                      &v[v_offset], ldv, &work[jw + 1], &i__1, &info);
00616         }
00617 
00618 /*        ==== Update vertical slab in H ==== */
00619 
00620         if (*wantt) {
00621             ltop = 1;
00622         } else {
00623             ltop = *ktop;
00624         }
00625         i__1 = kwtop - 1;
00626         i__2 = *nv;
00627         for (krow = ltop; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow += 
00628                 i__2) {
00629 /* Computing MIN */
00630             i__3 = *nv, i__4 = kwtop - krow;
00631             kln = min(i__3,i__4);
00632             dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &h__[krow + kwtop * 
00633                     h_dim1], ldh, &v[v_offset], ldv, &c_b12, &wv[wv_offset], 
00634                     ldwv);
00635             dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &h__[krow + kwtop * 
00636                     h_dim1], ldh);
00637 /* L70: */
00638         }
00639 
00640 /*        ==== Update horizontal slab in H ==== */
00641 
00642         if (*wantt) {
00643             i__2 = *n;
00644             i__1 = *nh;
00645             for (kcol = *kbot + 1; i__1 < 0 ? kcol >= i__2 : kcol <= i__2; 
00646                     kcol += i__1) {
00647 /* Computing MIN */
00648                 i__3 = *nh, i__4 = *n - kcol + 1;
00649                 kln = min(i__3,i__4);
00650                 dgemm_("C", "N", &jw, &kln, &jw, &c_b13, &v[v_offset], ldv, &
00651                         h__[kwtop + kcol * h_dim1], ldh, &c_b12, &t[t_offset], 
00652                          ldt);
00653                 dlacpy_("A", &jw, &kln, &t[t_offset], ldt, &h__[kwtop + kcol *
00654                          h_dim1], ldh);
00655 /* L80: */
00656             }
00657         }
00658 
00659 /*        ==== Update vertical slab in Z ==== */
00660 
00661         if (*wantz) {
00662             i__1 = *ihiz;
00663             i__2 = *nv;
00664             for (krow = *iloz; i__2 < 0 ? krow >= i__1 : krow <= i__1; krow +=
00665                      i__2) {
00666 /* Computing MIN */
00667                 i__3 = *nv, i__4 = *ihiz - krow + 1;
00668                 kln = min(i__3,i__4);
00669                 dgemm_("N", "N", &kln, &jw, &jw, &c_b13, &z__[krow + kwtop * 
00670                         z_dim1], ldz, &v[v_offset], ldv, &c_b12, &wv[
00671                         wv_offset], ldwv);
00672                 dlacpy_("A", &kln, &jw, &wv[wv_offset], ldwv, &z__[krow + 
00673                         kwtop * z_dim1], ldz);
00674 /* L90: */
00675             }
00676         }
00677     }
00678 
00679 /*     ==== Return the number of deflations ... ==== */
00680 
00681     *nd = jw - *ns;
00682 
00683 /*     ==== ... and the number of shifts. (Subtracting */
00684 /*     .    INFQR from the spike length takes care */
00685 /*     .    of the case of a rare QR failure while */
00686 /*     .    calculating eigenvalues of the deflation */
00687 /*     .    window.)  ==== */
00688 
00689     *ns -= infqr;
00690 
00691 /*      ==== Return optimal workspace. ==== */
00692 
00693     work[1] = (doublereal) lwkopt;
00694 
00695 /*     ==== End of DLAQR2 ==== */
00696 
00697     return 0;
00698 } /* dlaqr2_ */


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