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


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