zhbtrd.c
Go to the documentation of this file.
00001 /* zhbtrd.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int zhbtrd_(char *vect, char *uplo, integer *n, integer *kd, 
00023         doublecomplex *ab, integer *ldab, doublereal *d__, doublereal *e, 
00024         doublecomplex *q, integer *ldq, doublecomplex *work, integer *info)
00025 {
00026     /* System generated locals */
00027     integer ab_dim1, ab_offset, q_dim1, q_offset, i__1, i__2, i__3, i__4, 
00028             i__5, i__6;
00029     doublereal d__1;
00030     doublecomplex z__1;
00031 
00032     /* Builtin functions */
00033     void d_cnjg(doublecomplex *, doublecomplex *);
00034     double z_abs(doublecomplex *);
00035 
00036     /* Local variables */
00037     integer i__, j, k, l;
00038     doublecomplex t;
00039     integer i2, j1, j2, nq, nr, kd1, ibl, iqb, kdn, jin, nrt, kdm1, inca, 
00040             jend, lend, jinc;
00041     doublereal abst;
00042     integer incx, last;
00043     doublecomplex temp;
00044     extern /* Subroutine */ int zrot_(integer *, doublecomplex *, integer *, 
00045             doublecomplex *, integer *, doublereal *, doublecomplex *);
00046     integer j1end, j1inc, iqend;
00047     extern logical lsame_(char *, char *);
00048     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00049             doublecomplex *, integer *);
00050     logical initq, wantq, upper;
00051     extern /* Subroutine */ int zlar2v_(integer *, doublecomplex *, 
00052             doublecomplex *, doublecomplex *, integer *, doublereal *, 
00053             doublecomplex *, integer *);
00054     integer iqaend;
00055     extern /* Subroutine */ int xerbla_(char *, integer *), zlacgv_(
00056             integer *, doublecomplex *, integer *), zlaset_(char *, integer *, 
00057              integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
00058             integer *), zlartg_(doublecomplex *, doublecomplex *, 
00059             doublereal *, doublecomplex *, doublecomplex *), zlargv_(integer *
00060 , doublecomplex *, integer *, doublecomplex *, integer *, 
00061             doublereal *, integer *), zlartv_(integer *, doublecomplex *, 
00062             integer *, doublecomplex *, integer *, doublereal *, 
00063             doublecomplex *, integer *);
00064 
00065 
00066 /*  -- LAPACK routine (version 3.2) -- */
00067 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00068 /*     November 2006 */
00069 
00070 /*     .. Scalar Arguments .. */
00071 /*     .. */
00072 /*     .. Array Arguments .. */
00073 /*     .. */
00074 
00075 /*  Purpose */
00076 /*  ======= */
00077 
00078 /*  ZHBTRD reduces a complex Hermitian band matrix A to real symmetric */
00079 /*  tridiagonal form T by a unitary similarity transformation: */
00080 /*  Q**H * A * Q = T. */
00081 
00082 /*  Arguments */
00083 /*  ========= */
00084 
00085 /*  VECT    (input) CHARACTER*1 */
00086 /*          = 'N':  do not form Q; */
00087 /*          = 'V':  form Q; */
00088 /*          = 'U':  update a matrix X, by forming X*Q. */
00089 
00090 /*  UPLO    (input) CHARACTER*1 */
00091 /*          = 'U':  Upper triangle of A is stored; */
00092 /*          = 'L':  Lower triangle of A is stored. */
00093 
00094 /*  N       (input) INTEGER */
00095 /*          The order of the matrix A.  N >= 0. */
00096 
00097 /*  KD      (input) INTEGER */
00098 /*          The number of superdiagonals of the matrix A if UPLO = 'U', */
00099 /*          or the number of subdiagonals if UPLO = 'L'.  KD >= 0. */
00100 
00101 /*  AB      (input/output) COMPLEX*16 array, dimension (LDAB,N) */
00102 /*          On entry, the upper or lower triangle of the Hermitian band */
00103 /*          matrix A, stored in the first KD+1 rows of the array.  The */
00104 /*          j-th column of A is stored in the j-th column of the array AB */
00105 /*          as follows: */
00106 /*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
00107 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd). */
00108 /*          On exit, the diagonal elements of AB are overwritten by the */
00109 /*          diagonal elements of the tridiagonal matrix T; if KD > 0, the */
00110 /*          elements on the first superdiagonal (if UPLO = 'U') or the */
00111 /*          first subdiagonal (if UPLO = 'L') are overwritten by the */
00112 /*          off-diagonal elements of T; the rest of AB is overwritten by */
00113 /*          values generated during the reduction. */
00114 
00115 /*  LDAB    (input) INTEGER */
00116 /*          The leading dimension of the array AB.  LDAB >= KD+1. */
00117 
00118 /*  D       (output) DOUBLE PRECISION array, dimension (N) */
00119 /*          The diagonal elements of the tridiagonal matrix T. */
00120 
00121 /*  E       (output) DOUBLE PRECISION array, dimension (N-1) */
00122 /*          The off-diagonal elements of the tridiagonal matrix T: */
00123 /*          E(i) = T(i,i+1) if UPLO = 'U'; E(i) = T(i+1,i) if UPLO = 'L'. */
00124 
00125 /*  Q       (input/output) COMPLEX*16 array, dimension (LDQ,N) */
00126 /*          On entry, if VECT = 'U', then Q must contain an N-by-N */
00127 /*          matrix X; if VECT = 'N' or 'V', then Q need not be set. */
00128 
00129 /*          On exit: */
00130 /*          if VECT = 'V', Q contains the N-by-N unitary matrix Q; */
00131 /*          if VECT = 'U', Q contains the product X*Q; */
00132 /*          if VECT = 'N', the array Q is not referenced. */
00133 
00134 /*  LDQ     (input) INTEGER */
00135 /*          The leading dimension of the array Q. */
00136 /*          LDQ >= 1, and LDQ >= N if VECT = 'V' or 'U'. */
00137 
00138 /*  WORK    (workspace) COMPLEX*16 array, dimension (N) */
00139 
00140 /*  INFO    (output) INTEGER */
00141 /*          = 0:  successful exit */
00142 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00143 
00144 /*  Further Details */
00145 /*  =============== */
00146 
00147 /*  Modified by Linda Kaufman, Bell Labs. */
00148 
00149 /*  ===================================================================== */
00150 
00151 /*     .. Parameters .. */
00152 /*     .. */
00153 /*     .. Local Scalars .. */
00154 /*     .. */
00155 /*     .. External Subroutines .. */
00156 /*     .. */
00157 /*     .. Intrinsic Functions .. */
00158 /*     .. */
00159 /*     .. External Functions .. */
00160 /*     .. */
00161 /*     .. Executable Statements .. */
00162 
00163 /*     Test the input parameters */
00164 
00165     /* Parameter adjustments */
00166     ab_dim1 = *ldab;
00167     ab_offset = 1 + ab_dim1;
00168     ab -= ab_offset;
00169     --d__;
00170     --e;
00171     q_dim1 = *ldq;
00172     q_offset = 1 + q_dim1;
00173     q -= q_offset;
00174     --work;
00175 
00176     /* Function Body */
00177     initq = lsame_(vect, "V");
00178     wantq = initq || lsame_(vect, "U");
00179     upper = lsame_(uplo, "U");
00180     kd1 = *kd + 1;
00181     kdm1 = *kd - 1;
00182     incx = *ldab - 1;
00183     iqend = 1;
00184 
00185     *info = 0;
00186     if (! wantq && ! lsame_(vect, "N")) {
00187         *info = -1;
00188     } else if (! upper && ! lsame_(uplo, "L")) {
00189         *info = -2;
00190     } else if (*n < 0) {
00191         *info = -3;
00192     } else if (*kd < 0) {
00193         *info = -4;
00194     } else if (*ldab < kd1) {
00195         *info = -6;
00196     } else if (*ldq < max(1,*n) && wantq) {
00197         *info = -10;
00198     }
00199     if (*info != 0) {
00200         i__1 = -(*info);
00201         xerbla_("ZHBTRD", &i__1);
00202         return 0;
00203     }
00204 
00205 /*     Quick return if possible */
00206 
00207     if (*n == 0) {
00208         return 0;
00209     }
00210 
00211 /*     Initialize Q to the unit matrix, if needed */
00212 
00213     if (initq) {
00214         zlaset_("Full", n, n, &c_b1, &c_b2, &q[q_offset], ldq);
00215     }
00216 
00217 /*     Wherever possible, plane rotations are generated and applied in */
00218 /*     vector operations of length NR over the index set J1:J2:KD1. */
00219 
00220 /*     The real cosines and complex sines of the plane rotations are */
00221 /*     stored in the arrays D and WORK. */
00222 
00223     inca = kd1 * *ldab;
00224 /* Computing MIN */
00225     i__1 = *n - 1;
00226     kdn = min(i__1,*kd);
00227     if (upper) {
00228 
00229         if (*kd > 1) {
00230 
00231 /*           Reduce to complex Hermitian tridiagonal form, working with */
00232 /*           the upper triangle */
00233 
00234             nr = 0;
00235             j1 = kdn + 2;
00236             j2 = 1;
00237 
00238             i__1 = kd1 + ab_dim1;
00239             i__2 = kd1 + ab_dim1;
00240             d__1 = ab[i__2].r;
00241             ab[i__1].r = d__1, ab[i__1].i = 0.;
00242             i__1 = *n - 2;
00243             for (i__ = 1; i__ <= i__1; ++i__) {
00244 
00245 /*              Reduce i-th row of matrix to tridiagonal form */
00246 
00247                 for (k = kdn + 1; k >= 2; --k) {
00248                     j1 += kdn;
00249                     j2 += kdn;
00250 
00251                     if (nr > 0) {
00252 
00253 /*                    generate plane rotations to annihilate nonzero */
00254 /*                    elements which have been created outside the band */
00255 
00256                         zlargv_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &inca, &
00257                                 work[j1], &kd1, &d__[j1], &kd1);
00258 
00259 /*                    apply rotations from the right */
00260 
00261 
00262 /*                    Dependent on the the number of diagonals either */
00263 /*                    ZLARTV or ZROT is used */
00264 
00265                         if (nr >= (*kd << 1) - 1) {
00266                             i__2 = *kd - 1;
00267                             for (l = 1; l <= i__2; ++l) {
00268                                 zlartv_(&nr, &ab[l + 1 + (j1 - 1) * ab_dim1], 
00269                                         &inca, &ab[l + j1 * ab_dim1], &inca, &
00270                                         d__[j1], &work[j1], &kd1);
00271 /* L10: */
00272                             }
00273 
00274                         } else {
00275                             jend = j1 + (nr - 1) * kd1;
00276                             i__2 = jend;
00277                             i__3 = kd1;
00278                             for (jinc = j1; i__3 < 0 ? jinc >= i__2 : jinc <= 
00279                                     i__2; jinc += i__3) {
00280                                 zrot_(&kdm1, &ab[(jinc - 1) * ab_dim1 + 2], &
00281                                         c__1, &ab[jinc * ab_dim1 + 1], &c__1, 
00282                                         &d__[jinc], &work[jinc]);
00283 /* L20: */
00284                             }
00285                         }
00286                     }
00287 
00288 
00289                     if (k > 2) {
00290                         if (k <= *n - i__ + 1) {
00291 
00292 /*                       generate plane rotation to annihilate a(i,i+k-1) */
00293 /*                       within the band */
00294 
00295                             zlartg_(&ab[*kd - k + 3 + (i__ + k - 2) * ab_dim1]
00296 , &ab[*kd - k + 2 + (i__ + k - 1) * 
00297                                     ab_dim1], &d__[i__ + k - 1], &work[i__ + 
00298                                     k - 1], &temp);
00299                             i__3 = *kd - k + 3 + (i__ + k - 2) * ab_dim1;
00300                             ab[i__3].r = temp.r, ab[i__3].i = temp.i;
00301 
00302 /*                       apply rotation from the right */
00303 
00304                             i__3 = k - 3;
00305                             zrot_(&i__3, &ab[*kd - k + 4 + (i__ + k - 2) * 
00306                                     ab_dim1], &c__1, &ab[*kd - k + 3 + (i__ + 
00307                                     k - 1) * ab_dim1], &c__1, &d__[i__ + k - 
00308                                     1], &work[i__ + k - 1]);
00309                         }
00310                         ++nr;
00311                         j1 = j1 - kdn - 1;
00312                     }
00313 
00314 /*                 apply plane rotations from both sides to diagonal */
00315 /*                 blocks */
00316 
00317                     if (nr > 0) {
00318                         zlar2v_(&nr, &ab[kd1 + (j1 - 1) * ab_dim1], &ab[kd1 + 
00319                                 j1 * ab_dim1], &ab[*kd + j1 * ab_dim1], &inca, 
00320                                  &d__[j1], &work[j1], &kd1);
00321                     }
00322 
00323 /*                 apply plane rotations from the left */
00324 
00325                     if (nr > 0) {
00326                         zlacgv_(&nr, &work[j1], &kd1);
00327                         if ((*kd << 1) - 1 < nr) {
00328 
00329 /*                    Dependent on the the number of diagonals either */
00330 /*                    ZLARTV or ZROT is used */
00331 
00332                             i__3 = *kd - 1;
00333                             for (l = 1; l <= i__3; ++l) {
00334                                 if (j2 + l > *n) {
00335                                     nrt = nr - 1;
00336                                 } else {
00337                                     nrt = nr;
00338                                 }
00339                                 if (nrt > 0) {
00340                                     zlartv_(&nrt, &ab[*kd - l + (j1 + l) * 
00341                                             ab_dim1], &inca, &ab[*kd - l + 1 
00342                                             + (j1 + l) * ab_dim1], &inca, &
00343                                             d__[j1], &work[j1], &kd1);
00344                                 }
00345 /* L30: */
00346                             }
00347                         } else {
00348                             j1end = j1 + kd1 * (nr - 2);
00349                             if (j1end >= j1) {
00350                                 i__3 = j1end;
00351                                 i__2 = kd1;
00352                                 for (jin = j1; i__2 < 0 ? jin >= i__3 : jin <=
00353                                          i__3; jin += i__2) {
00354                                     i__4 = *kd - 1;
00355                                     zrot_(&i__4, &ab[*kd - 1 + (jin + 1) * 
00356                                             ab_dim1], &incx, &ab[*kd + (jin + 
00357                                             1) * ab_dim1], &incx, &d__[jin], &
00358                                             work[jin]);
00359 /* L40: */
00360                                 }
00361                             }
00362 /* Computing MIN */
00363                             i__2 = kdm1, i__3 = *n - j2;
00364                             lend = min(i__2,i__3);
00365                             last = j1end + kd1;
00366                             if (lend > 0) {
00367                                 zrot_(&lend, &ab[*kd - 1 + (last + 1) * 
00368                                         ab_dim1], &incx, &ab[*kd + (last + 1) 
00369                                         * ab_dim1], &incx, &d__[last], &work[
00370                                         last]);
00371                             }
00372                         }
00373                     }
00374 
00375                     if (wantq) {
00376 
00377 /*                    accumulate product of plane rotations in Q */
00378 
00379                         if (initq) {
00380 
00381 /*                 take advantage of the fact that Q was */
00382 /*                 initially the Identity matrix */
00383 
00384                             iqend = max(iqend,j2);
00385 /* Computing MAX */
00386                             i__2 = 0, i__3 = k - 3;
00387                             i2 = max(i__2,i__3);
00388                             iqaend = i__ * *kd + 1;
00389                             if (k == 2) {
00390                                 iqaend += *kd;
00391                             }
00392                             iqaend = min(iqaend,iqend);
00393                             i__2 = j2;
00394                             i__3 = kd1;
00395                             for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j 
00396                                     += i__3) {
00397                                 ibl = i__ - i2 / kdm1;
00398                                 ++i2;
00399 /* Computing MAX */
00400                                 i__4 = 1, i__5 = j - ibl;
00401                                 iqb = max(i__4,i__5);
00402                                 nq = iqaend + 1 - iqb;
00403 /* Computing MIN */
00404                                 i__4 = iqaend + *kd;
00405                                 iqaend = min(i__4,iqend);
00406                                 d_cnjg(&z__1, &work[j]);
00407                                 zrot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1, 
00408                                         &q[iqb + j * q_dim1], &c__1, &d__[j], 
00409                                         &z__1);
00410 /* L50: */
00411                             }
00412                         } else {
00413 
00414                             i__3 = j2;
00415                             i__2 = kd1;
00416                             for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j 
00417                                     += i__2) {
00418                                 d_cnjg(&z__1, &work[j]);
00419                                 zrot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
00420                                         j * q_dim1 + 1], &c__1, &d__[j], &
00421                                         z__1);
00422 /* L60: */
00423                             }
00424                         }
00425 
00426                     }
00427 
00428                     if (j2 + kdn > *n) {
00429 
00430 /*                    adjust J2 to keep within the bounds of the matrix */
00431 
00432                         --nr;
00433                         j2 = j2 - kdn - 1;
00434                     }
00435 
00436                     i__2 = j2;
00437                     i__3 = kd1;
00438                     for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3) 
00439                             {
00440 
00441 /*                    create nonzero element a(j-1,j+kd) outside the band */
00442 /*                    and store it in WORK */
00443 
00444                         i__4 = j + *kd;
00445                         i__5 = j;
00446                         i__6 = (j + *kd) * ab_dim1 + 1;
00447                         z__1.r = work[i__5].r * ab[i__6].r - work[i__5].i * 
00448                                 ab[i__6].i, z__1.i = work[i__5].r * ab[i__6]
00449                                 .i + work[i__5].i * ab[i__6].r;
00450                         work[i__4].r = z__1.r, work[i__4].i = z__1.i;
00451                         i__4 = (j + *kd) * ab_dim1 + 1;
00452                         i__5 = j;
00453                         i__6 = (j + *kd) * ab_dim1 + 1;
00454                         z__1.r = d__[i__5] * ab[i__6].r, z__1.i = d__[i__5] * 
00455                                 ab[i__6].i;
00456                         ab[i__4].r = z__1.r, ab[i__4].i = z__1.i;
00457 /* L70: */
00458                     }
00459 /* L80: */
00460                 }
00461 /* L90: */
00462             }
00463         }
00464 
00465         if (*kd > 0) {
00466 
00467 /*           make off-diagonal elements real and copy them to E */
00468 
00469             i__1 = *n - 1;
00470             for (i__ = 1; i__ <= i__1; ++i__) {
00471                 i__3 = *kd + (i__ + 1) * ab_dim1;
00472                 t.r = ab[i__3].r, t.i = ab[i__3].i;
00473                 abst = z_abs(&t);
00474                 i__3 = *kd + (i__ + 1) * ab_dim1;
00475                 ab[i__3].r = abst, ab[i__3].i = 0.;
00476                 e[i__] = abst;
00477                 if (abst != 0.) {
00478                     z__1.r = t.r / abst, z__1.i = t.i / abst;
00479                     t.r = z__1.r, t.i = z__1.i;
00480                 } else {
00481                     t.r = 1., t.i = 0.;
00482                 }
00483                 if (i__ < *n - 1) {
00484                     i__3 = *kd + (i__ + 2) * ab_dim1;
00485                     i__2 = *kd + (i__ + 2) * ab_dim1;
00486                     z__1.r = ab[i__2].r * t.r - ab[i__2].i * t.i, z__1.i = ab[
00487                             i__2].r * t.i + ab[i__2].i * t.r;
00488                     ab[i__3].r = z__1.r, ab[i__3].i = z__1.i;
00489                 }
00490                 if (wantq) {
00491                     d_cnjg(&z__1, &t);
00492                     zscal_(n, &z__1, &q[(i__ + 1) * q_dim1 + 1], &c__1);
00493                 }
00494 /* L100: */
00495             }
00496         } else {
00497 
00498 /*           set E to zero if original matrix was diagonal */
00499 
00500             i__1 = *n - 1;
00501             for (i__ = 1; i__ <= i__1; ++i__) {
00502                 e[i__] = 0.;
00503 /* L110: */
00504             }
00505         }
00506 
00507 /*        copy diagonal elements to D */
00508 
00509         i__1 = *n;
00510         for (i__ = 1; i__ <= i__1; ++i__) {
00511             i__3 = i__;
00512             i__2 = kd1 + i__ * ab_dim1;
00513             d__[i__3] = ab[i__2].r;
00514 /* L120: */
00515         }
00516 
00517     } else {
00518 
00519         if (*kd > 1) {
00520 
00521 /*           Reduce to complex Hermitian tridiagonal form, working with */
00522 /*           the lower triangle */
00523 
00524             nr = 0;
00525             j1 = kdn + 2;
00526             j2 = 1;
00527 
00528             i__1 = ab_dim1 + 1;
00529             i__3 = ab_dim1 + 1;
00530             d__1 = ab[i__3].r;
00531             ab[i__1].r = d__1, ab[i__1].i = 0.;
00532             i__1 = *n - 2;
00533             for (i__ = 1; i__ <= i__1; ++i__) {
00534 
00535 /*              Reduce i-th column of matrix to tridiagonal form */
00536 
00537                 for (k = kdn + 1; k >= 2; --k) {
00538                     j1 += kdn;
00539                     j2 += kdn;
00540 
00541                     if (nr > 0) {
00542 
00543 /*                    generate plane rotations to annihilate nonzero */
00544 /*                    elements which have been created outside the band */
00545 
00546                         zlargv_(&nr, &ab[kd1 + (j1 - kd1) * ab_dim1], &inca, &
00547                                 work[j1], &kd1, &d__[j1], &kd1);
00548 
00549 /*                    apply plane rotations from one side */
00550 
00551 
00552 /*                    Dependent on the the number of diagonals either */
00553 /*                    ZLARTV or ZROT is used */
00554 
00555                         if (nr > (*kd << 1) - 1) {
00556                             i__3 = *kd - 1;
00557                             for (l = 1; l <= i__3; ++l) {
00558                                 zlartv_(&nr, &ab[kd1 - l + (j1 - kd1 + l) * 
00559                                         ab_dim1], &inca, &ab[kd1 - l + 1 + (
00560                                         j1 - kd1 + l) * ab_dim1], &inca, &d__[
00561                                         j1], &work[j1], &kd1);
00562 /* L130: */
00563                             }
00564                         } else {
00565                             jend = j1 + kd1 * (nr - 1);
00566                             i__3 = jend;
00567                             i__2 = kd1;
00568                             for (jinc = j1; i__2 < 0 ? jinc >= i__3 : jinc <= 
00569                                     i__3; jinc += i__2) {
00570                                 zrot_(&kdm1, &ab[*kd + (jinc - *kd) * ab_dim1]
00571 , &incx, &ab[kd1 + (jinc - *kd) * 
00572                                         ab_dim1], &incx, &d__[jinc], &work[
00573                                         jinc]);
00574 /* L140: */
00575                             }
00576                         }
00577 
00578                     }
00579 
00580                     if (k > 2) {
00581                         if (k <= *n - i__ + 1) {
00582 
00583 /*                       generate plane rotation to annihilate a(i+k-1,i) */
00584 /*                       within the band */
00585 
00586                             zlartg_(&ab[k - 1 + i__ * ab_dim1], &ab[k + i__ * 
00587                                     ab_dim1], &d__[i__ + k - 1], &work[i__ + 
00588                                     k - 1], &temp);
00589                             i__2 = k - 1 + i__ * ab_dim1;
00590                             ab[i__2].r = temp.r, ab[i__2].i = temp.i;
00591 
00592 /*                       apply rotation from the left */
00593 
00594                             i__2 = k - 3;
00595                             i__3 = *ldab - 1;
00596                             i__4 = *ldab - 1;
00597                             zrot_(&i__2, &ab[k - 2 + (i__ + 1) * ab_dim1], &
00598                                     i__3, &ab[k - 1 + (i__ + 1) * ab_dim1], &
00599                                     i__4, &d__[i__ + k - 1], &work[i__ + k - 
00600                                     1]);
00601                         }
00602                         ++nr;
00603                         j1 = j1 - kdn - 1;
00604                     }
00605 
00606 /*                 apply plane rotations from both sides to diagonal */
00607 /*                 blocks */
00608 
00609                     if (nr > 0) {
00610                         zlar2v_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &ab[j1 * 
00611                                 ab_dim1 + 1], &ab[(j1 - 1) * ab_dim1 + 2], &
00612                                 inca, &d__[j1], &work[j1], &kd1);
00613                     }
00614 
00615 /*                 apply plane rotations from the right */
00616 
00617 
00618 /*                    Dependent on the the number of diagonals either */
00619 /*                    ZLARTV or ZROT is used */
00620 
00621                     if (nr > 0) {
00622                         zlacgv_(&nr, &work[j1], &kd1);
00623                         if (nr > (*kd << 1) - 1) {
00624                             i__2 = *kd - 1;
00625                             for (l = 1; l <= i__2; ++l) {
00626                                 if (j2 + l > *n) {
00627                                     nrt = nr - 1;
00628                                 } else {
00629                                     nrt = nr;
00630                                 }
00631                                 if (nrt > 0) {
00632                                     zlartv_(&nrt, &ab[l + 2 + (j1 - 1) * 
00633                                             ab_dim1], &inca, &ab[l + 1 + j1 * 
00634                                             ab_dim1], &inca, &d__[j1], &work[
00635                                             j1], &kd1);
00636                                 }
00637 /* L150: */
00638                             }
00639                         } else {
00640                             j1end = j1 + kd1 * (nr - 2);
00641                             if (j1end >= j1) {
00642                                 i__2 = j1end;
00643                                 i__3 = kd1;
00644                                 for (j1inc = j1; i__3 < 0 ? j1inc >= i__2 : 
00645                                         j1inc <= i__2; j1inc += i__3) {
00646                                     zrot_(&kdm1, &ab[(j1inc - 1) * ab_dim1 + 
00647                                             3], &c__1, &ab[j1inc * ab_dim1 + 
00648                                             2], &c__1, &d__[j1inc], &work[
00649                                             j1inc]);
00650 /* L160: */
00651                                 }
00652                             }
00653 /* Computing MIN */
00654                             i__3 = kdm1, i__2 = *n - j2;
00655                             lend = min(i__3,i__2);
00656                             last = j1end + kd1;
00657                             if (lend > 0) {
00658                                 zrot_(&lend, &ab[(last - 1) * ab_dim1 + 3], &
00659                                         c__1, &ab[last * ab_dim1 + 2], &c__1, 
00660                                         &d__[last], &work[last]);
00661                             }
00662                         }
00663                     }
00664 
00665 
00666 
00667                     if (wantq) {
00668 
00669 /*                    accumulate product of plane rotations in Q */
00670 
00671                         if (initq) {
00672 
00673 /*                 take advantage of the fact that Q was */
00674 /*                 initially the Identity matrix */
00675 
00676                             iqend = max(iqend,j2);
00677 /* Computing MAX */
00678                             i__3 = 0, i__2 = k - 3;
00679                             i2 = max(i__3,i__2);
00680                             iqaend = i__ * *kd + 1;
00681                             if (k == 2) {
00682                                 iqaend += *kd;
00683                             }
00684                             iqaend = min(iqaend,iqend);
00685                             i__3 = j2;
00686                             i__2 = kd1;
00687                             for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j 
00688                                     += i__2) {
00689                                 ibl = i__ - i2 / kdm1;
00690                                 ++i2;
00691 /* Computing MAX */
00692                                 i__4 = 1, i__5 = j - ibl;
00693                                 iqb = max(i__4,i__5);
00694                                 nq = iqaend + 1 - iqb;
00695 /* Computing MIN */
00696                                 i__4 = iqaend + *kd;
00697                                 iqaend = min(i__4,iqend);
00698                                 zrot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1, 
00699                                         &q[iqb + j * q_dim1], &c__1, &d__[j], 
00700                                         &work[j]);
00701 /* L170: */
00702                             }
00703                         } else {
00704 
00705                             i__2 = j2;
00706                             i__3 = kd1;
00707                             for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j 
00708                                     += i__3) {
00709                                 zrot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
00710                                         j * q_dim1 + 1], &c__1, &d__[j], &
00711                                         work[j]);
00712 /* L180: */
00713                             }
00714                         }
00715                     }
00716 
00717                     if (j2 + kdn > *n) {
00718 
00719 /*                    adjust J2 to keep within the bounds of the matrix */
00720 
00721                         --nr;
00722                         j2 = j2 - kdn - 1;
00723                     }
00724 
00725                     i__3 = j2;
00726                     i__2 = kd1;
00727                     for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2) 
00728                             {
00729 
00730 /*                    create nonzero element a(j+kd,j-1) outside the */
00731 /*                    band and store it in WORK */
00732 
00733                         i__4 = j + *kd;
00734                         i__5 = j;
00735                         i__6 = kd1 + j * ab_dim1;
00736                         z__1.r = work[i__5].r * ab[i__6].r - work[i__5].i * 
00737                                 ab[i__6].i, z__1.i = work[i__5].r * ab[i__6]
00738                                 .i + work[i__5].i * ab[i__6].r;
00739                         work[i__4].r = z__1.r, work[i__4].i = z__1.i;
00740                         i__4 = kd1 + j * ab_dim1;
00741                         i__5 = j;
00742                         i__6 = kd1 + j * ab_dim1;
00743                         z__1.r = d__[i__5] * ab[i__6].r, z__1.i = d__[i__5] * 
00744                                 ab[i__6].i;
00745                         ab[i__4].r = z__1.r, ab[i__4].i = z__1.i;
00746 /* L190: */
00747                     }
00748 /* L200: */
00749                 }
00750 /* L210: */
00751             }
00752         }
00753 
00754         if (*kd > 0) {
00755 
00756 /*           make off-diagonal elements real and copy them to E */
00757 
00758             i__1 = *n - 1;
00759             for (i__ = 1; i__ <= i__1; ++i__) {
00760                 i__2 = i__ * ab_dim1 + 2;
00761                 t.r = ab[i__2].r, t.i = ab[i__2].i;
00762                 abst = z_abs(&t);
00763                 i__2 = i__ * ab_dim1 + 2;
00764                 ab[i__2].r = abst, ab[i__2].i = 0.;
00765                 e[i__] = abst;
00766                 if (abst != 0.) {
00767                     z__1.r = t.r / abst, z__1.i = t.i / abst;
00768                     t.r = z__1.r, t.i = z__1.i;
00769                 } else {
00770                     t.r = 1., t.i = 0.;
00771                 }
00772                 if (i__ < *n - 1) {
00773                     i__2 = (i__ + 1) * ab_dim1 + 2;
00774                     i__3 = (i__ + 1) * ab_dim1 + 2;
00775                     z__1.r = ab[i__3].r * t.r - ab[i__3].i * t.i, z__1.i = ab[
00776                             i__3].r * t.i + ab[i__3].i * t.r;
00777                     ab[i__2].r = z__1.r, ab[i__2].i = z__1.i;
00778                 }
00779                 if (wantq) {
00780                     zscal_(n, &t, &q[(i__ + 1) * q_dim1 + 1], &c__1);
00781                 }
00782 /* L220: */
00783             }
00784         } else {
00785 
00786 /*           set E to zero if original matrix was diagonal */
00787 
00788             i__1 = *n - 1;
00789             for (i__ = 1; i__ <= i__1; ++i__) {
00790                 e[i__] = 0.;
00791 /* L230: */
00792             }
00793         }
00794 
00795 /*        copy diagonal elements to D */
00796 
00797         i__1 = *n;
00798         for (i__ = 1; i__ <= i__1; ++i__) {
00799             i__2 = i__;
00800             i__3 = i__ * ab_dim1 + 1;
00801             d__[i__2] = ab[i__3].r;
00802 /* L240: */
00803         }
00804     }
00805 
00806     return 0;
00807 
00808 /*     End of ZHBTRD */
00809 
00810 } /* zhbtrd_ */


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