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


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