zlaqr5.c
Go to the documentation of this file.
00001 /* zlaqr5.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__3 = 3;
00021 static integer c__1 = 1;
00022 static integer c__2 = 2;
00023 
00024 /* Subroutine */ int zlaqr5_(logical *wantt, logical *wantz, integer *kacc22, 
00025         integer *n, integer *ktop, integer *kbot, integer *nshfts, 
00026         doublecomplex *s, doublecomplex *h__, integer *ldh, integer *iloz, 
00027         integer *ihiz, doublecomplex *z__, integer *ldz, doublecomplex *v, 
00028         integer *ldv, doublecomplex *u, integer *ldu, integer *nv, 
00029         doublecomplex *wv, integer *ldwv, integer *nh, doublecomplex *wh, 
00030         integer *ldwh)
00031 {
00032     /* System generated locals */
00033     integer h_dim1, h_offset, u_dim1, u_offset, v_dim1, v_offset, wh_dim1, 
00034             wh_offset, wv_dim1, wv_offset, z_dim1, z_offset, i__1, i__2, i__3,
00035              i__4, i__5, i__6, i__7, i__8, i__9, i__10, i__11;
00036     doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10;
00037     doublecomplex z__1, z__2, z__3, z__4, z__5, z__6, z__7, z__8;
00038 
00039     /* Builtin functions */
00040     void d_cnjg(doublecomplex *, doublecomplex *);
00041     double d_imag(doublecomplex *);
00042 
00043     /* Local variables */
00044     integer j, k, m, i2, j2, i4, j4, k1;
00045     doublereal h11, h12, h21, h22;
00046     integer m22, ns, nu;
00047     doublecomplex vt[3];
00048     doublereal scl;
00049     integer kdu, kms;
00050     doublereal ulp;
00051     integer knz, kzs;
00052     doublereal tst1, tst2;
00053     doublecomplex beta;
00054     logical blk22, bmp22;
00055     integer mend, jcol, jlen, jbot, mbot, jtop, jrow, mtop;
00056     doublecomplex alpha;
00057     logical accum;
00058     integer ndcol, incol, krcol, nbmps;
00059     extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, 
00060             integer *, doublecomplex *, doublecomplex *, integer *, 
00061             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00062             integer *), ztrmm_(char *, char *, char *, char *, 
00063              integer *, integer *, doublecomplex *, doublecomplex *, integer *
00064 , doublecomplex *, integer *), 
00065             dlabad_(doublereal *, doublereal *), zlaqr1_(integer *, 
00066             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00067             doublecomplex *);
00068     extern doublereal dlamch_(char *);
00069     doublereal safmin, safmax;
00070     extern /* Subroutine */ int zlarfg_(integer *, doublecomplex *, 
00071             doublecomplex *, integer *, doublecomplex *);
00072     doublecomplex refsum;
00073     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00074             doublecomplex *, integer *, doublecomplex *, integer *), 
00075             zlaset_(char *, integer *, integer *, doublecomplex *, 
00076             doublecomplex *, doublecomplex *, integer *);
00077     integer mstart;
00078     doublereal smlnum;
00079 
00080 
00081 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00082 /*     Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
00083 /*     November 2006 */
00084 
00085 /*     .. Scalar Arguments .. */
00086 /*     .. */
00087 /*     .. Array Arguments .. */
00088 /*     .. */
00089 
00090 /*     This auxiliary subroutine called by ZLAQR0 performs a */
00091 /*     single small-bulge multi-shift QR sweep. */
00092 
00093 /*      WANTT  (input) logical scalar */
00094 /*             WANTT = .true. if the triangular Schur factor */
00095 /*             is being computed.  WANTT is set to .false. otherwise. */
00096 
00097 /*      WANTZ  (input) logical scalar */
00098 /*             WANTZ = .true. if the unitary Schur factor is being */
00099 /*             computed.  WANTZ is set to .false. otherwise. */
00100 
00101 /*      KACC22 (input) integer with value 0, 1, or 2. */
00102 /*             Specifies the computation mode of far-from-diagonal */
00103 /*             orthogonal updates. */
00104 /*        = 0: ZLAQR5 does not accumulate reflections and does not */
00105 /*             use matrix-matrix multiply to update far-from-diagonal */
00106 /*             matrix entries. */
00107 /*        = 1: ZLAQR5 accumulates reflections and uses matrix-matrix */
00108 /*             multiply to update the far-from-diagonal matrix entries. */
00109 /*        = 2: ZLAQR5 accumulates reflections, uses matrix-matrix */
00110 /*             multiply to update the far-from-diagonal matrix entries, */
00111 /*             and takes advantage of 2-by-2 block structure during */
00112 /*             matrix multiplies. */
00113 
00114 /*      N      (input) integer scalar */
00115 /*             N is the order of the Hessenberg matrix H upon which this */
00116 /*             subroutine operates. */
00117 
00118 /*      KTOP   (input) integer scalar */
00119 /*      KBOT   (input) integer scalar */
00120 /*             These are the first and last rows and columns of an */
00121 /*             isolated diagonal block upon which the QR sweep is to be */
00122 /*             applied. It is assumed without a check that */
00123 /*                       either KTOP = 1  or   H(KTOP,KTOP-1) = 0 */
00124 /*             and */
00125 /*                       either KBOT = N  or   H(KBOT+1,KBOT) = 0. */
00126 
00127 /*      NSHFTS (input) integer scalar */
00128 /*             NSHFTS gives the number of simultaneous shifts.  NSHFTS */
00129 /*             must be positive and even. */
00130 
00131 /*      S      (input/output) COMPLEX*16 array of size (NSHFTS) */
00132 /*             S contains the shifts of origin that define the multi- */
00133 /*             shift QR sweep.  On output S may be reordered. */
00134 
00135 /*      H      (input/output) COMPLEX*16 array of size (LDH,N) */
00136 /*             On input H contains a Hessenberg matrix.  On output a */
00137 /*             multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied */
00138 /*             to the isolated diagonal block in rows and columns KTOP */
00139 /*             through KBOT. */
00140 
00141 /*      LDH    (input) integer scalar */
00142 /*             LDH is the leading dimension of H just as declared in the */
00143 /*             calling procedure.  LDH.GE.MAX(1,N). */
00144 
00145 /*      ILOZ   (input) INTEGER */
00146 /*      IHIZ   (input) INTEGER */
00147 /*             Specify the rows of Z to which transformations must be */
00148 /*             applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N */
00149 
00150 /*      Z      (input/output) COMPLEX*16 array of size (LDZ,IHI) */
00151 /*             If WANTZ = .TRUE., then the QR Sweep unitary */
00152 /*             similarity transformation is accumulated into */
00153 /*             Z(ILOZ:IHIZ,ILO:IHI) from the right. */
00154 /*             If WANTZ = .FALSE., then Z is unreferenced. */
00155 
00156 /*      LDZ    (input) integer scalar */
00157 /*             LDA is the leading dimension of Z just as declared in */
00158 /*             the calling procedure. LDZ.GE.N. */
00159 
00160 /*      V      (workspace) COMPLEX*16 array of size (LDV,NSHFTS/2) */
00161 
00162 /*      LDV    (input) integer scalar */
00163 /*             LDV is the leading dimension of V as declared in the */
00164 /*             calling procedure.  LDV.GE.3. */
00165 
00166 /*      U      (workspace) COMPLEX*16 array of size */
00167 /*             (LDU,3*NSHFTS-3) */
00168 
00169 /*      LDU    (input) integer scalar */
00170 /*             LDU is the leading dimension of U just as declared in the */
00171 /*             in the calling subroutine.  LDU.GE.3*NSHFTS-3. */
00172 
00173 /*      NH     (input) integer scalar */
00174 /*             NH is the number of columns in array WH available for */
00175 /*             workspace. NH.GE.1. */
00176 
00177 /*      WH     (workspace) COMPLEX*16 array of size (LDWH,NH) */
00178 
00179 /*      LDWH   (input) integer scalar */
00180 /*             Leading dimension of WH just as declared in the */
00181 /*             calling procedure.  LDWH.GE.3*NSHFTS-3. */
00182 
00183 /*      NV     (input) integer scalar */
00184 /*             NV is the number of rows in WV agailable for workspace. */
00185 /*             NV.GE.1. */
00186 
00187 /*      WV     (workspace) COMPLEX*16 array of size */
00188 /*             (LDWV,3*NSHFTS-3) */
00189 
00190 /*      LDWV   (input) integer scalar */
00191 /*             LDWV is the leading dimension of WV as declared in the */
00192 /*             in the calling subroutine.  LDWV.GE.NV. */
00193 
00194 /*     ================================================================ */
00195 /*     Based on contributions by */
00196 /*        Karen Braman and Ralph Byers, Department of Mathematics, */
00197 /*        University of Kansas, USA */
00198 
00199 /*     ================================================================ */
00200 /*     Reference: */
00201 
00202 /*     K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */
00203 /*     Algorithm Part I: Maintaining Well Focused Shifts, and */
00204 /*     Level 3 Performance, SIAM Journal of Matrix Analysis, */
00205 /*     volume 23, pages 929--947, 2002. */
00206 
00207 /*     ================================================================ */
00208 /*     .. Parameters .. */
00209 /*     .. */
00210 /*     .. Local Scalars .. */
00211 /*     .. */
00212 /*     .. External Functions .. */
00213 /*     .. */
00214 /*     .. Intrinsic Functions .. */
00215 
00216 /*     .. */
00217 /*     .. Local Arrays .. */
00218 /*     .. */
00219 /*     .. External Subroutines .. */
00220 /*     .. */
00221 /*     .. Statement Functions .. */
00222 /*     .. */
00223 /*     .. Statement Function definitions .. */
00224 /*     .. */
00225 /*     .. Executable Statements .. */
00226 
00227 /*     ==== If there are no shifts, then there is nothing to do. ==== */
00228 
00229     /* Parameter adjustments */
00230     --s;
00231     h_dim1 = *ldh;
00232     h_offset = 1 + h_dim1;
00233     h__ -= h_offset;
00234     z_dim1 = *ldz;
00235     z_offset = 1 + z_dim1;
00236     z__ -= z_offset;
00237     v_dim1 = *ldv;
00238     v_offset = 1 + v_dim1;
00239     v -= v_offset;
00240     u_dim1 = *ldu;
00241     u_offset = 1 + u_dim1;
00242     u -= u_offset;
00243     wv_dim1 = *ldwv;
00244     wv_offset = 1 + wv_dim1;
00245     wv -= wv_offset;
00246     wh_dim1 = *ldwh;
00247     wh_offset = 1 + wh_dim1;
00248     wh -= wh_offset;
00249 
00250     /* Function Body */
00251     if (*nshfts < 2) {
00252         return 0;
00253     }
00254 
00255 /*     ==== If the active block is empty or 1-by-1, then there */
00256 /*     .    is nothing to do. ==== */
00257 
00258     if (*ktop >= *kbot) {
00259         return 0;
00260     }
00261 
00262 /*     ==== NSHFTS is supposed to be even, but if it is odd, */
00263 /*     .    then simply reduce it by one.  ==== */
00264 
00265     ns = *nshfts - *nshfts % 2;
00266 
00267 /*     ==== Machine constants for deflation ==== */
00268 
00269     safmin = dlamch_("SAFE MINIMUM");
00270     safmax = 1. / safmin;
00271     dlabad_(&safmin, &safmax);
00272     ulp = dlamch_("PRECISION");
00273     smlnum = safmin * ((doublereal) (*n) / ulp);
00274 
00275 /*     ==== Use accumulated reflections to update far-from-diagonal */
00276 /*     .    entries ? ==== */
00277 
00278     accum = *kacc22 == 1 || *kacc22 == 2;
00279 
00280 /*     ==== If so, exploit the 2-by-2 block structure? ==== */
00281 
00282     blk22 = ns > 2 && *kacc22 == 2;
00283 
00284 /*     ==== clear trash ==== */
00285 
00286     if (*ktop + 2 <= *kbot) {
00287         i__1 = *ktop + 2 + *ktop * h_dim1;
00288         h__[i__1].r = 0., h__[i__1].i = 0.;
00289     }
00290 
00291 /*     ==== NBMPS = number of 2-shift bulges in the chain ==== */
00292 
00293     nbmps = ns / 2;
00294 
00295 /*     ==== KDU = width of slab ==== */
00296 
00297     kdu = nbmps * 6 - 3;
00298 
00299 /*     ==== Create and chase chains of NBMPS bulges ==== */
00300 
00301     i__1 = *kbot - 2;
00302     i__2 = nbmps * 3 - 2;
00303     for (incol = (1 - nbmps) * 3 + *ktop - 1; i__2 < 0 ? incol >= i__1 : 
00304             incol <= i__1; incol += i__2) {
00305         ndcol = incol + kdu;
00306         if (accum) {
00307             zlaset_("ALL", &kdu, &kdu, &c_b1, &c_b2, &u[u_offset], ldu);
00308         }
00309 
00310 /*        ==== Near-the-diagonal bulge chase.  The following loop */
00311 /*        .    performs the near-the-diagonal part of a small bulge */
00312 /*        .    multi-shift QR sweep.  Each 6*NBMPS-2 column diagonal */
00313 /*        .    chunk extends from column INCOL to column NDCOL */
00314 /*        .    (including both column INCOL and column NDCOL). The */
00315 /*        .    following loop chases a 3*NBMPS column long chain of */
00316 /*        .    NBMPS bulges 3*NBMPS-2 columns to the right.  (INCOL */
00317 /*        .    may be less than KTOP and and NDCOL may be greater than */
00318 /*        .    KBOT indicating phantom columns from which to chase */
00319 /*        .    bulges before they are actually introduced or to which */
00320 /*        .    to chase bulges beyond column KBOT.)  ==== */
00321 
00322 /* Computing MIN */
00323         i__4 = incol + nbmps * 3 - 3, i__5 = *kbot - 2;
00324         i__3 = min(i__4,i__5);
00325         for (krcol = incol; krcol <= i__3; ++krcol) {
00326 
00327 /*           ==== Bulges number MTOP to MBOT are active double implicit */
00328 /*           .    shift bulges.  There may or may not also be small */
00329 /*           .    2-by-2 bulge, if there is room.  The inactive bulges */
00330 /*           .    (if any) must wait until the active bulges have moved */
00331 /*           .    down the diagonal to make room.  The phantom matrix */
00332 /*           .    paradigm described above helps keep track.  ==== */
00333 
00334 /* Computing MAX */
00335             i__4 = 1, i__5 = (*ktop - 1 - krcol + 2) / 3 + 1;
00336             mtop = max(i__4,i__5);
00337 /* Computing MIN */
00338             i__4 = nbmps, i__5 = (*kbot - krcol) / 3;
00339             mbot = min(i__4,i__5);
00340             m22 = mbot + 1;
00341             bmp22 = mbot < nbmps && krcol + (m22 - 1) * 3 == *kbot - 2;
00342 
00343 /*           ==== Generate reflections to chase the chain right */
00344 /*           .    one column.  (The minimum value of K is KTOP-1.) ==== */
00345 
00346             i__4 = mbot;
00347             for (m = mtop; m <= i__4; ++m) {
00348                 k = krcol + (m - 1) * 3;
00349                 if (k == *ktop - 1) {
00350                     zlaqr1_(&c__3, &h__[*ktop + *ktop * h_dim1], ldh, &s[(m <<
00351                              1) - 1], &s[m * 2], &v[m * v_dim1 + 1]);
00352                     i__5 = m * v_dim1 + 1;
00353                     alpha.r = v[i__5].r, alpha.i = v[i__5].i;
00354                     zlarfg_(&c__3, &alpha, &v[m * v_dim1 + 2], &c__1, &v[m * 
00355                             v_dim1 + 1]);
00356                 } else {
00357                     i__5 = k + 1 + k * h_dim1;
00358                     beta.r = h__[i__5].r, beta.i = h__[i__5].i;
00359                     i__5 = m * v_dim1 + 2;
00360                     i__6 = k + 2 + k * h_dim1;
00361                     v[i__5].r = h__[i__6].r, v[i__5].i = h__[i__6].i;
00362                     i__5 = m * v_dim1 + 3;
00363                     i__6 = k + 3 + k * h_dim1;
00364                     v[i__5].r = h__[i__6].r, v[i__5].i = h__[i__6].i;
00365                     zlarfg_(&c__3, &beta, &v[m * v_dim1 + 2], &c__1, &v[m * 
00366                             v_dim1 + 1]);
00367 
00368 /*                 ==== A Bulge may collapse because of vigilant */
00369 /*                 .    deflation or destructive underflow.  In the */
00370 /*                 .    underflow case, try the two-small-subdiagonals */
00371 /*                 .    trick to try to reinflate the bulge.  ==== */
00372 
00373                     i__5 = k + 3 + k * h_dim1;
00374                     i__6 = k + 3 + (k + 1) * h_dim1;
00375                     i__7 = k + 3 + (k + 2) * h_dim1;
00376                     if (h__[i__5].r != 0. || h__[i__5].i != 0. || (h__[i__6]
00377                             .r != 0. || h__[i__6].i != 0.) || h__[i__7].r == 
00378                             0. && h__[i__7].i == 0.) {
00379 
00380 /*                    ==== Typical case: not collapsed (yet). ==== */
00381 
00382                         i__5 = k + 1 + k * h_dim1;
00383                         h__[i__5].r = beta.r, h__[i__5].i = beta.i;
00384                         i__5 = k + 2 + k * h_dim1;
00385                         h__[i__5].r = 0., h__[i__5].i = 0.;
00386                         i__5 = k + 3 + k * h_dim1;
00387                         h__[i__5].r = 0., h__[i__5].i = 0.;
00388                     } else {
00389 
00390 /*                    ==== Atypical case: collapsed.  Attempt to */
00391 /*                    .    reintroduce ignoring H(K+1,K) and H(K+2,K). */
00392 /*                    .    If the fill resulting from the new */
00393 /*                    .    reflector is too large, then abandon it. */
00394 /*                    .    Otherwise, use the new one. ==== */
00395 
00396                         zlaqr1_(&c__3, &h__[k + 1 + (k + 1) * h_dim1], ldh, &
00397                                 s[(m << 1) - 1], &s[m * 2], vt);
00398                         alpha.r = vt[0].r, alpha.i = vt[0].i;
00399                         zlarfg_(&c__3, &alpha, &vt[1], &c__1, vt);
00400                         d_cnjg(&z__2, vt);
00401                         i__5 = k + 1 + k * h_dim1;
00402                         d_cnjg(&z__5, &vt[1]);
00403                         i__6 = k + 2 + k * h_dim1;
00404                         z__4.r = z__5.r * h__[i__6].r - z__5.i * h__[i__6].i, 
00405                                 z__4.i = z__5.r * h__[i__6].i + z__5.i * h__[
00406                                 i__6].r;
00407                         z__3.r = h__[i__5].r + z__4.r, z__3.i = h__[i__5].i + 
00408                                 z__4.i;
00409                         z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = 
00410                                 z__2.r * z__3.i + z__2.i * z__3.r;
00411                         refsum.r = z__1.r, refsum.i = z__1.i;
00412 
00413                         i__5 = k + 2 + k * h_dim1;
00414                         z__3.r = refsum.r * vt[1].r - refsum.i * vt[1].i, 
00415                                 z__3.i = refsum.r * vt[1].i + refsum.i * vt[1]
00416                                 .r;
00417                         z__2.r = h__[i__5].r - z__3.r, z__2.i = h__[i__5].i - 
00418                                 z__3.i;
00419                         z__1.r = z__2.r, z__1.i = z__2.i;
00420                         z__5.r = refsum.r * vt[2].r - refsum.i * vt[2].i, 
00421                                 z__5.i = refsum.r * vt[2].i + refsum.i * vt[2]
00422                                 .r;
00423                         z__4.r = z__5.r, z__4.i = z__5.i;
00424                         i__6 = k + k * h_dim1;
00425                         i__7 = k + 1 + (k + 1) * h_dim1;
00426                         i__8 = k + 2 + (k + 2) * h_dim1;
00427                         if ((d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1)
00428                                 , abs(d__2)) + ((d__3 = z__4.r, abs(d__3)) + (
00429                                 d__4 = d_imag(&z__4), abs(d__4))) > ulp * ((
00430                                 d__5 = h__[i__6].r, abs(d__5)) + (d__6 = 
00431                                 d_imag(&h__[k + k * h_dim1]), abs(d__6)) + ((
00432                                 d__7 = h__[i__7].r, abs(d__7)) + (d__8 = 
00433                                 d_imag(&h__[k + 1 + (k + 1) * h_dim1]), abs(
00434                                 d__8))) + ((d__9 = h__[i__8].r, abs(d__9)) + (
00435                                 d__10 = d_imag(&h__[k + 2 + (k + 2) * h_dim1])
00436                                 , abs(d__10))))) {
00437 
00438 /*                       ==== Starting a new bulge here would */
00439 /*                       .    create non-negligible fill.  Use */
00440 /*                       .    the old one with trepidation. ==== */
00441 
00442                             i__5 = k + 1 + k * h_dim1;
00443                             h__[i__5].r = beta.r, h__[i__5].i = beta.i;
00444                             i__5 = k + 2 + k * h_dim1;
00445                             h__[i__5].r = 0., h__[i__5].i = 0.;
00446                             i__5 = k + 3 + k * h_dim1;
00447                             h__[i__5].r = 0., h__[i__5].i = 0.;
00448                         } else {
00449 
00450 /*                       ==== Stating a new bulge here would */
00451 /*                       .    create only negligible fill. */
00452 /*                       .    Replace the old reflector with */
00453 /*                       .    the new one. ==== */
00454 
00455                             i__5 = k + 1 + k * h_dim1;
00456                             i__6 = k + 1 + k * h_dim1;
00457                             z__1.r = h__[i__6].r - refsum.r, z__1.i = h__[
00458                                     i__6].i - refsum.i;
00459                             h__[i__5].r = z__1.r, h__[i__5].i = z__1.i;
00460                             i__5 = k + 2 + k * h_dim1;
00461                             h__[i__5].r = 0., h__[i__5].i = 0.;
00462                             i__5 = k + 3 + k * h_dim1;
00463                             h__[i__5].r = 0., h__[i__5].i = 0.;
00464                             i__5 = m * v_dim1 + 1;
00465                             v[i__5].r = vt[0].r, v[i__5].i = vt[0].i;
00466                             i__5 = m * v_dim1 + 2;
00467                             v[i__5].r = vt[1].r, v[i__5].i = vt[1].i;
00468                             i__5 = m * v_dim1 + 3;
00469                             v[i__5].r = vt[2].r, v[i__5].i = vt[2].i;
00470                         }
00471                     }
00472                 }
00473 /* L10: */
00474             }
00475 
00476 /*           ==== Generate a 2-by-2 reflection, if needed. ==== */
00477 
00478             k = krcol + (m22 - 1) * 3;
00479             if (bmp22) {
00480                 if (k == *ktop - 1) {
00481                     zlaqr1_(&c__2, &h__[k + 1 + (k + 1) * h_dim1], ldh, &s[(
00482                             m22 << 1) - 1], &s[m22 * 2], &v[m22 * v_dim1 + 1])
00483                             ;
00484                     i__4 = m22 * v_dim1 + 1;
00485                     beta.r = v[i__4].r, beta.i = v[i__4].i;
00486                     zlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22 
00487                             * v_dim1 + 1]);
00488                 } else {
00489                     i__4 = k + 1 + k * h_dim1;
00490                     beta.r = h__[i__4].r, beta.i = h__[i__4].i;
00491                     i__4 = m22 * v_dim1 + 2;
00492                     i__5 = k + 2 + k * h_dim1;
00493                     v[i__4].r = h__[i__5].r, v[i__4].i = h__[i__5].i;
00494                     zlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22 
00495                             * v_dim1 + 1]);
00496                     i__4 = k + 1 + k * h_dim1;
00497                     h__[i__4].r = beta.r, h__[i__4].i = beta.i;
00498                     i__4 = k + 2 + k * h_dim1;
00499                     h__[i__4].r = 0., h__[i__4].i = 0.;
00500                 }
00501             }
00502 
00503 /*           ==== Multiply H by reflections from the left ==== */
00504 
00505             if (accum) {
00506                 jbot = min(ndcol,*kbot);
00507             } else if (*wantt) {
00508                 jbot = *n;
00509             } else {
00510                 jbot = *kbot;
00511             }
00512             i__4 = jbot;
00513             for (j = max(*ktop,krcol); j <= i__4; ++j) {
00514 /* Computing MIN */
00515                 i__5 = mbot, i__6 = (j - krcol + 2) / 3;
00516                 mend = min(i__5,i__6);
00517                 i__5 = mend;
00518                 for (m = mtop; m <= i__5; ++m) {
00519                     k = krcol + (m - 1) * 3;
00520                     d_cnjg(&z__2, &v[m * v_dim1 + 1]);
00521                     i__6 = k + 1 + j * h_dim1;
00522                     d_cnjg(&z__6, &v[m * v_dim1 + 2]);
00523                     i__7 = k + 2 + j * h_dim1;
00524                     z__5.r = z__6.r * h__[i__7].r - z__6.i * h__[i__7].i, 
00525                             z__5.i = z__6.r * h__[i__7].i + z__6.i * h__[i__7]
00526                             .r;
00527                     z__4.r = h__[i__6].r + z__5.r, z__4.i = h__[i__6].i + 
00528                             z__5.i;
00529                     d_cnjg(&z__8, &v[m * v_dim1 + 3]);
00530                     i__8 = k + 3 + j * h_dim1;
00531                     z__7.r = z__8.r * h__[i__8].r - z__8.i * h__[i__8].i, 
00532                             z__7.i = z__8.r * h__[i__8].i + z__8.i * h__[i__8]
00533                             .r;
00534                     z__3.r = z__4.r + z__7.r, z__3.i = z__4.i + z__7.i;
00535                     z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = 
00536                             z__2.r * z__3.i + z__2.i * z__3.r;
00537                     refsum.r = z__1.r, refsum.i = z__1.i;
00538                     i__6 = k + 1 + j * h_dim1;
00539                     i__7 = k + 1 + j * h_dim1;
00540                     z__1.r = h__[i__7].r - refsum.r, z__1.i = h__[i__7].i - 
00541                             refsum.i;
00542                     h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00543                     i__6 = k + 2 + j * h_dim1;
00544                     i__7 = k + 2 + j * h_dim1;
00545                     i__8 = m * v_dim1 + 2;
00546                     z__2.r = refsum.r * v[i__8].r - refsum.i * v[i__8].i, 
00547                             z__2.i = refsum.r * v[i__8].i + refsum.i * v[i__8]
00548                             .r;
00549                     z__1.r = h__[i__7].r - z__2.r, z__1.i = h__[i__7].i - 
00550                             z__2.i;
00551                     h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00552                     i__6 = k + 3 + j * h_dim1;
00553                     i__7 = k + 3 + j * h_dim1;
00554                     i__8 = m * v_dim1 + 3;
00555                     z__2.r = refsum.r * v[i__8].r - refsum.i * v[i__8].i, 
00556                             z__2.i = refsum.r * v[i__8].i + refsum.i * v[i__8]
00557                             .r;
00558                     z__1.r = h__[i__7].r - z__2.r, z__1.i = h__[i__7].i - 
00559                             z__2.i;
00560                     h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00561 /* L20: */
00562                 }
00563 /* L30: */
00564             }
00565             if (bmp22) {
00566                 k = krcol + (m22 - 1) * 3;
00567 /* Computing MAX */
00568                 i__4 = k + 1;
00569                 i__5 = jbot;
00570                 for (j = max(i__4,*ktop); j <= i__5; ++j) {
00571                     d_cnjg(&z__2, &v[m22 * v_dim1 + 1]);
00572                     i__4 = k + 1 + j * h_dim1;
00573                     d_cnjg(&z__5, &v[m22 * v_dim1 + 2]);
00574                     i__6 = k + 2 + j * h_dim1;
00575                     z__4.r = z__5.r * h__[i__6].r - z__5.i * h__[i__6].i, 
00576                             z__4.i = z__5.r * h__[i__6].i + z__5.i * h__[i__6]
00577                             .r;
00578                     z__3.r = h__[i__4].r + z__4.r, z__3.i = h__[i__4].i + 
00579                             z__4.i;
00580                     z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = 
00581                             z__2.r * z__3.i + z__2.i * z__3.r;
00582                     refsum.r = z__1.r, refsum.i = z__1.i;
00583                     i__4 = k + 1 + j * h_dim1;
00584                     i__6 = k + 1 + j * h_dim1;
00585                     z__1.r = h__[i__6].r - refsum.r, z__1.i = h__[i__6].i - 
00586                             refsum.i;
00587                     h__[i__4].r = z__1.r, h__[i__4].i = z__1.i;
00588                     i__4 = k + 2 + j * h_dim1;
00589                     i__6 = k + 2 + j * h_dim1;
00590                     i__7 = m22 * v_dim1 + 2;
00591                     z__2.r = refsum.r * v[i__7].r - refsum.i * v[i__7].i, 
00592                             z__2.i = refsum.r * v[i__7].i + refsum.i * v[i__7]
00593                             .r;
00594                     z__1.r = h__[i__6].r - z__2.r, z__1.i = h__[i__6].i - 
00595                             z__2.i;
00596                     h__[i__4].r = z__1.r, h__[i__4].i = z__1.i;
00597 /* L40: */
00598                 }
00599             }
00600 
00601 /*           ==== Multiply H by reflections from the right. */
00602 /*           .    Delay filling in the last row until the */
00603 /*           .    vigilant deflation check is complete. ==== */
00604 
00605             if (accum) {
00606                 jtop = max(*ktop,incol);
00607             } else if (*wantt) {
00608                 jtop = 1;
00609             } else {
00610                 jtop = *ktop;
00611             }
00612             i__5 = mbot;
00613             for (m = mtop; m <= i__5; ++m) {
00614                 i__4 = m * v_dim1 + 1;
00615                 if (v[i__4].r != 0. || v[i__4].i != 0.) {
00616                     k = krcol + (m - 1) * 3;
00617 /* Computing MIN */
00618                     i__6 = *kbot, i__7 = k + 3;
00619                     i__4 = min(i__6,i__7);
00620                     for (j = jtop; j <= i__4; ++j) {
00621                         i__6 = m * v_dim1 + 1;
00622                         i__7 = j + (k + 1) * h_dim1;
00623                         i__8 = m * v_dim1 + 2;
00624                         i__9 = j + (k + 2) * h_dim1;
00625                         z__4.r = v[i__8].r * h__[i__9].r - v[i__8].i * h__[
00626                                 i__9].i, z__4.i = v[i__8].r * h__[i__9].i + v[
00627                                 i__8].i * h__[i__9].r;
00628                         z__3.r = h__[i__7].r + z__4.r, z__3.i = h__[i__7].i + 
00629                                 z__4.i;
00630                         i__10 = m * v_dim1 + 3;
00631                         i__11 = j + (k + 3) * h_dim1;
00632                         z__5.r = v[i__10].r * h__[i__11].r - v[i__10].i * h__[
00633                                 i__11].i, z__5.i = v[i__10].r * h__[i__11].i 
00634                                 + v[i__10].i * h__[i__11].r;
00635                         z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + z__5.i;
00636                         z__1.r = v[i__6].r * z__2.r - v[i__6].i * z__2.i, 
00637                                 z__1.i = v[i__6].r * z__2.i + v[i__6].i * 
00638                                 z__2.r;
00639                         refsum.r = z__1.r, refsum.i = z__1.i;
00640                         i__6 = j + (k + 1) * h_dim1;
00641                         i__7 = j + (k + 1) * h_dim1;
00642                         z__1.r = h__[i__7].r - refsum.r, z__1.i = h__[i__7].i 
00643                                 - refsum.i;
00644                         h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00645                         i__6 = j + (k + 2) * h_dim1;
00646                         i__7 = j + (k + 2) * h_dim1;
00647                         d_cnjg(&z__3, &v[m * v_dim1 + 2]);
00648                         z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00649                                 z__2.i = refsum.r * z__3.i + refsum.i * 
00650                                 z__3.r;
00651                         z__1.r = h__[i__7].r - z__2.r, z__1.i = h__[i__7].i - 
00652                                 z__2.i;
00653                         h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00654                         i__6 = j + (k + 3) * h_dim1;
00655                         i__7 = j + (k + 3) * h_dim1;
00656                         d_cnjg(&z__3, &v[m * v_dim1 + 3]);
00657                         z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00658                                 z__2.i = refsum.r * z__3.i + refsum.i * 
00659                                 z__3.r;
00660                         z__1.r = h__[i__7].r - z__2.r, z__1.i = h__[i__7].i - 
00661                                 z__2.i;
00662                         h__[i__6].r = z__1.r, h__[i__6].i = z__1.i;
00663 /* L50: */
00664                     }
00665 
00666                     if (accum) {
00667 
00668 /*                    ==== Accumulate U. (If necessary, update Z later */
00669 /*                    .    with with an efficient matrix-matrix */
00670 /*                    .    multiply.) ==== */
00671 
00672                         kms = k - incol;
00673 /* Computing MAX */
00674                         i__4 = 1, i__6 = *ktop - incol;
00675                         i__7 = kdu;
00676                         for (j = max(i__4,i__6); j <= i__7; ++j) {
00677                             i__4 = m * v_dim1 + 1;
00678                             i__6 = j + (kms + 1) * u_dim1;
00679                             i__8 = m * v_dim1 + 2;
00680                             i__9 = j + (kms + 2) * u_dim1;
00681                             z__4.r = v[i__8].r * u[i__9].r - v[i__8].i * u[
00682                                     i__9].i, z__4.i = v[i__8].r * u[i__9].i + 
00683                                     v[i__8].i * u[i__9].r;
00684                             z__3.r = u[i__6].r + z__4.r, z__3.i = u[i__6].i + 
00685                                     z__4.i;
00686                             i__10 = m * v_dim1 + 3;
00687                             i__11 = j + (kms + 3) * u_dim1;
00688                             z__5.r = v[i__10].r * u[i__11].r - v[i__10].i * u[
00689                                     i__11].i, z__5.i = v[i__10].r * u[i__11]
00690                                     .i + v[i__10].i * u[i__11].r;
00691                             z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + 
00692                                     z__5.i;
00693                             z__1.r = v[i__4].r * z__2.r - v[i__4].i * z__2.i, 
00694                                     z__1.i = v[i__4].r * z__2.i + v[i__4].i * 
00695                                     z__2.r;
00696                             refsum.r = z__1.r, refsum.i = z__1.i;
00697                             i__4 = j + (kms + 1) * u_dim1;
00698                             i__6 = j + (kms + 1) * u_dim1;
00699                             z__1.r = u[i__6].r - refsum.r, z__1.i = u[i__6].i 
00700                                     - refsum.i;
00701                             u[i__4].r = z__1.r, u[i__4].i = z__1.i;
00702                             i__4 = j + (kms + 2) * u_dim1;
00703                             i__6 = j + (kms + 2) * u_dim1;
00704                             d_cnjg(&z__3, &v[m * v_dim1 + 2]);
00705                             z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00706                                     z__2.i = refsum.r * z__3.i + refsum.i * 
00707                                     z__3.r;
00708                             z__1.r = u[i__6].r - z__2.r, z__1.i = u[i__6].i - 
00709                                     z__2.i;
00710                             u[i__4].r = z__1.r, u[i__4].i = z__1.i;
00711                             i__4 = j + (kms + 3) * u_dim1;
00712                             i__6 = j + (kms + 3) * u_dim1;
00713                             d_cnjg(&z__3, &v[m * v_dim1 + 3]);
00714                             z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00715                                     z__2.i = refsum.r * z__3.i + refsum.i * 
00716                                     z__3.r;
00717                             z__1.r = u[i__6].r - z__2.r, z__1.i = u[i__6].i - 
00718                                     z__2.i;
00719                             u[i__4].r = z__1.r, u[i__4].i = z__1.i;
00720 /* L60: */
00721                         }
00722                     } else if (*wantz) {
00723 
00724 /*                    ==== U is not accumulated, so update Z */
00725 /*                    .    now by multiplying by reflections */
00726 /*                    .    from the right. ==== */
00727 
00728                         i__7 = *ihiz;
00729                         for (j = *iloz; j <= i__7; ++j) {
00730                             i__4 = m * v_dim1 + 1;
00731                             i__6 = j + (k + 1) * z_dim1;
00732                             i__8 = m * v_dim1 + 2;
00733                             i__9 = j + (k + 2) * z_dim1;
00734                             z__4.r = v[i__8].r * z__[i__9].r - v[i__8].i * 
00735                                     z__[i__9].i, z__4.i = v[i__8].r * z__[
00736                                     i__9].i + v[i__8].i * z__[i__9].r;
00737                             z__3.r = z__[i__6].r + z__4.r, z__3.i = z__[i__6]
00738                                     .i + z__4.i;
00739                             i__10 = m * v_dim1 + 3;
00740                             i__11 = j + (k + 3) * z_dim1;
00741                             z__5.r = v[i__10].r * z__[i__11].r - v[i__10].i * 
00742                                     z__[i__11].i, z__5.i = v[i__10].r * z__[
00743                                     i__11].i + v[i__10].i * z__[i__11].r;
00744                             z__2.r = z__3.r + z__5.r, z__2.i = z__3.i + 
00745                                     z__5.i;
00746                             z__1.r = v[i__4].r * z__2.r - v[i__4].i * z__2.i, 
00747                                     z__1.i = v[i__4].r * z__2.i + v[i__4].i * 
00748                                     z__2.r;
00749                             refsum.r = z__1.r, refsum.i = z__1.i;
00750                             i__4 = j + (k + 1) * z_dim1;
00751                             i__6 = j + (k + 1) * z_dim1;
00752                             z__1.r = z__[i__6].r - refsum.r, z__1.i = z__[
00753                                     i__6].i - refsum.i;
00754                             z__[i__4].r = z__1.r, z__[i__4].i = z__1.i;
00755                             i__4 = j + (k + 2) * z_dim1;
00756                             i__6 = j + (k + 2) * z_dim1;
00757                             d_cnjg(&z__3, &v[m * v_dim1 + 2]);
00758                             z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00759                                     z__2.i = refsum.r * z__3.i + refsum.i * 
00760                                     z__3.r;
00761                             z__1.r = z__[i__6].r - z__2.r, z__1.i = z__[i__6]
00762                                     .i - z__2.i;
00763                             z__[i__4].r = z__1.r, z__[i__4].i = z__1.i;
00764                             i__4 = j + (k + 3) * z_dim1;
00765                             i__6 = j + (k + 3) * z_dim1;
00766                             d_cnjg(&z__3, &v[m * v_dim1 + 3]);
00767                             z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00768                                     z__2.i = refsum.r * z__3.i + refsum.i * 
00769                                     z__3.r;
00770                             z__1.r = z__[i__6].r - z__2.r, z__1.i = z__[i__6]
00771                                     .i - z__2.i;
00772                             z__[i__4].r = z__1.r, z__[i__4].i = z__1.i;
00773 /* L70: */
00774                         }
00775                     }
00776                 }
00777 /* L80: */
00778             }
00779 
00780 /*           ==== Special case: 2-by-2 reflection (if needed) ==== */
00781 
00782             k = krcol + (m22 - 1) * 3;
00783             i__5 = m22 * v_dim1 + 1;
00784             if (bmp22 && (v[i__5].r != 0. || v[i__5].i != 0.)) {
00785 /* Computing MIN */
00786                 i__7 = *kbot, i__4 = k + 3;
00787                 i__5 = min(i__7,i__4);
00788                 for (j = jtop; j <= i__5; ++j) {
00789                     i__7 = m22 * v_dim1 + 1;
00790                     i__4 = j + (k + 1) * h_dim1;
00791                     i__6 = m22 * v_dim1 + 2;
00792                     i__8 = j + (k + 2) * h_dim1;
00793                     z__3.r = v[i__6].r * h__[i__8].r - v[i__6].i * h__[i__8]
00794                             .i, z__3.i = v[i__6].r * h__[i__8].i + v[i__6].i *
00795                              h__[i__8].r;
00796                     z__2.r = h__[i__4].r + z__3.r, z__2.i = h__[i__4].i + 
00797                             z__3.i;
00798                     z__1.r = v[i__7].r * z__2.r - v[i__7].i * z__2.i, z__1.i =
00799                              v[i__7].r * z__2.i + v[i__7].i * z__2.r;
00800                     refsum.r = z__1.r, refsum.i = z__1.i;
00801                     i__7 = j + (k + 1) * h_dim1;
00802                     i__4 = j + (k + 1) * h_dim1;
00803                     z__1.r = h__[i__4].r - refsum.r, z__1.i = h__[i__4].i - 
00804                             refsum.i;
00805                     h__[i__7].r = z__1.r, h__[i__7].i = z__1.i;
00806                     i__7 = j + (k + 2) * h_dim1;
00807                     i__4 = j + (k + 2) * h_dim1;
00808                     d_cnjg(&z__3, &v[m22 * v_dim1 + 2]);
00809                     z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, z__2.i = 
00810                             refsum.r * z__3.i + refsum.i * z__3.r;
00811                     z__1.r = h__[i__4].r - z__2.r, z__1.i = h__[i__4].i - 
00812                             z__2.i;
00813                     h__[i__7].r = z__1.r, h__[i__7].i = z__1.i;
00814 /* L90: */
00815                 }
00816 
00817                 if (accum) {
00818                     kms = k - incol;
00819 /* Computing MAX */
00820                     i__5 = 1, i__7 = *ktop - incol;
00821                     i__4 = kdu;
00822                     for (j = max(i__5,i__7); j <= i__4; ++j) {
00823                         i__5 = m22 * v_dim1 + 1;
00824                         i__7 = j + (kms + 1) * u_dim1;
00825                         i__6 = m22 * v_dim1 + 2;
00826                         i__8 = j + (kms + 2) * u_dim1;
00827                         z__3.r = v[i__6].r * u[i__8].r - v[i__6].i * u[i__8]
00828                                 .i, z__3.i = v[i__6].r * u[i__8].i + v[i__6]
00829                                 .i * u[i__8].r;
00830                         z__2.r = u[i__7].r + z__3.r, z__2.i = u[i__7].i + 
00831                                 z__3.i;
00832                         z__1.r = v[i__5].r * z__2.r - v[i__5].i * z__2.i, 
00833                                 z__1.i = v[i__5].r * z__2.i + v[i__5].i * 
00834                                 z__2.r;
00835                         refsum.r = z__1.r, refsum.i = z__1.i;
00836                         i__5 = j + (kms + 1) * u_dim1;
00837                         i__7 = j + (kms + 1) * u_dim1;
00838                         z__1.r = u[i__7].r - refsum.r, z__1.i = u[i__7].i - 
00839                                 refsum.i;
00840                         u[i__5].r = z__1.r, u[i__5].i = z__1.i;
00841                         i__5 = j + (kms + 2) * u_dim1;
00842                         i__7 = j + (kms + 2) * u_dim1;
00843                         d_cnjg(&z__3, &v[m22 * v_dim1 + 2]);
00844                         z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00845                                 z__2.i = refsum.r * z__3.i + refsum.i * 
00846                                 z__3.r;
00847                         z__1.r = u[i__7].r - z__2.r, z__1.i = u[i__7].i - 
00848                                 z__2.i;
00849                         u[i__5].r = z__1.r, u[i__5].i = z__1.i;
00850 /* L100: */
00851                     }
00852                 } else if (*wantz) {
00853                     i__4 = *ihiz;
00854                     for (j = *iloz; j <= i__4; ++j) {
00855                         i__5 = m22 * v_dim1 + 1;
00856                         i__7 = j + (k + 1) * z_dim1;
00857                         i__6 = m22 * v_dim1 + 2;
00858                         i__8 = j + (k + 2) * z_dim1;
00859                         z__3.r = v[i__6].r * z__[i__8].r - v[i__6].i * z__[
00860                                 i__8].i, z__3.i = v[i__6].r * z__[i__8].i + v[
00861                                 i__6].i * z__[i__8].r;
00862                         z__2.r = z__[i__7].r + z__3.r, z__2.i = z__[i__7].i + 
00863                                 z__3.i;
00864                         z__1.r = v[i__5].r * z__2.r - v[i__5].i * z__2.i, 
00865                                 z__1.i = v[i__5].r * z__2.i + v[i__5].i * 
00866                                 z__2.r;
00867                         refsum.r = z__1.r, refsum.i = z__1.i;
00868                         i__5 = j + (k + 1) * z_dim1;
00869                         i__7 = j + (k + 1) * z_dim1;
00870                         z__1.r = z__[i__7].r - refsum.r, z__1.i = z__[i__7].i 
00871                                 - refsum.i;
00872                         z__[i__5].r = z__1.r, z__[i__5].i = z__1.i;
00873                         i__5 = j + (k + 2) * z_dim1;
00874                         i__7 = j + (k + 2) * z_dim1;
00875                         d_cnjg(&z__3, &v[m22 * v_dim1 + 2]);
00876                         z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, 
00877                                 z__2.i = refsum.r * z__3.i + refsum.i * 
00878                                 z__3.r;
00879                         z__1.r = z__[i__7].r - z__2.r, z__1.i = z__[i__7].i - 
00880                                 z__2.i;
00881                         z__[i__5].r = z__1.r, z__[i__5].i = z__1.i;
00882 /* L110: */
00883                     }
00884                 }
00885             }
00886 
00887 /*           ==== Vigilant deflation check ==== */
00888 
00889             mstart = mtop;
00890             if (krcol + (mstart - 1) * 3 < *ktop) {
00891                 ++mstart;
00892             }
00893             mend = mbot;
00894             if (bmp22) {
00895                 ++mend;
00896             }
00897             if (krcol == *kbot - 2) {
00898                 ++mend;
00899             }
00900             i__4 = mend;
00901             for (m = mstart; m <= i__4; ++m) {
00902 /* Computing MIN */
00903                 i__5 = *kbot - 1, i__7 = krcol + (m - 1) * 3;
00904                 k = min(i__5,i__7);
00905 
00906 /*              ==== The following convergence test requires that */
00907 /*              .    the tradition small-compared-to-nearby-diagonals */
00908 /*              .    criterion and the Ahues & Tisseur (LAWN 122, 1997) */
00909 /*              .    criteria both be satisfied.  The latter improves */
00910 /*              .    accuracy in some examples. Falling back on an */
00911 /*              .    alternate convergence criterion when TST1 or TST2 */
00912 /*              .    is zero (as done here) is traditional but probably */
00913 /*              .    unnecessary. ==== */
00914 
00915                 i__5 = k + 1 + k * h_dim1;
00916                 if (h__[i__5].r != 0. || h__[i__5].i != 0.) {
00917                     i__5 = k + k * h_dim1;
00918                     i__7 = k + 1 + (k + 1) * h_dim1;
00919                     tst1 = (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = d_imag(&
00920                             h__[k + k * h_dim1]), abs(d__2)) + ((d__3 = h__[
00921                             i__7].r, abs(d__3)) + (d__4 = d_imag(&h__[k + 1 + 
00922                             (k + 1) * h_dim1]), abs(d__4)));
00923                     if (tst1 == 0.) {
00924                         if (k >= *ktop + 1) {
00925                             i__5 = k + (k - 1) * h_dim1;
00926                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00927                                     d_imag(&h__[k + (k - 1) * h_dim1]), abs(
00928                                     d__2));
00929                         }
00930                         if (k >= *ktop + 2) {
00931                             i__5 = k + (k - 2) * h_dim1;
00932                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00933                                     d_imag(&h__[k + (k - 2) * h_dim1]), abs(
00934                                     d__2));
00935                         }
00936                         if (k >= *ktop + 3) {
00937                             i__5 = k + (k - 3) * h_dim1;
00938                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00939                                     d_imag(&h__[k + (k - 3) * h_dim1]), abs(
00940                                     d__2));
00941                         }
00942                         if (k <= *kbot - 2) {
00943                             i__5 = k + 2 + (k + 1) * h_dim1;
00944                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00945                                     d_imag(&h__[k + 2 + (k + 1) * h_dim1]), 
00946                                     abs(d__2));
00947                         }
00948                         if (k <= *kbot - 3) {
00949                             i__5 = k + 3 + (k + 1) * h_dim1;
00950                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00951                                     d_imag(&h__[k + 3 + (k + 1) * h_dim1]), 
00952                                     abs(d__2));
00953                         }
00954                         if (k <= *kbot - 4) {
00955                             i__5 = k + 4 + (k + 1) * h_dim1;
00956                             tst1 += (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00957                                     d_imag(&h__[k + 4 + (k + 1) * h_dim1]), 
00958                                     abs(d__2));
00959                         }
00960                     }
00961                     i__5 = k + 1 + k * h_dim1;
00962 /* Computing MAX */
00963                     d__3 = smlnum, d__4 = ulp * tst1;
00964                     if ((d__1 = h__[i__5].r, abs(d__1)) + (d__2 = d_imag(&h__[
00965                             k + 1 + k * h_dim1]), abs(d__2)) <= max(d__3,d__4)
00966                             ) {
00967 /* Computing MAX */
00968                         i__5 = k + 1 + k * h_dim1;
00969                         i__7 = k + (k + 1) * h_dim1;
00970                         d__5 = (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00971                                 d_imag(&h__[k + 1 + k * h_dim1]), abs(d__2)), 
00972                                 d__6 = (d__3 = h__[i__7].r, abs(d__3)) + (
00973                                 d__4 = d_imag(&h__[k + (k + 1) * h_dim1]), 
00974                                 abs(d__4));
00975                         h12 = max(d__5,d__6);
00976 /* Computing MIN */
00977                         i__5 = k + 1 + k * h_dim1;
00978                         i__7 = k + (k + 1) * h_dim1;
00979                         d__5 = (d__1 = h__[i__5].r, abs(d__1)) + (d__2 = 
00980                                 d_imag(&h__[k + 1 + k * h_dim1]), abs(d__2)), 
00981                                 d__6 = (d__3 = h__[i__7].r, abs(d__3)) + (
00982                                 d__4 = d_imag(&h__[k + (k + 1) * h_dim1]), 
00983                                 abs(d__4));
00984                         h21 = min(d__5,d__6);
00985                         i__5 = k + k * h_dim1;
00986                         i__7 = k + 1 + (k + 1) * h_dim1;
00987                         z__2.r = h__[i__5].r - h__[i__7].r, z__2.i = h__[i__5]
00988                                 .i - h__[i__7].i;
00989                         z__1.r = z__2.r, z__1.i = z__2.i;
00990 /* Computing MAX */
00991                         i__6 = k + 1 + (k + 1) * h_dim1;
00992                         d__5 = (d__1 = h__[i__6].r, abs(d__1)) + (d__2 = 
00993                                 d_imag(&h__[k + 1 + (k + 1) * h_dim1]), abs(
00994                                 d__2)), d__6 = (d__3 = z__1.r, abs(d__3)) + (
00995                                 d__4 = d_imag(&z__1), abs(d__4));
00996                         h11 = max(d__5,d__6);
00997                         i__5 = k + k * h_dim1;
00998                         i__7 = k + 1 + (k + 1) * h_dim1;
00999                         z__2.r = h__[i__5].r - h__[i__7].r, z__2.i = h__[i__5]
01000                                 .i - h__[i__7].i;
01001                         z__1.r = z__2.r, z__1.i = z__2.i;
01002 /* Computing MIN */
01003                         i__6 = k + 1 + (k + 1) * h_dim1;
01004                         d__5 = (d__1 = h__[i__6].r, abs(d__1)) + (d__2 = 
01005                                 d_imag(&h__[k + 1 + (k + 1) * h_dim1]), abs(
01006                                 d__2)), d__6 = (d__3 = z__1.r, abs(d__3)) + (
01007                                 d__4 = d_imag(&z__1), abs(d__4));
01008                         h22 = min(d__5,d__6);
01009                         scl = h11 + h12;
01010                         tst2 = h22 * (h11 / scl);
01011 
01012 /* Computing MAX */
01013                         d__1 = smlnum, d__2 = ulp * tst2;
01014                         if (tst2 == 0. || h21 * (h12 / scl) <= max(d__1,d__2))
01015                                  {
01016                             i__5 = k + 1 + k * h_dim1;
01017                             h__[i__5].r = 0., h__[i__5].i = 0.;
01018                         }
01019                     }
01020                 }
01021 /* L120: */
01022             }
01023 
01024 /*           ==== Fill in the last row of each bulge. ==== */
01025 
01026 /* Computing MIN */
01027             i__4 = nbmps, i__5 = (*kbot - krcol - 1) / 3;
01028             mend = min(i__4,i__5);
01029             i__4 = mend;
01030             for (m = mtop; m <= i__4; ++m) {
01031                 k = krcol + (m - 1) * 3;
01032                 i__5 = m * v_dim1 + 1;
01033                 i__7 = m * v_dim1 + 3;
01034                 z__2.r = v[i__5].r * v[i__7].r - v[i__5].i * v[i__7].i, 
01035                         z__2.i = v[i__5].r * v[i__7].i + v[i__5].i * v[i__7]
01036                         .r;
01037                 i__6 = k + 4 + (k + 3) * h_dim1;
01038                 z__1.r = z__2.r * h__[i__6].r - z__2.i * h__[i__6].i, z__1.i =
01039                          z__2.r * h__[i__6].i + z__2.i * h__[i__6].r;
01040                 refsum.r = z__1.r, refsum.i = z__1.i;
01041                 i__5 = k + 4 + (k + 1) * h_dim1;
01042                 z__1.r = -refsum.r, z__1.i = -refsum.i;
01043                 h__[i__5].r = z__1.r, h__[i__5].i = z__1.i;
01044                 i__5 = k + 4 + (k + 2) * h_dim1;
01045                 z__2.r = -refsum.r, z__2.i = -refsum.i;
01046                 d_cnjg(&z__3, &v[m * v_dim1 + 2]);
01047                 z__1.r = z__2.r * z__3.r - z__2.i * z__3.i, z__1.i = z__2.r * 
01048                         z__3.i + z__2.i * z__3.r;
01049                 h__[i__5].r = z__1.r, h__[i__5].i = z__1.i;
01050                 i__5 = k + 4 + (k + 3) * h_dim1;
01051                 i__7 = k + 4 + (k + 3) * h_dim1;
01052                 d_cnjg(&z__3, &v[m * v_dim1 + 3]);
01053                 z__2.r = refsum.r * z__3.r - refsum.i * z__3.i, z__2.i = 
01054                         refsum.r * z__3.i + refsum.i * z__3.r;
01055                 z__1.r = h__[i__7].r - z__2.r, z__1.i = h__[i__7].i - z__2.i;
01056                 h__[i__5].r = z__1.r, h__[i__5].i = z__1.i;
01057 /* L130: */
01058             }
01059 
01060 /*           ==== End of near-the-diagonal bulge chase. ==== */
01061 
01062 /* L140: */
01063         }
01064 
01065 /*        ==== Use U (if accumulated) to update far-from-diagonal */
01066 /*        .    entries in H.  If required, use U to update Z as */
01067 /*        .    well. ==== */
01068 
01069         if (accum) {
01070             if (*wantt) {
01071                 jtop = 1;
01072                 jbot = *n;
01073             } else {
01074                 jtop = *ktop;
01075                 jbot = *kbot;
01076             }
01077             if (! blk22 || incol < *ktop || ndcol > *kbot || ns <= 2) {
01078 
01079 /*              ==== Updates not exploiting the 2-by-2 block */
01080 /*              .    structure of U.  K1 and NU keep track of */
01081 /*              .    the location and size of U in the special */
01082 /*              .    cases of introducing bulges and chasing */
01083 /*              .    bulges off the bottom.  In these special */
01084 /*              .    cases and in case the number of shifts */
01085 /*              .    is NS = 2, there is no 2-by-2 block */
01086 /*              .    structure to exploit.  ==== */
01087 
01088 /* Computing MAX */
01089                 i__3 = 1, i__4 = *ktop - incol;
01090                 k1 = max(i__3,i__4);
01091 /* Computing MAX */
01092                 i__3 = 0, i__4 = ndcol - *kbot;
01093                 nu = kdu - max(i__3,i__4) - k1 + 1;
01094 
01095 /*              ==== Horizontal Multiply ==== */
01096 
01097                 i__3 = jbot;
01098                 i__4 = *nh;
01099                 for (jcol = min(ndcol,*kbot) + 1; i__4 < 0 ? jcol >= i__3 : 
01100                         jcol <= i__3; jcol += i__4) {
01101 /* Computing MIN */
01102                     i__5 = *nh, i__7 = jbot - jcol + 1;
01103                     jlen = min(i__5,i__7);
01104                     zgemm_("C", "N", &nu, &jlen, &nu, &c_b2, &u[k1 + k1 * 
01105                             u_dim1], ldu, &h__[incol + k1 + jcol * h_dim1], 
01106                             ldh, &c_b1, &wh[wh_offset], ldwh);
01107                     zlacpy_("ALL", &nu, &jlen, &wh[wh_offset], ldwh, &h__[
01108                             incol + k1 + jcol * h_dim1], ldh);
01109 /* L150: */
01110                 }
01111 
01112 /*              ==== Vertical multiply ==== */
01113 
01114                 i__4 = max(*ktop,incol) - 1;
01115                 i__3 = *nv;
01116                 for (jrow = jtop; i__3 < 0 ? jrow >= i__4 : jrow <= i__4; 
01117                         jrow += i__3) {
01118 /* Computing MIN */
01119                     i__5 = *nv, i__7 = max(*ktop,incol) - jrow;
01120                     jlen = min(i__5,i__7);
01121                     zgemm_("N", "N", &jlen, &nu, &nu, &c_b2, &h__[jrow + (
01122                             incol + k1) * h_dim1], ldh, &u[k1 + k1 * u_dim1], 
01123                             ldu, &c_b1, &wv[wv_offset], ldwv);
01124                     zlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &h__[
01125                             jrow + (incol + k1) * h_dim1], ldh);
01126 /* L160: */
01127                 }
01128 
01129 /*              ==== Z multiply (also vertical) ==== */
01130 
01131                 if (*wantz) {
01132                     i__3 = *ihiz;
01133                     i__4 = *nv;
01134                     for (jrow = *iloz; i__4 < 0 ? jrow >= i__3 : jrow <= i__3;
01135                              jrow += i__4) {
01136 /* Computing MIN */
01137                         i__5 = *nv, i__7 = *ihiz - jrow + 1;
01138                         jlen = min(i__5,i__7);
01139                         zgemm_("N", "N", &jlen, &nu, &nu, &c_b2, &z__[jrow + (
01140                                 incol + k1) * z_dim1], ldz, &u[k1 + k1 * 
01141                                 u_dim1], ldu, &c_b1, &wv[wv_offset], ldwv);
01142                         zlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &z__[
01143                                 jrow + (incol + k1) * z_dim1], ldz)
01144                                 ;
01145 /* L170: */
01146                     }
01147                 }
01148             } else {
01149 
01150 /*              ==== Updates exploiting U's 2-by-2 block structure. */
01151 /*              .    (I2, I4, J2, J4 are the last rows and columns */
01152 /*              .    of the blocks.) ==== */
01153 
01154                 i2 = (kdu + 1) / 2;
01155                 i4 = kdu;
01156                 j2 = i4 - i2;
01157                 j4 = kdu;
01158 
01159 /*              ==== KZS and KNZ deal with the band of zeros */
01160 /*              .    along the diagonal of one of the triangular */
01161 /*              .    blocks. ==== */
01162 
01163                 kzs = j4 - j2 - (ns + 1);
01164                 knz = ns + 1;
01165 
01166 /*              ==== Horizontal multiply ==== */
01167 
01168                 i__4 = jbot;
01169                 i__3 = *nh;
01170                 for (jcol = min(ndcol,*kbot) + 1; i__3 < 0 ? jcol >= i__4 : 
01171                         jcol <= i__4; jcol += i__3) {
01172 /* Computing MIN */
01173                     i__5 = *nh, i__7 = jbot - jcol + 1;
01174                     jlen = min(i__5,i__7);
01175 
01176 /*                 ==== Copy bottom of H to top+KZS of scratch ==== */
01177 /*                  (The first KZS rows get multiplied by zero.) ==== */
01178 
01179                     zlacpy_("ALL", &knz, &jlen, &h__[incol + 1 + j2 + jcol * 
01180                             h_dim1], ldh, &wh[kzs + 1 + wh_dim1], ldwh);
01181 
01182 /*                 ==== Multiply by U21' ==== */
01183 
01184                     zlaset_("ALL", &kzs, &jlen, &c_b1, &c_b1, &wh[wh_offset], 
01185                             ldwh);
01186                     ztrmm_("L", "U", "C", "N", &knz, &jlen, &c_b2, &u[j2 + 1 
01187                             + (kzs + 1) * u_dim1], ldu, &wh[kzs + 1 + wh_dim1]
01188 , ldwh);
01189 
01190 /*                 ==== Multiply top of H by U11' ==== */
01191 
01192                     zgemm_("C", "N", &i2, &jlen, &j2, &c_b2, &u[u_offset], 
01193                             ldu, &h__[incol + 1 + jcol * h_dim1], ldh, &c_b2, 
01194                             &wh[wh_offset], ldwh);
01195 
01196 /*                 ==== Copy top of H to bottom of WH ==== */
01197 
01198                     zlacpy_("ALL", &j2, &jlen, &h__[incol + 1 + jcol * h_dim1]
01199 , ldh, &wh[i2 + 1 + wh_dim1], ldwh);
01200 
01201 /*                 ==== Multiply by U21' ==== */
01202 
01203                     ztrmm_("L", "L", "C", "N", &j2, &jlen, &c_b2, &u[(i2 + 1) 
01204                             * u_dim1 + 1], ldu, &wh[i2 + 1 + wh_dim1], ldwh);
01205 
01206 /*                 ==== Multiply by U22 ==== */
01207 
01208                     i__5 = i4 - i2;
01209                     i__7 = j4 - j2;
01210                     zgemm_("C", "N", &i__5, &jlen, &i__7, &c_b2, &u[j2 + 1 + (
01211                             i2 + 1) * u_dim1], ldu, &h__[incol + 1 + j2 + 
01212                             jcol * h_dim1], ldh, &c_b2, &wh[i2 + 1 + wh_dim1], 
01213                              ldwh);
01214 
01215 /*                 ==== Copy it back ==== */
01216 
01217                     zlacpy_("ALL", &kdu, &jlen, &wh[wh_offset], ldwh, &h__[
01218                             incol + 1 + jcol * h_dim1], ldh);
01219 /* L180: */
01220                 }
01221 
01222 /*              ==== Vertical multiply ==== */
01223 
01224                 i__3 = max(incol,*ktop) - 1;
01225                 i__4 = *nv;
01226                 for (jrow = jtop; i__4 < 0 ? jrow >= i__3 : jrow <= i__3; 
01227                         jrow += i__4) {
01228 /* Computing MIN */
01229                     i__5 = *nv, i__7 = max(incol,*ktop) - jrow;
01230                     jlen = min(i__5,i__7);
01231 
01232 /*                 ==== Copy right of H to scratch (the first KZS */
01233 /*                 .    columns get multiplied by zero) ==== */
01234 
01235                     zlacpy_("ALL", &jlen, &knz, &h__[jrow + (incol + 1 + j2) *
01236                              h_dim1], ldh, &wv[(kzs + 1) * wv_dim1 + 1], ldwv);
01237 
01238 /*                 ==== Multiply by U21 ==== */
01239 
01240                     zlaset_("ALL", &jlen, &kzs, &c_b1, &c_b1, &wv[wv_offset], 
01241                             ldwv);
01242                     ztrmm_("R", "U", "N", "N", &jlen, &knz, &c_b2, &u[j2 + 1 
01243                             + (kzs + 1) * u_dim1], ldu, &wv[(kzs + 1) * 
01244                             wv_dim1 + 1], ldwv);
01245 
01246 /*                 ==== Multiply by U11 ==== */
01247 
01248                     zgemm_("N", "N", &jlen, &i2, &j2, &c_b2, &h__[jrow + (
01249                             incol + 1) * h_dim1], ldh, &u[u_offset], ldu, &
01250                             c_b2, &wv[wv_offset], ldwv);
01251 
01252 /*                 ==== Copy left of H to right of scratch ==== */
01253 
01254                     zlacpy_("ALL", &jlen, &j2, &h__[jrow + (incol + 1) * 
01255                             h_dim1], ldh, &wv[(i2 + 1) * wv_dim1 + 1], ldwv);
01256 
01257 /*                 ==== Multiply by U21 ==== */
01258 
01259                     i__5 = i4 - i2;
01260                     ztrmm_("R", "L", "N", "N", &jlen, &i__5, &c_b2, &u[(i2 + 
01261                             1) * u_dim1 + 1], ldu, &wv[(i2 + 1) * wv_dim1 + 1]
01262 , ldwv);
01263 
01264 /*                 ==== Multiply by U22 ==== */
01265 
01266                     i__5 = i4 - i2;
01267                     i__7 = j4 - j2;
01268                     zgemm_("N", "N", &jlen, &i__5, &i__7, &c_b2, &h__[jrow + (
01269                             incol + 1 + j2) * h_dim1], ldh, &u[j2 + 1 + (i2 + 
01270                             1) * u_dim1], ldu, &c_b2, &wv[(i2 + 1) * wv_dim1 
01271                             + 1], ldwv);
01272 
01273 /*                 ==== Copy it back ==== */
01274 
01275                     zlacpy_("ALL", &jlen, &kdu, &wv[wv_offset], ldwv, &h__[
01276                             jrow + (incol + 1) * h_dim1], ldh);
01277 /* L190: */
01278                 }
01279 
01280 /*              ==== Multiply Z (also vertical) ==== */
01281 
01282                 if (*wantz) {
01283                     i__4 = *ihiz;
01284                     i__3 = *nv;
01285                     for (jrow = *iloz; i__3 < 0 ? jrow >= i__4 : jrow <= i__4;
01286                              jrow += i__3) {
01287 /* Computing MIN */
01288                         i__5 = *nv, i__7 = *ihiz - jrow + 1;
01289                         jlen = min(i__5,i__7);
01290 
01291 /*                    ==== Copy right of Z to left of scratch (first */
01292 /*                    .     KZS columns get multiplied by zero) ==== */
01293 
01294                         zlacpy_("ALL", &jlen, &knz, &z__[jrow + (incol + 1 + 
01295                                 j2) * z_dim1], ldz, &wv[(kzs + 1) * wv_dim1 + 
01296                                 1], ldwv);
01297 
01298 /*                    ==== Multiply by U12 ==== */
01299 
01300                         zlaset_("ALL", &jlen, &kzs, &c_b1, &c_b1, &wv[
01301                                 wv_offset], ldwv);
01302                         ztrmm_("R", "U", "N", "N", &jlen, &knz, &c_b2, &u[j2 
01303                                 + 1 + (kzs + 1) * u_dim1], ldu, &wv[(kzs + 1) 
01304                                 * wv_dim1 + 1], ldwv);
01305 
01306 /*                    ==== Multiply by U11 ==== */
01307 
01308                         zgemm_("N", "N", &jlen, &i2, &j2, &c_b2, &z__[jrow + (
01309                                 incol + 1) * z_dim1], ldz, &u[u_offset], ldu, 
01310                                 &c_b2, &wv[wv_offset], ldwv);
01311 
01312 /*                    ==== Copy left of Z to right of scratch ==== */
01313 
01314                         zlacpy_("ALL", &jlen, &j2, &z__[jrow + (incol + 1) * 
01315                                 z_dim1], ldz, &wv[(i2 + 1) * wv_dim1 + 1], 
01316                                 ldwv);
01317 
01318 /*                    ==== Multiply by U21 ==== */
01319 
01320                         i__5 = i4 - i2;
01321                         ztrmm_("R", "L", "N", "N", &jlen, &i__5, &c_b2, &u[(
01322                                 i2 + 1) * u_dim1 + 1], ldu, &wv[(i2 + 1) * 
01323                                 wv_dim1 + 1], ldwv);
01324 
01325 /*                    ==== Multiply by U22 ==== */
01326 
01327                         i__5 = i4 - i2;
01328                         i__7 = j4 - j2;
01329                         zgemm_("N", "N", &jlen, &i__5, &i__7, &c_b2, &z__[
01330                                 jrow + (incol + 1 + j2) * z_dim1], ldz, &u[j2 
01331                                 + 1 + (i2 + 1) * u_dim1], ldu, &c_b2, &wv[(i2 
01332                                 + 1) * wv_dim1 + 1], ldwv);
01333 
01334 /*                    ==== Copy the result back to Z ==== */
01335 
01336                         zlacpy_("ALL", &jlen, &kdu, &wv[wv_offset], ldwv, &
01337                                 z__[jrow + (incol + 1) * z_dim1], ldz);
01338 /* L200: */
01339                     }
01340                 }
01341             }
01342         }
01343 /* L210: */
01344     }
01345 
01346 /*     ==== End of ZLAQR5 ==== */
01347 
01348     return 0;
01349 } /* zlaqr5_ */


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