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


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