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


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