clahqr.c
Go to the documentation of this file.
00001 /* clahqr.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static integer c__2 = 2;
00020 
00021 /* Subroutine */ int clahqr_(logical *wantt, logical *wantz, integer *n, 
00022         integer *ilo, integer *ihi, complex *h__, integer *ldh, complex *w, 
00023         integer *iloz, integer *ihiz, complex *z__, integer *ldz, integer *
00024         info)
00025 {
00026     /* System generated locals */
00027     integer h_dim1, h_offset, z_dim1, z_offset, i__1, i__2, i__3, i__4;
00028     real r__1, r__2, r__3, r__4, r__5, r__6;
00029     complex q__1, q__2, q__3, q__4, q__5, q__6, q__7;
00030 
00031     /* Builtin functions */
00032     double r_imag(complex *);
00033     void r_cnjg(complex *, complex *);
00034     double c_abs(complex *);
00035     void c_sqrt(complex *, complex *), pow_ci(complex *, complex *, integer *)
00036             ;
00037 
00038     /* Local variables */
00039     integer i__, j, k, l, m;
00040     real s;
00041     complex t, u, v[2], x, y;
00042     integer i1, i2;
00043     complex t1;
00044     real t2;
00045     complex v2;
00046     real aa, ab, ba, bb, h10;
00047     complex h11;
00048     real h21;
00049     complex h22, sc;
00050     integer nh, nz;
00051     real sx;
00052     integer jhi;
00053     complex h11s;
00054     integer jlo, its;
00055     real ulp;
00056     complex sum;
00057     real tst;
00058     complex temp;
00059     extern /* Subroutine */ int cscal_(integer *, complex *, complex *, 
00060             integer *), ccopy_(integer *, complex *, integer *, complex *, 
00061             integer *);
00062     real rtemp;
00063     extern /* Subroutine */ int slabad_(real *, real *), clarfg_(integer *, 
00064             complex *, complex *, integer *, complex *);
00065     extern /* Complex */ VOID cladiv_(complex *, complex *, complex *);
00066     extern doublereal slamch_(char *);
00067     real safmin, safmax, smlnum;
00068 
00069 
00070 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00071 /*     Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
00072 /*     November 2006 */
00073 
00074 /*     .. Scalar Arguments .. */
00075 /*     .. */
00076 /*     .. Array Arguments .. */
00077 /*     .. */
00078 
00079 /*     Purpose */
00080 /*     ======= */
00081 
00082 /*     CLAHQR is an auxiliary routine called by CHSEQR to update the */
00083 /*     eigenvalues and Schur decomposition already computed by CHSEQR, by */
00084 /*     dealing with the Hessenberg submatrix in rows and columns ILO to */
00085 /*     IHI. */
00086 
00087 /*     Arguments */
00088 /*     ========= */
00089 
00090 /*     WANTT   (input) LOGICAL */
00091 /*          = .TRUE. : the full Schur form T is required; */
00092 /*          = .FALSE.: only eigenvalues are required. */
00093 
00094 /*     WANTZ   (input) LOGICAL */
00095 /*          = .TRUE. : the matrix of Schur vectors Z is required; */
00096 /*          = .FALSE.: Schur vectors are not required. */
00097 
00098 /*     N       (input) INTEGER */
00099 /*          The order of the matrix H.  N >= 0. */
00100 
00101 /*     ILO     (input) INTEGER */
00102 /*     IHI     (input) INTEGER */
00103 /*          It is assumed that H is already upper triangular in rows and */
00104 /*          columns IHI+1:N, and that H(ILO,ILO-1) = 0 (unless ILO = 1). */
00105 /*          CLAHQR works primarily with the Hessenberg submatrix in rows */
00106 /*          and columns ILO to IHI, but applies transformations to all of */
00107 /*          H if WANTT is .TRUE.. */
00108 /*          1 <= ILO <= max(1,IHI); IHI <= N. */
00109 
00110 /*     H       (input/output) COMPLEX array, dimension (LDH,N) */
00111 /*          On entry, the upper Hessenberg matrix H. */
00112 /*          On exit, if INFO is zero and if WANTT is .TRUE., then H */
00113 /*          is upper triangular in rows and columns ILO:IHI.  If INFO */
00114 /*          is zero and if WANTT is .FALSE., then the contents of H */
00115 /*          are unspecified on exit.  The output state of H in case */
00116 /*          INF is positive is below under the description of INFO. */
00117 
00118 /*     LDH     (input) INTEGER */
00119 /*          The leading dimension of the array H. LDH >= max(1,N). */
00120 
00121 /*     W       (output) COMPLEX array, dimension (N) */
00122 /*          The computed eigenvalues ILO to IHI are stored in the */
00123 /*          corresponding elements of W. If WANTT is .TRUE., the */
00124 /*          eigenvalues are stored in the same order as on the diagonal */
00125 /*          of the Schur form returned in H, with W(i) = H(i,i). */
00126 
00127 /*     ILOZ    (input) INTEGER */
00128 /*     IHIZ    (input) INTEGER */
00129 /*          Specify the rows of Z to which transformations must be */
00130 /*          applied if WANTZ is .TRUE.. */
00131 /*          1 <= ILOZ <= ILO; IHI <= IHIZ <= N. */
00132 
00133 /*     Z       (input/output) COMPLEX array, dimension (LDZ,N) */
00134 /*          If WANTZ is .TRUE., on entry Z must contain the current */
00135 /*          matrix Z of transformations accumulated by CHSEQR, and on */
00136 /*          exit Z has been updated; transformations are applied only to */
00137 /*          the submatrix Z(ILOZ:IHIZ,ILO:IHI). */
00138 /*          If WANTZ is .FALSE., Z is not referenced. */
00139 
00140 /*     LDZ     (input) INTEGER */
00141 /*          The leading dimension of the array Z. LDZ >= max(1,N). */
00142 
00143 /*     INFO    (output) INTEGER */
00144 /*           =   0: successful exit */
00145 /*          .GT. 0: if INFO = i, CLAHQR failed to compute all the */
00146 /*                  eigenvalues ILO to IHI in a total of 30 iterations */
00147 /*                  per eigenvalue; elements i+1:ihi of W contain */
00148 /*                  those eigenvalues which have been successfully */
00149 /*                  computed. */
00150 
00151 /*                  If INFO .GT. 0 and WANTT is .FALSE., then on exit, */
00152 /*                  the remaining unconverged eigenvalues are the */
00153 /*                  eigenvalues of the upper Hessenberg matrix */
00154 /*                  rows and columns ILO thorugh INFO of the final, */
00155 /*                  output value of H. */
00156 
00157 /*                  If INFO .GT. 0 and WANTT is .TRUE., then on exit */
00158 /*          (*)       (initial value of H)*U  = U*(final value of H) */
00159 /*                  where U is an orthognal matrix.    The final */
00160 /*                  value of H is upper Hessenberg and triangular in */
00161 /*                  rows and columns INFO+1 through IHI. */
00162 
00163 /*                  If INFO .GT. 0 and WANTZ is .TRUE., then on exit */
00164 /*                      (final value of Z)  = (initial value of Z)*U */
00165 /*                  where U is the orthogonal matrix in (*) */
00166 /*                  (regardless of the value of WANTT.) */
00167 
00168 /*     Further Details */
00169 /*     =============== */
00170 
00171 /*     02-96 Based on modifications by */
00172 /*     David Day, Sandia National Laboratory, USA */
00173 
00174 /*     12-04 Further modifications by */
00175 /*     Ralph Byers, University of Kansas, USA */
00176 /*     This is a modified version of CLAHQR from LAPACK version 3.0. */
00177 /*     It is (1) more robust against overflow and underflow and */
00178 /*     (2) adopts the more conservative Ahues & Tisseur stopping */
00179 /*     criterion (LAWN 122, 1997). */
00180 
00181 /*     ========================================================= */
00182 
00183 /*     .. Parameters .. */
00184 /*     .. */
00185 /*     .. Local Scalars .. */
00186 /*     .. */
00187 /*     .. Local Arrays .. */
00188 /*     .. */
00189 /*     .. External Functions .. */
00190 /*     .. */
00191 /*     .. External Subroutines .. */
00192 /*     .. */
00193 /*     .. Statement Functions .. */
00194 /*     .. */
00195 /*     .. Intrinsic Functions .. */
00196 /*     .. */
00197 /*     .. Statement Function definitions .. */
00198 /*     .. */
00199 /*     .. Executable Statements .. */
00200 
00201     /* Parameter adjustments */
00202     h_dim1 = *ldh;
00203     h_offset = 1 + h_dim1;
00204     h__ -= h_offset;
00205     --w;
00206     z_dim1 = *ldz;
00207     z_offset = 1 + z_dim1;
00208     z__ -= z_offset;
00209 
00210     /* Function Body */
00211     *info = 0;
00212 
00213 /*     Quick return if possible */
00214 
00215     if (*n == 0) {
00216         return 0;
00217     }
00218     if (*ilo == *ihi) {
00219         i__1 = *ilo;
00220         i__2 = *ilo + *ilo * h_dim1;
00221         w[i__1].r = h__[i__2].r, w[i__1].i = h__[i__2].i;
00222         return 0;
00223     }
00224 
00225 /*     ==== clear out the trash ==== */
00226     i__1 = *ihi - 3;
00227     for (j = *ilo; j <= i__1; ++j) {
00228         i__2 = j + 2 + j * h_dim1;
00229         h__[i__2].r = 0.f, h__[i__2].i = 0.f;
00230         i__2 = j + 3 + j * h_dim1;
00231         h__[i__2].r = 0.f, h__[i__2].i = 0.f;
00232 /* L10: */
00233     }
00234     if (*ilo <= *ihi - 2) {
00235         i__1 = *ihi + (*ihi - 2) * h_dim1;
00236         h__[i__1].r = 0.f, h__[i__1].i = 0.f;
00237     }
00238 /*     ==== ensure that subdiagonal entries are real ==== */
00239     if (*wantt) {
00240         jlo = 1;
00241         jhi = *n;
00242     } else {
00243         jlo = *ilo;
00244         jhi = *ihi;
00245     }
00246     i__1 = *ihi;
00247     for (i__ = *ilo + 1; i__ <= i__1; ++i__) {
00248         if (r_imag(&h__[i__ + (i__ - 1) * h_dim1]) != 0.f) {
00249 /*           ==== The following redundant normalization */
00250 /*           .    avoids problems with both gradual and */
00251 /*           .    sudden underflow in ABS(H(I,I-1)) ==== */
00252             i__2 = i__ + (i__ - 1) * h_dim1;
00253             i__3 = i__ + (i__ - 1) * h_dim1;
00254             r__3 = (r__1 = h__[i__3].r, dabs(r__1)) + (r__2 = r_imag(&h__[i__ 
00255                     + (i__ - 1) * h_dim1]), dabs(r__2));
00256             q__1.r = h__[i__2].r / r__3, q__1.i = h__[i__2].i / r__3;
00257             sc.r = q__1.r, sc.i = q__1.i;
00258             r_cnjg(&q__2, &sc);
00259             r__1 = c_abs(&sc);
00260             q__1.r = q__2.r / r__1, q__1.i = q__2.i / r__1;
00261             sc.r = q__1.r, sc.i = q__1.i;
00262             i__2 = i__ + (i__ - 1) * h_dim1;
00263             r__1 = c_abs(&h__[i__ + (i__ - 1) * h_dim1]);
00264             h__[i__2].r = r__1, h__[i__2].i = 0.f;
00265             i__2 = jhi - i__ + 1;
00266             cscal_(&i__2, &sc, &h__[i__ + i__ * h_dim1], ldh);
00267 /* Computing MIN */
00268             i__3 = jhi, i__4 = i__ + 1;
00269             i__2 = min(i__3,i__4) - jlo + 1;
00270             r_cnjg(&q__1, &sc);
00271             cscal_(&i__2, &q__1, &h__[jlo + i__ * h_dim1], &c__1);
00272             if (*wantz) {
00273                 i__2 = *ihiz - *iloz + 1;
00274                 r_cnjg(&q__1, &sc);
00275                 cscal_(&i__2, &q__1, &z__[*iloz + i__ * z_dim1], &c__1);
00276             }
00277         }
00278 /* L20: */
00279     }
00280 
00281     nh = *ihi - *ilo + 1;
00282     nz = *ihiz - *iloz + 1;
00283 
00284 /*     Set machine-dependent constants for the stopping criterion. */
00285 
00286     safmin = slamch_("SAFE MINIMUM");
00287     safmax = 1.f / safmin;
00288     slabad_(&safmin, &safmax);
00289     ulp = slamch_("PRECISION");
00290     smlnum = safmin * ((real) nh / ulp);
00291 
00292 /*     I1 and I2 are the indices of the first row and last column of H */
00293 /*     to which transformations must be applied. If eigenvalues only are */
00294 /*     being computed, I1 and I2 are set inside the main loop. */
00295 
00296     if (*wantt) {
00297         i1 = 1;
00298         i2 = *n;
00299     }
00300 
00301 /*     The main loop begins here. I is the loop index and decreases from */
00302 /*     IHI to ILO in steps of 1. Each iteration of the loop works */
00303 /*     with the active submatrix in rows and columns L to I. */
00304 /*     Eigenvalues I+1 to IHI have already converged. Either L = ILO, or */
00305 /*     H(L,L-1) is negligible so that the matrix splits. */
00306 
00307     i__ = *ihi;
00308 L30:
00309     if (i__ < *ilo) {
00310         goto L150;
00311     }
00312 
00313 /*     Perform QR iterations on rows and columns ILO to I until a */
00314 /*     submatrix of order 1 splits off at the bottom because a */
00315 /*     subdiagonal element has become negligible. */
00316 
00317     l = *ilo;
00318     for (its = 0; its <= 30; ++its) {
00319 
00320 /*        Look for a single small subdiagonal element. */
00321 
00322         i__1 = l + 1;
00323         for (k = i__; k >= i__1; --k) {
00324             i__2 = k + (k - 1) * h_dim1;
00325             if ((r__1 = h__[i__2].r, dabs(r__1)) + (r__2 = r_imag(&h__[k + (k 
00326                     - 1) * h_dim1]), dabs(r__2)) <= smlnum) {
00327                 goto L50;
00328             }
00329             i__2 = k - 1 + (k - 1) * h_dim1;
00330             i__3 = k + k * h_dim1;
00331             tst = (r__1 = h__[i__2].r, dabs(r__1)) + (r__2 = r_imag(&h__[k - 
00332                     1 + (k - 1) * h_dim1]), dabs(r__2)) + ((r__3 = h__[i__3]
00333                     .r, dabs(r__3)) + (r__4 = r_imag(&h__[k + k * h_dim1]), 
00334                     dabs(r__4)));
00335             if (tst == 0.f) {
00336                 if (k - 2 >= *ilo) {
00337                     i__2 = k - 1 + (k - 2) * h_dim1;
00338                     tst += (r__1 = h__[i__2].r, dabs(r__1));
00339                 }
00340                 if (k + 1 <= *ihi) {
00341                     i__2 = k + 1 + k * h_dim1;
00342                     tst += (r__1 = h__[i__2].r, dabs(r__1));
00343                 }
00344             }
00345 /*           ==== The following is a conservative small subdiagonal */
00346 /*           .    deflation criterion due to Ahues & Tisseur (LAWN 122, */
00347 /*           .    1997). It has better mathematical foundation and */
00348 /*           .    improves accuracy in some examples.  ==== */
00349             i__2 = k + (k - 1) * h_dim1;
00350             if ((r__1 = h__[i__2].r, dabs(r__1)) <= ulp * tst) {
00351 /* Computing MAX */
00352                 i__2 = k + (k - 1) * h_dim1;
00353                 i__3 = k - 1 + k * h_dim1;
00354                 r__5 = (r__1 = h__[i__2].r, dabs(r__1)) + (r__2 = r_imag(&h__[
00355                         k + (k - 1) * h_dim1]), dabs(r__2)), r__6 = (r__3 = 
00356                         h__[i__3].r, dabs(r__3)) + (r__4 = r_imag(&h__[k - 1 
00357                         + k * h_dim1]), dabs(r__4));
00358                 ab = dmax(r__5,r__6);
00359 /* Computing MIN */
00360                 i__2 = k + (k - 1) * h_dim1;
00361                 i__3 = k - 1 + k * h_dim1;
00362                 r__5 = (r__1 = h__[i__2].r, dabs(r__1)) + (r__2 = r_imag(&h__[
00363                         k + (k - 1) * h_dim1]), dabs(r__2)), r__6 = (r__3 = 
00364                         h__[i__3].r, dabs(r__3)) + (r__4 = r_imag(&h__[k - 1 
00365                         + k * h_dim1]), dabs(r__4));
00366                 ba = dmin(r__5,r__6);
00367                 i__2 = k - 1 + (k - 1) * h_dim1;
00368                 i__3 = k + k * h_dim1;
00369                 q__2.r = h__[i__2].r - h__[i__3].r, q__2.i = h__[i__2].i - 
00370                         h__[i__3].i;
00371                 q__1.r = q__2.r, q__1.i = q__2.i;
00372 /* Computing MAX */
00373                 i__4 = k + k * h_dim1;
00374                 r__5 = (r__1 = h__[i__4].r, dabs(r__1)) + (r__2 = r_imag(&h__[
00375                         k + k * h_dim1]), dabs(r__2)), r__6 = (r__3 = q__1.r, 
00376                         dabs(r__3)) + (r__4 = r_imag(&q__1), dabs(r__4));
00377                 aa = dmax(r__5,r__6);
00378                 i__2 = k - 1 + (k - 1) * h_dim1;
00379                 i__3 = k + k * h_dim1;
00380                 q__2.r = h__[i__2].r - h__[i__3].r, q__2.i = h__[i__2].i - 
00381                         h__[i__3].i;
00382                 q__1.r = q__2.r, q__1.i = q__2.i;
00383 /* Computing MIN */
00384                 i__4 = k + k * h_dim1;
00385                 r__5 = (r__1 = h__[i__4].r, dabs(r__1)) + (r__2 = r_imag(&h__[
00386                         k + k * h_dim1]), dabs(r__2)), r__6 = (r__3 = q__1.r, 
00387                         dabs(r__3)) + (r__4 = r_imag(&q__1), dabs(r__4));
00388                 bb = dmin(r__5,r__6);
00389                 s = aa + ab;
00390 /* Computing MAX */
00391                 r__1 = smlnum, r__2 = ulp * (bb * (aa / s));
00392                 if (ba * (ab / s) <= dmax(r__1,r__2)) {
00393                     goto L50;
00394                 }
00395             }
00396 /* L40: */
00397         }
00398 L50:
00399         l = k;
00400         if (l > *ilo) {
00401 
00402 /*           H(L,L-1) is negligible */
00403 
00404             i__1 = l + (l - 1) * h_dim1;
00405             h__[i__1].r = 0.f, h__[i__1].i = 0.f;
00406         }
00407 
00408 /*        Exit from loop if a submatrix of order 1 has split off. */
00409 
00410         if (l >= i__) {
00411             goto L140;
00412         }
00413 
00414 /*        Now the active submatrix is in rows and columns L to I. If */
00415 /*        eigenvalues only are being computed, only the active submatrix */
00416 /*        need be transformed. */
00417 
00418         if (! (*wantt)) {
00419             i1 = l;
00420             i2 = i__;
00421         }
00422 
00423         if (its == 10) {
00424 
00425 /*           Exceptional shift. */
00426 
00427             i__1 = l + 1 + l * h_dim1;
00428             s = (r__1 = h__[i__1].r, dabs(r__1)) * .75f;
00429             i__1 = l + l * h_dim1;
00430             q__1.r = s + h__[i__1].r, q__1.i = h__[i__1].i;
00431             t.r = q__1.r, t.i = q__1.i;
00432         } else if (its == 20) {
00433 
00434 /*           Exceptional shift. */
00435 
00436             i__1 = i__ + (i__ - 1) * h_dim1;
00437             s = (r__1 = h__[i__1].r, dabs(r__1)) * .75f;
00438             i__1 = i__ + i__ * h_dim1;
00439             q__1.r = s + h__[i__1].r, q__1.i = h__[i__1].i;
00440             t.r = q__1.r, t.i = q__1.i;
00441         } else {
00442 
00443 /*           Wilkinson's shift. */
00444 
00445             i__1 = i__ + i__ * h_dim1;
00446             t.r = h__[i__1].r, t.i = h__[i__1].i;
00447             c_sqrt(&q__2, &h__[i__ - 1 + i__ * h_dim1]);
00448             c_sqrt(&q__3, &h__[i__ + (i__ - 1) * h_dim1]);
00449             q__1.r = q__2.r * q__3.r - q__2.i * q__3.i, q__1.i = q__2.r * 
00450                     q__3.i + q__2.i * q__3.r;
00451             u.r = q__1.r, u.i = q__1.i;
00452             s = (r__1 = u.r, dabs(r__1)) + (r__2 = r_imag(&u), dabs(r__2));
00453             if (s != 0.f) {
00454                 i__1 = i__ - 1 + (i__ - 1) * h_dim1;
00455                 q__2.r = h__[i__1].r - t.r, q__2.i = h__[i__1].i - t.i;
00456                 q__1.r = q__2.r * .5f, q__1.i = q__2.i * .5f;
00457                 x.r = q__1.r, x.i = q__1.i;
00458                 sx = (r__1 = x.r, dabs(r__1)) + (r__2 = r_imag(&x), dabs(r__2)
00459                         );
00460 /* Computing MAX */
00461                 r__3 = s, r__4 = (r__1 = x.r, dabs(r__1)) + (r__2 = r_imag(&x)
00462                         , dabs(r__2));
00463                 s = dmax(r__3,r__4);
00464                 q__5.r = x.r / s, q__5.i = x.i / s;
00465                 pow_ci(&q__4, &q__5, &c__2);
00466                 q__7.r = u.r / s, q__7.i = u.i / s;
00467                 pow_ci(&q__6, &q__7, &c__2);
00468                 q__3.r = q__4.r + q__6.r, q__3.i = q__4.i + q__6.i;
00469                 c_sqrt(&q__2, &q__3);
00470                 q__1.r = s * q__2.r, q__1.i = s * q__2.i;
00471                 y.r = q__1.r, y.i = q__1.i;
00472                 if (sx > 0.f) {
00473                     q__1.r = x.r / sx, q__1.i = x.i / sx;
00474                     q__2.r = x.r / sx, q__2.i = x.i / sx;
00475                     if (q__1.r * y.r + r_imag(&q__2) * r_imag(&y) < 0.f) {
00476                         q__3.r = -y.r, q__3.i = -y.i;
00477                         y.r = q__3.r, y.i = q__3.i;
00478                     }
00479                 }
00480                 q__4.r = x.r + y.r, q__4.i = x.i + y.i;
00481                 cladiv_(&q__3, &u, &q__4);
00482                 q__2.r = u.r * q__3.r - u.i * q__3.i, q__2.i = u.r * q__3.i + 
00483                         u.i * q__3.r;
00484                 q__1.r = t.r - q__2.r, q__1.i = t.i - q__2.i;
00485                 t.r = q__1.r, t.i = q__1.i;
00486             }
00487         }
00488 
00489 /*        Look for two consecutive small subdiagonal elements. */
00490 
00491         i__1 = l + 1;
00492         for (m = i__ - 1; m >= i__1; --m) {
00493 
00494 /*           Determine the effect of starting the single-shift QR */
00495 /*           iteration at row M, and see if this would make H(M,M-1) */
00496 /*           negligible. */
00497 
00498             i__2 = m + m * h_dim1;
00499             h11.r = h__[i__2].r, h11.i = h__[i__2].i;
00500             i__2 = m + 1 + (m + 1) * h_dim1;
00501             h22.r = h__[i__2].r, h22.i = h__[i__2].i;
00502             q__1.r = h11.r - t.r, q__1.i = h11.i - t.i;
00503             h11s.r = q__1.r, h11s.i = q__1.i;
00504             i__2 = m + 1 + m * h_dim1;
00505             h21 = h__[i__2].r;
00506             s = (r__1 = h11s.r, dabs(r__1)) + (r__2 = r_imag(&h11s), dabs(
00507                     r__2)) + dabs(h21);
00508             q__1.r = h11s.r / s, q__1.i = h11s.i / s;
00509             h11s.r = q__1.r, h11s.i = q__1.i;
00510             h21 /= s;
00511             v[0].r = h11s.r, v[0].i = h11s.i;
00512             v[1].r = h21, v[1].i = 0.f;
00513             i__2 = m + (m - 1) * h_dim1;
00514             h10 = h__[i__2].r;
00515             if (dabs(h10) * dabs(h21) <= ulp * (((r__1 = h11s.r, dabs(r__1)) 
00516                     + (r__2 = r_imag(&h11s), dabs(r__2))) * ((r__3 = h11.r, 
00517                     dabs(r__3)) + (r__4 = r_imag(&h11), dabs(r__4)) + ((r__5 =
00518                      h22.r, dabs(r__5)) + (r__6 = r_imag(&h22), dabs(r__6)))))
00519                     ) {
00520                 goto L70;
00521             }
00522 /* L60: */
00523         }
00524         i__1 = l + l * h_dim1;
00525         h11.r = h__[i__1].r, h11.i = h__[i__1].i;
00526         i__1 = l + 1 + (l + 1) * h_dim1;
00527         h22.r = h__[i__1].r, h22.i = h__[i__1].i;
00528         q__1.r = h11.r - t.r, q__1.i = h11.i - t.i;
00529         h11s.r = q__1.r, h11s.i = q__1.i;
00530         i__1 = l + 1 + l * h_dim1;
00531         h21 = h__[i__1].r;
00532         s = (r__1 = h11s.r, dabs(r__1)) + (r__2 = r_imag(&h11s), dabs(r__2)) 
00533                 + dabs(h21);
00534         q__1.r = h11s.r / s, q__1.i = h11s.i / s;
00535         h11s.r = q__1.r, h11s.i = q__1.i;
00536         h21 /= s;
00537         v[0].r = h11s.r, v[0].i = h11s.i;
00538         v[1].r = h21, v[1].i = 0.f;
00539 L70:
00540 
00541 /*        Single-shift QR step */
00542 
00543         i__1 = i__ - 1;
00544         for (k = m; k <= i__1; ++k) {
00545 
00546 /*           The first iteration of this loop determines a reflection G */
00547 /*           from the vector V and applies it from left and right to H, */
00548 /*           thus creating a nonzero bulge below the subdiagonal. */
00549 
00550 /*           Each subsequent iteration determines a reflection G to */
00551 /*           restore the Hessenberg form in the (K-1)th column, and thus */
00552 /*           chases the bulge one step toward the bottom of the active */
00553 /*           submatrix. */
00554 
00555 /*           V(2) is always real before the call to CLARFG, and hence */
00556 /*           after the call T2 ( = T1*V(2) ) is also real. */
00557 
00558             if (k > m) {
00559                 ccopy_(&c__2, &h__[k + (k - 1) * h_dim1], &c__1, v, &c__1);
00560             }
00561             clarfg_(&c__2, v, &v[1], &c__1, &t1);
00562             if (k > m) {
00563                 i__2 = k + (k - 1) * h_dim1;
00564                 h__[i__2].r = v[0].r, h__[i__2].i = v[0].i;
00565                 i__2 = k + 1 + (k - 1) * h_dim1;
00566                 h__[i__2].r = 0.f, h__[i__2].i = 0.f;
00567             }
00568             v2.r = v[1].r, v2.i = v[1].i;
00569             q__1.r = t1.r * v2.r - t1.i * v2.i, q__1.i = t1.r * v2.i + t1.i * 
00570                     v2.r;
00571             t2 = q__1.r;
00572 
00573 /*           Apply G from the left to transform the rows of the matrix */
00574 /*           in columns K to I2. */
00575 
00576             i__2 = i2;
00577             for (j = k; j <= i__2; ++j) {
00578                 r_cnjg(&q__3, &t1);
00579                 i__3 = k + j * h_dim1;
00580                 q__2.r = q__3.r * h__[i__3].r - q__3.i * h__[i__3].i, q__2.i =
00581                          q__3.r * h__[i__3].i + q__3.i * h__[i__3].r;
00582                 i__4 = k + 1 + j * h_dim1;
00583                 q__4.r = t2 * h__[i__4].r, q__4.i = t2 * h__[i__4].i;
00584                 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
00585                 sum.r = q__1.r, sum.i = q__1.i;
00586                 i__3 = k + j * h_dim1;
00587                 i__4 = k + j * h_dim1;
00588                 q__1.r = h__[i__4].r - sum.r, q__1.i = h__[i__4].i - sum.i;
00589                 h__[i__3].r = q__1.r, h__[i__3].i = q__1.i;
00590                 i__3 = k + 1 + j * h_dim1;
00591                 i__4 = k + 1 + j * h_dim1;
00592                 q__2.r = sum.r * v2.r - sum.i * v2.i, q__2.i = sum.r * v2.i + 
00593                         sum.i * v2.r;
00594                 q__1.r = h__[i__4].r - q__2.r, q__1.i = h__[i__4].i - q__2.i;
00595                 h__[i__3].r = q__1.r, h__[i__3].i = q__1.i;
00596 /* L80: */
00597             }
00598 
00599 /*           Apply G from the right to transform the columns of the */
00600 /*           matrix in rows I1 to min(K+2,I). */
00601 
00602 /* Computing MIN */
00603             i__3 = k + 2;
00604             i__2 = min(i__3,i__);
00605             for (j = i1; j <= i__2; ++j) {
00606                 i__3 = j + k * h_dim1;
00607                 q__2.r = t1.r * h__[i__3].r - t1.i * h__[i__3].i, q__2.i = 
00608                         t1.r * h__[i__3].i + t1.i * h__[i__3].r;
00609                 i__4 = j + (k + 1) * h_dim1;
00610                 q__3.r = t2 * h__[i__4].r, q__3.i = t2 * h__[i__4].i;
00611                 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00612                 sum.r = q__1.r, sum.i = q__1.i;
00613                 i__3 = j + k * h_dim1;
00614                 i__4 = j + k * h_dim1;
00615                 q__1.r = h__[i__4].r - sum.r, q__1.i = h__[i__4].i - sum.i;
00616                 h__[i__3].r = q__1.r, h__[i__3].i = q__1.i;
00617                 i__3 = j + (k + 1) * h_dim1;
00618                 i__4 = j + (k + 1) * h_dim1;
00619                 r_cnjg(&q__3, &v2);
00620                 q__2.r = sum.r * q__3.r - sum.i * q__3.i, q__2.i = sum.r * 
00621                         q__3.i + sum.i * q__3.r;
00622                 q__1.r = h__[i__4].r - q__2.r, q__1.i = h__[i__4].i - q__2.i;
00623                 h__[i__3].r = q__1.r, h__[i__3].i = q__1.i;
00624 /* L90: */
00625             }
00626 
00627             if (*wantz) {
00628 
00629 /*              Accumulate transformations in the matrix Z */
00630 
00631                 i__2 = *ihiz;
00632                 for (j = *iloz; j <= i__2; ++j) {
00633                     i__3 = j + k * z_dim1;
00634                     q__2.r = t1.r * z__[i__3].r - t1.i * z__[i__3].i, q__2.i =
00635                              t1.r * z__[i__3].i + t1.i * z__[i__3].r;
00636                     i__4 = j + (k + 1) * z_dim1;
00637                     q__3.r = t2 * z__[i__4].r, q__3.i = t2 * z__[i__4].i;
00638                     q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00639                     sum.r = q__1.r, sum.i = q__1.i;
00640                     i__3 = j + k * z_dim1;
00641                     i__4 = j + k * z_dim1;
00642                     q__1.r = z__[i__4].r - sum.r, q__1.i = z__[i__4].i - 
00643                             sum.i;
00644                     z__[i__3].r = q__1.r, z__[i__3].i = q__1.i;
00645                     i__3 = j + (k + 1) * z_dim1;
00646                     i__4 = j + (k + 1) * z_dim1;
00647                     r_cnjg(&q__3, &v2);
00648                     q__2.r = sum.r * q__3.r - sum.i * q__3.i, q__2.i = sum.r *
00649                              q__3.i + sum.i * q__3.r;
00650                     q__1.r = z__[i__4].r - q__2.r, q__1.i = z__[i__4].i - 
00651                             q__2.i;
00652                     z__[i__3].r = q__1.r, z__[i__3].i = q__1.i;
00653 /* L100: */
00654                 }
00655             }
00656 
00657             if (k == m && m > l) {
00658 
00659 /*              If the QR step was started at row M > L because two */
00660 /*              consecutive small subdiagonals were found, then extra */
00661 /*              scaling must be performed to ensure that H(M,M-1) remains */
00662 /*              real. */
00663 
00664                 q__1.r = 1.f - t1.r, q__1.i = 0.f - t1.i;
00665                 temp.r = q__1.r, temp.i = q__1.i;
00666                 r__1 = c_abs(&temp);
00667                 q__1.r = temp.r / r__1, q__1.i = temp.i / r__1;
00668                 temp.r = q__1.r, temp.i = q__1.i;
00669                 i__2 = m + 1 + m * h_dim1;
00670                 i__3 = m + 1 + m * h_dim1;
00671                 r_cnjg(&q__2, &temp);
00672                 q__1.r = h__[i__3].r * q__2.r - h__[i__3].i * q__2.i, q__1.i =
00673                          h__[i__3].r * q__2.i + h__[i__3].i * q__2.r;
00674                 h__[i__2].r = q__1.r, h__[i__2].i = q__1.i;
00675                 if (m + 2 <= i__) {
00676                     i__2 = m + 2 + (m + 1) * h_dim1;
00677                     i__3 = m + 2 + (m + 1) * h_dim1;
00678                     q__1.r = h__[i__3].r * temp.r - h__[i__3].i * temp.i, 
00679                             q__1.i = h__[i__3].r * temp.i + h__[i__3].i * 
00680                             temp.r;
00681                     h__[i__2].r = q__1.r, h__[i__2].i = q__1.i;
00682                 }
00683                 i__2 = i__;
00684                 for (j = m; j <= i__2; ++j) {
00685                     if (j != m + 1) {
00686                         if (i2 > j) {
00687                             i__3 = i2 - j;
00688                             cscal_(&i__3, &temp, &h__[j + (j + 1) * h_dim1], 
00689                                     ldh);
00690                         }
00691                         i__3 = j - i1;
00692                         r_cnjg(&q__1, &temp);
00693                         cscal_(&i__3, &q__1, &h__[i1 + j * h_dim1], &c__1);
00694                         if (*wantz) {
00695                             r_cnjg(&q__1, &temp);
00696                             cscal_(&nz, &q__1, &z__[*iloz + j * z_dim1], &
00697                                     c__1);
00698                         }
00699                     }
00700 /* L110: */
00701                 }
00702             }
00703 /* L120: */
00704         }
00705 
00706 /*        Ensure that H(I,I-1) is real. */
00707 
00708         i__1 = i__ + (i__ - 1) * h_dim1;
00709         temp.r = h__[i__1].r, temp.i = h__[i__1].i;
00710         if (r_imag(&temp) != 0.f) {
00711             rtemp = c_abs(&temp);
00712             i__1 = i__ + (i__ - 1) * h_dim1;
00713             h__[i__1].r = rtemp, h__[i__1].i = 0.f;
00714             q__1.r = temp.r / rtemp, q__1.i = temp.i / rtemp;
00715             temp.r = q__1.r, temp.i = q__1.i;
00716             if (i2 > i__) {
00717                 i__1 = i2 - i__;
00718                 r_cnjg(&q__1, &temp);
00719                 cscal_(&i__1, &q__1, &h__[i__ + (i__ + 1) * h_dim1], ldh);
00720             }
00721             i__1 = i__ - i1;
00722             cscal_(&i__1, &temp, &h__[i1 + i__ * h_dim1], &c__1);
00723             if (*wantz) {
00724                 cscal_(&nz, &temp, &z__[*iloz + i__ * z_dim1], &c__1);
00725             }
00726         }
00727 
00728 /* L130: */
00729     }
00730 
00731 /*     Failure to converge in remaining number of iterations */
00732 
00733     *info = i__;
00734     return 0;
00735 
00736 L140:
00737 
00738 /*     H(I,I-1) is negligible: one eigenvalue has converged. */
00739 
00740     i__1 = i__;
00741     i__2 = i__ + i__ * h_dim1;
00742     w[i__1].r = h__[i__2].r, w[i__1].i = h__[i__2].i;
00743 
00744 /*     return to start of the main loop with new value of I. */
00745 
00746     i__ = l - 1;
00747     goto L30;
00748 
00749 L150:
00750     return 0;
00751 
00752 /*     End of CLAHQR */
00753 
00754 } /* clahqr_ */


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