dsbgst.c
Go to the documentation of this file.
00001 /* dsbgst.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_b8 = 0.;
00019 static doublereal c_b9 = 1.;
00020 static integer c__1 = 1;
00021 static doublereal c_b20 = -1.;
00022 
00023 /* Subroutine */ int dsbgst_(char *vect, char *uplo, integer *n, integer *ka, 
00024         integer *kb, doublereal *ab, integer *ldab, doublereal *bb, integer *
00025         ldbb, doublereal *x, integer *ldx, doublereal *work, integer *info)
00026 {
00027     /* System generated locals */
00028     integer ab_dim1, ab_offset, bb_dim1, bb_offset, x_dim1, x_offset, i__1, 
00029             i__2, i__3, i__4;
00030     doublereal d__1;
00031 
00032     /* Local variables */
00033     integer i__, j, k, l, m;
00034     doublereal t;
00035     integer i0, i1, i2, j1, j2;
00036     doublereal ra;
00037     integer nr, nx, ka1, kb1;
00038     doublereal ra1;
00039     integer j1t, j2t;
00040     doublereal bii;
00041     integer kbt, nrt, inca;
00042     extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, 
00043             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00044             integer *), drot_(integer *, doublereal *, integer *, doublereal *
00045 , integer *, doublereal *, doublereal *), dscal_(integer *, 
00046             doublereal *, doublereal *, integer *);
00047     extern logical lsame_(char *, char *);
00048     logical upper, wantx;
00049     extern /* Subroutine */ int dlar2v_(integer *, doublereal *, doublereal *, 
00050              doublereal *, integer *, doublereal *, doublereal *, integer *), 
00051             dlaset_(char *, integer *, integer *, doublereal *, doublereal *, 
00052             doublereal *, integer *), dlartg_(doublereal *, 
00053             doublereal *, doublereal *, doublereal *, doublereal *), xerbla_(
00054             char *, integer *), dlargv_(integer *, doublereal *, 
00055             integer *, doublereal *, integer *, doublereal *, integer *);
00056     logical update;
00057     extern /* Subroutine */ int dlartv_(integer *, doublereal *, integer *, 
00058             doublereal *, integer *, doublereal *, doublereal *, integer *);
00059 
00060 
00061 /*  -- LAPACK routine (version 3.2) -- */
00062 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00063 /*     November 2006 */
00064 
00065 /*     .. Scalar Arguments .. */
00066 /*     .. */
00067 /*     .. Array Arguments .. */
00068 /*     .. */
00069 
00070 /*  Purpose */
00071 /*  ======= */
00072 
00073 /*  DSBGST reduces a real symmetric-definite banded generalized */
00074 /*  eigenproblem  A*x = lambda*B*x  to standard form  C*y = lambda*y, */
00075 /*  such that C has the same bandwidth as A. */
00076 
00077 /*  B must have been previously factorized as S**T*S by DPBSTF, using a */
00078 /*  split Cholesky factorization. A is overwritten by C = X**T*A*X, where */
00079 /*  X = S**(-1)*Q and Q is an orthogonal matrix chosen to preserve the */
00080 /*  bandwidth of A. */
00081 
00082 /*  Arguments */
00083 /*  ========= */
00084 
00085 /*  VECT    (input) CHARACTER*1 */
00086 /*          = 'N':  do not form the transformation matrix X; */
00087 /*          = 'V':  form X. */
00088 
00089 /*  UPLO    (input) CHARACTER*1 */
00090 /*          = 'U':  Upper triangle of A is stored; */
00091 /*          = 'L':  Lower triangle of A is stored. */
00092 
00093 /*  N       (input) INTEGER */
00094 /*          The order of the matrices A and B.  N >= 0. */
00095 
00096 /*  KA      (input) INTEGER */
00097 /*          The number of superdiagonals of the matrix A if UPLO = 'U', */
00098 /*          or the number of subdiagonals if UPLO = 'L'.  KA >= 0. */
00099 
00100 /*  KB      (input) INTEGER */
00101 /*          The number of superdiagonals of the matrix B if UPLO = 'U', */
00102 /*          or the number of subdiagonals if UPLO = 'L'.  KA >= KB >= 0. */
00103 
00104 /*  AB      (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
00105 /*          On entry, the upper or lower triangle of the symmetric band */
00106 /*          matrix A, stored in the first ka+1 rows of the array.  The */
00107 /*          j-th column of A is stored in the j-th column of the array AB */
00108 /*          as follows: */
00109 /*          if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j; */
00110 /*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+ka). */
00111 
00112 /*          On exit, the transformed matrix X**T*A*X, stored in the same */
00113 /*          format as A. */
00114 
00115 /*  LDAB    (input) INTEGER */
00116 /*          The leading dimension of the array AB.  LDAB >= KA+1. */
00117 
00118 /*  BB      (input) DOUBLE PRECISION array, dimension (LDBB,N) */
00119 /*          The banded factor S from the split Cholesky factorization of */
00120 /*          B, as returned by DPBSTF, stored in the first KB+1 rows of */
00121 /*          the array. */
00122 
00123 /*  LDBB    (input) INTEGER */
00124 /*          The leading dimension of the array BB.  LDBB >= KB+1. */
00125 
00126 /*  X       (output) DOUBLE PRECISION array, dimension (LDX,N) */
00127 /*          If VECT = 'V', the n-by-n matrix X. */
00128 /*          If VECT = 'N', the array X is not referenced. */
00129 
00130 /*  LDX     (input) INTEGER */
00131 /*          The leading dimension of the array X. */
00132 /*          LDX >= max(1,N) if VECT = 'V'; LDX >= 1 otherwise. */
00133 
00134 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*N) */
00135 
00136 /*  INFO    (output) INTEGER */
00137 /*          = 0:  successful exit */
00138 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00139 
00140 /*  ===================================================================== */
00141 
00142 /*     .. Parameters .. */
00143 /*     .. */
00144 /*     .. Local Scalars .. */
00145 /*     .. */
00146 /*     .. External Functions .. */
00147 /*     .. */
00148 /*     .. External Subroutines .. */
00149 /*     .. */
00150 /*     .. Intrinsic Functions .. */
00151 /*     .. */
00152 /*     .. Executable Statements .. */
00153 
00154 /*     Test the input parameters */
00155 
00156     /* Parameter adjustments */
00157     ab_dim1 = *ldab;
00158     ab_offset = 1 + ab_dim1;
00159     ab -= ab_offset;
00160     bb_dim1 = *ldbb;
00161     bb_offset = 1 + bb_dim1;
00162     bb -= bb_offset;
00163     x_dim1 = *ldx;
00164     x_offset = 1 + x_dim1;
00165     x -= x_offset;
00166     --work;
00167 
00168     /* Function Body */
00169     wantx = lsame_(vect, "V");
00170     upper = lsame_(uplo, "U");
00171     ka1 = *ka + 1;
00172     kb1 = *kb + 1;
00173     *info = 0;
00174     if (! wantx && ! lsame_(vect, "N")) {
00175         *info = -1;
00176     } else if (! upper && ! lsame_(uplo, "L")) {
00177         *info = -2;
00178     } else if (*n < 0) {
00179         *info = -3;
00180     } else if (*ka < 0) {
00181         *info = -4;
00182     } else if (*kb < 0 || *kb > *ka) {
00183         *info = -5;
00184     } else if (*ldab < *ka + 1) {
00185         *info = -7;
00186     } else if (*ldbb < *kb + 1) {
00187         *info = -9;
00188     } else if (*ldx < 1 || wantx && *ldx < max(1,*n)) {
00189         *info = -11;
00190     }
00191     if (*info != 0) {
00192         i__1 = -(*info);
00193         xerbla_("DSBGST", &i__1);
00194         return 0;
00195     }
00196 
00197 /*     Quick return if possible */
00198 
00199     if (*n == 0) {
00200         return 0;
00201     }
00202 
00203     inca = *ldab * ka1;
00204 
00205 /*     Initialize X to the unit matrix, if needed */
00206 
00207     if (wantx) {
00208         dlaset_("Full", n, n, &c_b8, &c_b9, &x[x_offset], ldx);
00209     }
00210 
00211 /*     Set M to the splitting point m. It must be the same value as is */
00212 /*     used in DPBSTF. The chosen value allows the arrays WORK and RWORK */
00213 /*     to be of dimension (N). */
00214 
00215     m = (*n + *kb) / 2;
00216 
00217 /*     The routine works in two phases, corresponding to the two halves */
00218 /*     of the split Cholesky factorization of B as S**T*S where */
00219 
00220 /*     S = ( U    ) */
00221 /*         ( M  L ) */
00222 
00223 /*     with U upper triangular of order m, and L lower triangular of */
00224 /*     order n-m. S has the same bandwidth as B. */
00225 
00226 /*     S is treated as a product of elementary matrices: */
00227 
00228 /*     S = S(m)*S(m-1)*...*S(2)*S(1)*S(m+1)*S(m+2)*...*S(n-1)*S(n) */
00229 
00230 /*     where S(i) is determined by the i-th row of S. */
00231 
00232 /*     In phase 1, the index i takes the values n, n-1, ... , m+1; */
00233 /*     in phase 2, it takes the values 1, 2, ... , m. */
00234 
00235 /*     For each value of i, the current matrix A is updated by forming */
00236 /*     inv(S(i))**T*A*inv(S(i)). This creates a triangular bulge outside */
00237 /*     the band of A. The bulge is then pushed down toward the bottom of */
00238 /*     A in phase 1, and up toward the top of A in phase 2, by applying */
00239 /*     plane rotations. */
00240 
00241 /*     There are kb*(kb+1)/2 elements in the bulge, but at most 2*kb-1 */
00242 /*     of them are linearly independent, so annihilating a bulge requires */
00243 /*     only 2*kb-1 plane rotations. The rotations are divided into a 1st */
00244 /*     set of kb-1 rotations, and a 2nd set of kb rotations. */
00245 
00246 /*     Wherever possible, rotations are generated and applied in vector */
00247 /*     operations of length NR between the indices J1 and J2 (sometimes */
00248 /*     replaced by modified values NRT, J1T or J2T). */
00249 
00250 /*     The cosines and sines of the rotations are stored in the array */
00251 /*     WORK. The cosines of the 1st set of rotations are stored in */
00252 /*     elements n+2:n+m-kb-1 and the sines of the 1st set in elements */
00253 /*     2:m-kb-1; the cosines of the 2nd set are stored in elements */
00254 /*     n+m-kb+1:2*n and the sines of the second set in elements m-kb+1:n. */
00255 
00256 /*     The bulges are not formed explicitly; nonzero elements outside the */
00257 /*     band are created only when they are required for generating new */
00258 /*     rotations; they are stored in the array WORK, in positions where */
00259 /*     they are later overwritten by the sines of the rotations which */
00260 /*     annihilate them. */
00261 
00262 /*     **************************** Phase 1 ***************************** */
00263 
00264 /*     The logical structure of this phase is: */
00265 
00266 /*     UPDATE = .TRUE. */
00267 /*     DO I = N, M + 1, -1 */
00268 /*        use S(i) to update A and create a new bulge */
00269 /*        apply rotations to push all bulges KA positions downward */
00270 /*     END DO */
00271 /*     UPDATE = .FALSE. */
00272 /*     DO I = M + KA + 1, N - 1 */
00273 /*        apply rotations to push all bulges KA positions downward */
00274 /*     END DO */
00275 
00276 /*     To avoid duplicating code, the two loops are merged. */
00277 
00278     update = TRUE_;
00279     i__ = *n + 1;
00280 L10:
00281     if (update) {
00282         --i__;
00283 /* Computing MIN */
00284         i__1 = *kb, i__2 = i__ - 1;
00285         kbt = min(i__1,i__2);
00286         i0 = i__ - 1;
00287 /* Computing MIN */
00288         i__1 = *n, i__2 = i__ + *ka;
00289         i1 = min(i__1,i__2);
00290         i2 = i__ - kbt + ka1;
00291         if (i__ < m + 1) {
00292             update = FALSE_;
00293             ++i__;
00294             i0 = m;
00295             if (*ka == 0) {
00296                 goto L480;
00297             }
00298             goto L10;
00299         }
00300     } else {
00301         i__ += *ka;
00302         if (i__ > *n - 1) {
00303             goto L480;
00304         }
00305     }
00306 
00307     if (upper) {
00308 
00309 /*        Transform A, working with the upper triangle */
00310 
00311         if (update) {
00312 
00313 /*           Form  inv(S(i))**T * A * inv(S(i)) */
00314 
00315             bii = bb[kb1 + i__ * bb_dim1];
00316             i__1 = i1;
00317             for (j = i__; j <= i__1; ++j) {
00318                 ab[i__ - j + ka1 + j * ab_dim1] /= bii;
00319 /* L20: */
00320             }
00321 /* Computing MAX */
00322             i__1 = 1, i__2 = i__ - *ka;
00323             i__3 = i__;
00324             for (j = max(i__1,i__2); j <= i__3; ++j) {
00325                 ab[j - i__ + ka1 + i__ * ab_dim1] /= bii;
00326 /* L30: */
00327             }
00328             i__3 = i__ - 1;
00329             for (k = i__ - kbt; k <= i__3; ++k) {
00330                 i__1 = k;
00331                 for (j = i__ - kbt; j <= i__1; ++j) {
00332                     ab[j - k + ka1 + k * ab_dim1] = ab[j - k + ka1 + k * 
00333                             ab_dim1] - bb[j - i__ + kb1 + i__ * bb_dim1] * ab[
00334                             k - i__ + ka1 + i__ * ab_dim1] - bb[k - i__ + kb1 
00335                             + i__ * bb_dim1] * ab[j - i__ + ka1 + i__ * 
00336                             ab_dim1] + ab[ka1 + i__ * ab_dim1] * bb[j - i__ + 
00337                             kb1 + i__ * bb_dim1] * bb[k - i__ + kb1 + i__ * 
00338                             bb_dim1];
00339 /* L40: */
00340                 }
00341 /* Computing MAX */
00342                 i__1 = 1, i__2 = i__ - *ka;
00343                 i__4 = i__ - kbt - 1;
00344                 for (j = max(i__1,i__2); j <= i__4; ++j) {
00345                     ab[j - k + ka1 + k * ab_dim1] -= bb[k - i__ + kb1 + i__ * 
00346                             bb_dim1] * ab[j - i__ + ka1 + i__ * ab_dim1];
00347 /* L50: */
00348                 }
00349 /* L60: */
00350             }
00351             i__3 = i1;
00352             for (j = i__; j <= i__3; ++j) {
00353 /* Computing MAX */
00354                 i__4 = j - *ka, i__1 = i__ - kbt;
00355                 i__2 = i__ - 1;
00356                 for (k = max(i__4,i__1); k <= i__2; ++k) {
00357                     ab[k - j + ka1 + j * ab_dim1] -= bb[k - i__ + kb1 + i__ * 
00358                             bb_dim1] * ab[i__ - j + ka1 + j * ab_dim1];
00359 /* L70: */
00360                 }
00361 /* L80: */
00362             }
00363 
00364             if (wantx) {
00365 
00366 /*              post-multiply X by inv(S(i)) */
00367 
00368                 i__3 = *n - m;
00369                 d__1 = 1. / bii;
00370                 dscal_(&i__3, &d__1, &x[m + 1 + i__ * x_dim1], &c__1);
00371                 if (kbt > 0) {
00372                     i__3 = *n - m;
00373                     dger_(&i__3, &kbt, &c_b20, &x[m + 1 + i__ * x_dim1], &
00374                             c__1, &bb[kb1 - kbt + i__ * bb_dim1], &c__1, &x[m 
00375                             + 1 + (i__ - kbt) * x_dim1], ldx);
00376                 }
00377             }
00378 
00379 /*           store a(i,i1) in RA1 for use in next loop over K */
00380 
00381             ra1 = ab[i__ - i1 + ka1 + i1 * ab_dim1];
00382         }
00383 
00384 /*        Generate and apply vectors of rotations to chase all the */
00385 /*        existing bulges KA positions down toward the bottom of the */
00386 /*        band */
00387 
00388         i__3 = *kb - 1;
00389         for (k = 1; k <= i__3; ++k) {
00390             if (update) {
00391 
00392 /*              Determine the rotations which would annihilate the bulge */
00393 /*              which has in theory just been created */
00394 
00395                 if (i__ - k + *ka < *n && i__ - k > 1) {
00396 
00397 /*                 generate rotation to annihilate a(i,i-k+ka+1) */
00398 
00399                     dlartg_(&ab[k + 1 + (i__ - k + *ka) * ab_dim1], &ra1, &
00400                             work[*n + i__ - k + *ka - m], &work[i__ - k + *ka 
00401                             - m], &ra);
00402 
00403 /*                 create nonzero element a(i-k,i-k+ka+1) outside the */
00404 /*                 band and store it in WORK(i-k) */
00405 
00406                     t = -bb[kb1 - k + i__ * bb_dim1] * ra1;
00407                     work[i__ - k] = work[*n + i__ - k + *ka - m] * t - work[
00408                             i__ - k + *ka - m] * ab[(i__ - k + *ka) * ab_dim1 
00409                             + 1];
00410                     ab[(i__ - k + *ka) * ab_dim1 + 1] = work[i__ - k + *ka - 
00411                             m] * t + work[*n + i__ - k + *ka - m] * ab[(i__ - 
00412                             k + *ka) * ab_dim1 + 1];
00413                     ra1 = ra;
00414                 }
00415             }
00416 /* Computing MAX */
00417             i__2 = 1, i__4 = k - i0 + 2;
00418             j2 = i__ - k - 1 + max(i__2,i__4) * ka1;
00419             nr = (*n - j2 + *ka) / ka1;
00420             j1 = j2 + (nr - 1) * ka1;
00421             if (update) {
00422 /* Computing MAX */
00423                 i__2 = j2, i__4 = i__ + (*ka << 1) - k + 1;
00424                 j2t = max(i__2,i__4);
00425             } else {
00426                 j2t = j2;
00427             }
00428             nrt = (*n - j2t + *ka) / ka1;
00429             i__2 = j1;
00430             i__4 = ka1;
00431             for (j = j2t; i__4 < 0 ? j >= i__2 : j <= i__2; j += i__4) {
00432 
00433 /*              create nonzero element a(j-ka,j+1) outside the band */
00434 /*              and store it in WORK(j-m) */
00435 
00436                 work[j - m] *= ab[(j + 1) * ab_dim1 + 1];
00437                 ab[(j + 1) * ab_dim1 + 1] = work[*n + j - m] * ab[(j + 1) * 
00438                         ab_dim1 + 1];
00439 /* L90: */
00440             }
00441 
00442 /*           generate rotations in 1st set to annihilate elements which */
00443 /*           have been created outside the band */
00444 
00445             if (nrt > 0) {
00446                 dlargv_(&nrt, &ab[j2t * ab_dim1 + 1], &inca, &work[j2t - m], &
00447                         ka1, &work[*n + j2t - m], &ka1);
00448             }
00449             if (nr > 0) {
00450 
00451 /*              apply rotations in 1st set from the right */
00452 
00453                 i__4 = *ka - 1;
00454                 for (l = 1; l <= i__4; ++l) {
00455                     dlartv_(&nr, &ab[ka1 - l + j2 * ab_dim1], &inca, &ab[*ka 
00456                             - l + (j2 + 1) * ab_dim1], &inca, &work[*n + j2 - 
00457                             m], &work[j2 - m], &ka1);
00458 /* L100: */
00459                 }
00460 
00461 /*              apply rotations in 1st set from both sides to diagonal */
00462 /*              blocks */
00463 
00464                 dlar2v_(&nr, &ab[ka1 + j2 * ab_dim1], &ab[ka1 + (j2 + 1) * 
00465                         ab_dim1], &ab[*ka + (j2 + 1) * ab_dim1], &inca, &work[
00466                         *n + j2 - m], &work[j2 - m], &ka1);
00467 
00468             }
00469 
00470 /*           start applying rotations in 1st set from the left */
00471 
00472             i__4 = *kb - k + 1;
00473             for (l = *ka - 1; l >= i__4; --l) {
00474                 nrt = (*n - j2 + l) / ka1;
00475                 if (nrt > 0) {
00476                     dlartv_(&nrt, &ab[l + (j2 + ka1 - l) * ab_dim1], &inca, &
00477                             ab[l + 1 + (j2 + ka1 - l) * ab_dim1], &inca, &
00478                             work[*n + j2 - m], &work[j2 - m], &ka1);
00479                 }
00480 /* L110: */
00481             }
00482 
00483             if (wantx) {
00484 
00485 /*              post-multiply X by product of rotations in 1st set */
00486 
00487                 i__4 = j1;
00488                 i__2 = ka1;
00489                 for (j = j2; i__2 < 0 ? j >= i__4 : j <= i__4; j += i__2) {
00490                     i__1 = *n - m;
00491                     drot_(&i__1, &x[m + 1 + j * x_dim1], &c__1, &x[m + 1 + (j 
00492                             + 1) * x_dim1], &c__1, &work[*n + j - m], &work[j 
00493                             - m]);
00494 /* L120: */
00495                 }
00496             }
00497 /* L130: */
00498         }
00499 
00500         if (update) {
00501             if (i2 <= *n && kbt > 0) {
00502 
00503 /*              create nonzero element a(i-kbt,i-kbt+ka+1) outside the */
00504 /*              band and store it in WORK(i-kbt) */
00505 
00506                 work[i__ - kbt] = -bb[kb1 - kbt + i__ * bb_dim1] * ra1;
00507             }
00508         }
00509 
00510         for (k = *kb; k >= 1; --k) {
00511             if (update) {
00512 /* Computing MAX */
00513                 i__3 = 2, i__2 = k - i0 + 1;
00514                 j2 = i__ - k - 1 + max(i__3,i__2) * ka1;
00515             } else {
00516 /* Computing MAX */
00517                 i__3 = 1, i__2 = k - i0 + 1;
00518                 j2 = i__ - k - 1 + max(i__3,i__2) * ka1;
00519             }
00520 
00521 /*           finish applying rotations in 2nd set from the left */
00522 
00523             for (l = *kb - k; l >= 1; --l) {
00524                 nrt = (*n - j2 + *ka + l) / ka1;
00525                 if (nrt > 0) {
00526                     dlartv_(&nrt, &ab[l + (j2 - l + 1) * ab_dim1], &inca, &ab[
00527                             l + 1 + (j2 - l + 1) * ab_dim1], &inca, &work[*n 
00528                             + j2 - *ka], &work[j2 - *ka], &ka1);
00529                 }
00530 /* L140: */
00531             }
00532             nr = (*n - j2 + *ka) / ka1;
00533             j1 = j2 + (nr - 1) * ka1;
00534             i__3 = j2;
00535             i__2 = -ka1;
00536             for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2) {
00537                 work[j] = work[j - *ka];
00538                 work[*n + j] = work[*n + j - *ka];
00539 /* L150: */
00540             }
00541             i__2 = j1;
00542             i__3 = ka1;
00543             for (j = j2; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3) {
00544 
00545 /*              create nonzero element a(j-ka,j+1) outside the band */
00546 /*              and store it in WORK(j) */
00547 
00548                 work[j] *= ab[(j + 1) * ab_dim1 + 1];
00549                 ab[(j + 1) * ab_dim1 + 1] = work[*n + j] * ab[(j + 1) * 
00550                         ab_dim1 + 1];
00551 /* L160: */
00552             }
00553             if (update) {
00554                 if (i__ - k < *n - *ka && k <= kbt) {
00555                     work[i__ - k + *ka] = work[i__ - k];
00556                 }
00557             }
00558 /* L170: */
00559         }
00560 
00561         for (k = *kb; k >= 1; --k) {
00562 /* Computing MAX */
00563             i__3 = 1, i__2 = k - i0 + 1;
00564             j2 = i__ - k - 1 + max(i__3,i__2) * ka1;
00565             nr = (*n - j2 + *ka) / ka1;
00566             j1 = j2 + (nr - 1) * ka1;
00567             if (nr > 0) {
00568 
00569 /*              generate rotations in 2nd set to annihilate elements */
00570 /*              which have been created outside the band */
00571 
00572                 dlargv_(&nr, &ab[j2 * ab_dim1 + 1], &inca, &work[j2], &ka1, &
00573                         work[*n + j2], &ka1);
00574 
00575 /*              apply rotations in 2nd set from the right */
00576 
00577                 i__3 = *ka - 1;
00578                 for (l = 1; l <= i__3; ++l) {
00579                     dlartv_(&nr, &ab[ka1 - l + j2 * ab_dim1], &inca, &ab[*ka 
00580                             - l + (j2 + 1) * ab_dim1], &inca, &work[*n + j2], 
00581                             &work[j2], &ka1);
00582 /* L180: */
00583                 }
00584 
00585 /*              apply rotations in 2nd set from both sides to diagonal */
00586 /*              blocks */
00587 
00588                 dlar2v_(&nr, &ab[ka1 + j2 * ab_dim1], &ab[ka1 + (j2 + 1) * 
00589                         ab_dim1], &ab[*ka + (j2 + 1) * ab_dim1], &inca, &work[
00590                         *n + j2], &work[j2], &ka1);
00591 
00592             }
00593 
00594 /*           start applying rotations in 2nd set from the left */
00595 
00596             i__3 = *kb - k + 1;
00597             for (l = *ka - 1; l >= i__3; --l) {
00598                 nrt = (*n - j2 + l) / ka1;
00599                 if (nrt > 0) {
00600                     dlartv_(&nrt, &ab[l + (j2 + ka1 - l) * ab_dim1], &inca, &
00601                             ab[l + 1 + (j2 + ka1 - l) * ab_dim1], &inca, &
00602                             work[*n + j2], &work[j2], &ka1);
00603                 }
00604 /* L190: */
00605             }
00606 
00607             if (wantx) {
00608 
00609 /*              post-multiply X by product of rotations in 2nd set */
00610 
00611                 i__3 = j1;
00612                 i__2 = ka1;
00613                 for (j = j2; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2) {
00614                     i__4 = *n - m;
00615                     drot_(&i__4, &x[m + 1 + j * x_dim1], &c__1, &x[m + 1 + (j 
00616                             + 1) * x_dim1], &c__1, &work[*n + j], &work[j]);
00617 /* L200: */
00618                 }
00619             }
00620 /* L210: */
00621         }
00622 
00623         i__2 = *kb - 1;
00624         for (k = 1; k <= i__2; ++k) {
00625 /* Computing MAX */
00626             i__3 = 1, i__4 = k - i0 + 2;
00627             j2 = i__ - k - 1 + max(i__3,i__4) * ka1;
00628 
00629 /*           finish applying rotations in 1st set from the left */
00630 
00631             for (l = *kb - k; l >= 1; --l) {
00632                 nrt = (*n - j2 + l) / ka1;
00633                 if (nrt > 0) {
00634                     dlartv_(&nrt, &ab[l + (j2 + ka1 - l) * ab_dim1], &inca, &
00635                             ab[l + 1 + (j2 + ka1 - l) * ab_dim1], &inca, &
00636                             work[*n + j2 - m], &work[j2 - m], &ka1);
00637                 }
00638 /* L220: */
00639             }
00640 /* L230: */
00641         }
00642 
00643         if (*kb > 1) {
00644             i__2 = i__ - *kb + (*ka << 1) + 1;
00645             for (j = *n - 1; j >= i__2; --j) {
00646                 work[*n + j - m] = work[*n + j - *ka - m];
00647                 work[j - m] = work[j - *ka - m];
00648 /* L240: */
00649             }
00650         }
00651 
00652     } else {
00653 
00654 /*        Transform A, working with the lower triangle */
00655 
00656         if (update) {
00657 
00658 /*           Form  inv(S(i))**T * A * inv(S(i)) */
00659 
00660             bii = bb[i__ * bb_dim1 + 1];
00661             i__2 = i1;
00662             for (j = i__; j <= i__2; ++j) {
00663                 ab[j - i__ + 1 + i__ * ab_dim1] /= bii;
00664 /* L250: */
00665             }
00666 /* Computing MAX */
00667             i__2 = 1, i__3 = i__ - *ka;
00668             i__4 = i__;
00669             for (j = max(i__2,i__3); j <= i__4; ++j) {
00670                 ab[i__ - j + 1 + j * ab_dim1] /= bii;
00671 /* L260: */
00672             }
00673             i__4 = i__ - 1;
00674             for (k = i__ - kbt; k <= i__4; ++k) {
00675                 i__2 = k;
00676                 for (j = i__ - kbt; j <= i__2; ++j) {
00677                     ab[k - j + 1 + j * ab_dim1] = ab[k - j + 1 + j * ab_dim1] 
00678                             - bb[i__ - j + 1 + j * bb_dim1] * ab[i__ - k + 1 
00679                             + k * ab_dim1] - bb[i__ - k + 1 + k * bb_dim1] * 
00680                             ab[i__ - j + 1 + j * ab_dim1] + ab[i__ * ab_dim1 
00681                             + 1] * bb[i__ - j + 1 + j * bb_dim1] * bb[i__ - k 
00682                             + 1 + k * bb_dim1];
00683 /* L270: */
00684                 }
00685 /* Computing MAX */
00686                 i__2 = 1, i__3 = i__ - *ka;
00687                 i__1 = i__ - kbt - 1;
00688                 for (j = max(i__2,i__3); j <= i__1; ++j) {
00689                     ab[k - j + 1 + j * ab_dim1] -= bb[i__ - k + 1 + k * 
00690                             bb_dim1] * ab[i__ - j + 1 + j * ab_dim1];
00691 /* L280: */
00692                 }
00693 /* L290: */
00694             }
00695             i__4 = i1;
00696             for (j = i__; j <= i__4; ++j) {
00697 /* Computing MAX */
00698                 i__1 = j - *ka, i__2 = i__ - kbt;
00699                 i__3 = i__ - 1;
00700                 for (k = max(i__1,i__2); k <= i__3; ++k) {
00701                     ab[j - k + 1 + k * ab_dim1] -= bb[i__ - k + 1 + k * 
00702                             bb_dim1] * ab[j - i__ + 1 + i__ * ab_dim1];
00703 /* L300: */
00704                 }
00705 /* L310: */
00706             }
00707 
00708             if (wantx) {
00709 
00710 /*              post-multiply X by inv(S(i)) */
00711 
00712                 i__4 = *n - m;
00713                 d__1 = 1. / bii;
00714                 dscal_(&i__4, &d__1, &x[m + 1 + i__ * x_dim1], &c__1);
00715                 if (kbt > 0) {
00716                     i__4 = *n - m;
00717                     i__3 = *ldbb - 1;
00718                     dger_(&i__4, &kbt, &c_b20, &x[m + 1 + i__ * x_dim1], &
00719                             c__1, &bb[kbt + 1 + (i__ - kbt) * bb_dim1], &i__3, 
00720                              &x[m + 1 + (i__ - kbt) * x_dim1], ldx);
00721                 }
00722             }
00723 
00724 /*           store a(i1,i) in RA1 for use in next loop over K */
00725 
00726             ra1 = ab[i1 - i__ + 1 + i__ * ab_dim1];
00727         }
00728 
00729 /*        Generate and apply vectors of rotations to chase all the */
00730 /*        existing bulges KA positions down toward the bottom of the */
00731 /*        band */
00732 
00733         i__4 = *kb - 1;
00734         for (k = 1; k <= i__4; ++k) {
00735             if (update) {
00736 
00737 /*              Determine the rotations which would annihilate the bulge */
00738 /*              which has in theory just been created */
00739 
00740                 if (i__ - k + *ka < *n && i__ - k > 1) {
00741 
00742 /*                 generate rotation to annihilate a(i-k+ka+1,i) */
00743 
00744                     dlartg_(&ab[ka1 - k + i__ * ab_dim1], &ra1, &work[*n + 
00745                             i__ - k + *ka - m], &work[i__ - k + *ka - m], &ra)
00746                             ;
00747 
00748 /*                 create nonzero element a(i-k+ka+1,i-k) outside the */
00749 /*                 band and store it in WORK(i-k) */
00750 
00751                     t = -bb[k + 1 + (i__ - k) * bb_dim1] * ra1;
00752                     work[i__ - k] = work[*n + i__ - k + *ka - m] * t - work[
00753                             i__ - k + *ka - m] * ab[ka1 + (i__ - k) * ab_dim1]
00754                             ;
00755                     ab[ka1 + (i__ - k) * ab_dim1] = work[i__ - k + *ka - m] * 
00756                             t + work[*n + i__ - k + *ka - m] * ab[ka1 + (i__ 
00757                             - k) * ab_dim1];
00758                     ra1 = ra;
00759                 }
00760             }
00761 /* Computing MAX */
00762             i__3 = 1, i__1 = k - i0 + 2;
00763             j2 = i__ - k - 1 + max(i__3,i__1) * ka1;
00764             nr = (*n - j2 + *ka) / ka1;
00765             j1 = j2 + (nr - 1) * ka1;
00766             if (update) {
00767 /* Computing MAX */
00768                 i__3 = j2, i__1 = i__ + (*ka << 1) - k + 1;
00769                 j2t = max(i__3,i__1);
00770             } else {
00771                 j2t = j2;
00772             }
00773             nrt = (*n - j2t + *ka) / ka1;
00774             i__3 = j1;
00775             i__1 = ka1;
00776             for (j = j2t; i__1 < 0 ? j >= i__3 : j <= i__3; j += i__1) {
00777 
00778 /*              create nonzero element a(j+1,j-ka) outside the band */
00779 /*              and store it in WORK(j-m) */
00780 
00781                 work[j - m] *= ab[ka1 + (j - *ka + 1) * ab_dim1];
00782                 ab[ka1 + (j - *ka + 1) * ab_dim1] = work[*n + j - m] * ab[ka1 
00783                         + (j - *ka + 1) * ab_dim1];
00784 /* L320: */
00785             }
00786 
00787 /*           generate rotations in 1st set to annihilate elements which */
00788 /*           have been created outside the band */
00789 
00790             if (nrt > 0) {
00791                 dlargv_(&nrt, &ab[ka1 + (j2t - *ka) * ab_dim1], &inca, &work[
00792                         j2t - m], &ka1, &work[*n + j2t - m], &ka1);
00793             }
00794             if (nr > 0) {
00795 
00796 /*              apply rotations in 1st set from the left */
00797 
00798                 i__1 = *ka - 1;
00799                 for (l = 1; l <= i__1; ++l) {
00800                     dlartv_(&nr, &ab[l + 1 + (j2 - l) * ab_dim1], &inca, &ab[
00801                             l + 2 + (j2 - l) * ab_dim1], &inca, &work[*n + j2 
00802                             - m], &work[j2 - m], &ka1);
00803 /* L330: */
00804                 }
00805 
00806 /*              apply rotations in 1st set from both sides to diagonal */
00807 /*              blocks */
00808 
00809                 dlar2v_(&nr, &ab[j2 * ab_dim1 + 1], &ab[(j2 + 1) * ab_dim1 + 
00810                         1], &ab[j2 * ab_dim1 + 2], &inca, &work[*n + j2 - m], 
00811                         &work[j2 - m], &ka1);
00812 
00813             }
00814 
00815 /*           start applying rotations in 1st set from the right */
00816 
00817             i__1 = *kb - k + 1;
00818             for (l = *ka - 1; l >= i__1; --l) {
00819                 nrt = (*n - j2 + l) / ka1;
00820                 if (nrt > 0) {
00821                     dlartv_(&nrt, &ab[ka1 - l + 1 + j2 * ab_dim1], &inca, &ab[
00822                             ka1 - l + (j2 + 1) * ab_dim1], &inca, &work[*n + 
00823                             j2 - m], &work[j2 - m], &ka1);
00824                 }
00825 /* L340: */
00826             }
00827 
00828             if (wantx) {
00829 
00830 /*              post-multiply X by product of rotations in 1st set */
00831 
00832                 i__1 = j1;
00833                 i__3 = ka1;
00834                 for (j = j2; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
00835                     i__2 = *n - m;
00836                     drot_(&i__2, &x[m + 1 + j * x_dim1], &c__1, &x[m + 1 + (j 
00837                             + 1) * x_dim1], &c__1, &work[*n + j - m], &work[j 
00838                             - m]);
00839 /* L350: */
00840                 }
00841             }
00842 /* L360: */
00843         }
00844 
00845         if (update) {
00846             if (i2 <= *n && kbt > 0) {
00847 
00848 /*              create nonzero element a(i-kbt+ka+1,i-kbt) outside the */
00849 /*              band and store it in WORK(i-kbt) */
00850 
00851                 work[i__ - kbt] = -bb[kbt + 1 + (i__ - kbt) * bb_dim1] * ra1;
00852             }
00853         }
00854 
00855         for (k = *kb; k >= 1; --k) {
00856             if (update) {
00857 /* Computing MAX */
00858                 i__4 = 2, i__3 = k - i0 + 1;
00859                 j2 = i__ - k - 1 + max(i__4,i__3) * ka1;
00860             } else {
00861 /* Computing MAX */
00862                 i__4 = 1, i__3 = k - i0 + 1;
00863                 j2 = i__ - k - 1 + max(i__4,i__3) * ka1;
00864             }
00865 
00866 /*           finish applying rotations in 2nd set from the right */
00867 
00868             for (l = *kb - k; l >= 1; --l) {
00869                 nrt = (*n - j2 + *ka + l) / ka1;
00870                 if (nrt > 0) {
00871                     dlartv_(&nrt, &ab[ka1 - l + 1 + (j2 - *ka) * ab_dim1], &
00872                             inca, &ab[ka1 - l + (j2 - *ka + 1) * ab_dim1], &
00873                             inca, &work[*n + j2 - *ka], &work[j2 - *ka], &ka1)
00874                             ;
00875                 }
00876 /* L370: */
00877             }
00878             nr = (*n - j2 + *ka) / ka1;
00879             j1 = j2 + (nr - 1) * ka1;
00880             i__4 = j2;
00881             i__3 = -ka1;
00882             for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) {
00883                 work[j] = work[j - *ka];
00884                 work[*n + j] = work[*n + j - *ka];
00885 /* L380: */
00886             }
00887             i__3 = j1;
00888             i__4 = ka1;
00889             for (j = j2; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
00890 
00891 /*              create nonzero element a(j+1,j-ka) outside the band */
00892 /*              and store it in WORK(j) */
00893 
00894                 work[j] *= ab[ka1 + (j - *ka + 1) * ab_dim1];
00895                 ab[ka1 + (j - *ka + 1) * ab_dim1] = work[*n + j] * ab[ka1 + (
00896                         j - *ka + 1) * ab_dim1];
00897 /* L390: */
00898             }
00899             if (update) {
00900                 if (i__ - k < *n - *ka && k <= kbt) {
00901                     work[i__ - k + *ka] = work[i__ - k];
00902                 }
00903             }
00904 /* L400: */
00905         }
00906 
00907         for (k = *kb; k >= 1; --k) {
00908 /* Computing MAX */
00909             i__4 = 1, i__3 = k - i0 + 1;
00910             j2 = i__ - k - 1 + max(i__4,i__3) * ka1;
00911             nr = (*n - j2 + *ka) / ka1;
00912             j1 = j2 + (nr - 1) * ka1;
00913             if (nr > 0) {
00914 
00915 /*              generate rotations in 2nd set to annihilate elements */
00916 /*              which have been created outside the band */
00917 
00918                 dlargv_(&nr, &ab[ka1 + (j2 - *ka) * ab_dim1], &inca, &work[j2]
00919 , &ka1, &work[*n + j2], &ka1);
00920 
00921 /*              apply rotations in 2nd set from the left */
00922 
00923                 i__4 = *ka - 1;
00924                 for (l = 1; l <= i__4; ++l) {
00925                     dlartv_(&nr, &ab[l + 1 + (j2 - l) * ab_dim1], &inca, &ab[
00926                             l + 2 + (j2 - l) * ab_dim1], &inca, &work[*n + j2]
00927 , &work[j2], &ka1);
00928 /* L410: */
00929                 }
00930 
00931 /*              apply rotations in 2nd set from both sides to diagonal */
00932 /*              blocks */
00933 
00934                 dlar2v_(&nr, &ab[j2 * ab_dim1 + 1], &ab[(j2 + 1) * ab_dim1 + 
00935                         1], &ab[j2 * ab_dim1 + 2], &inca, &work[*n + j2], &
00936                         work[j2], &ka1);
00937 
00938             }
00939 
00940 /*           start applying rotations in 2nd set from the right */
00941 
00942             i__4 = *kb - k + 1;
00943             for (l = *ka - 1; l >= i__4; --l) {
00944                 nrt = (*n - j2 + l) / ka1;
00945                 if (nrt > 0) {
00946                     dlartv_(&nrt, &ab[ka1 - l + 1 + j2 * ab_dim1], &inca, &ab[
00947                             ka1 - l + (j2 + 1) * ab_dim1], &inca, &work[*n + 
00948                             j2], &work[j2], &ka1);
00949                 }
00950 /* L420: */
00951             }
00952 
00953             if (wantx) {
00954 
00955 /*              post-multiply X by product of rotations in 2nd set */
00956 
00957                 i__4 = j1;
00958                 i__3 = ka1;
00959                 for (j = j2; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) {
00960                     i__1 = *n - m;
00961                     drot_(&i__1, &x[m + 1 + j * x_dim1], &c__1, &x[m + 1 + (j 
00962                             + 1) * x_dim1], &c__1, &work[*n + j], &work[j]);
00963 /* L430: */
00964                 }
00965             }
00966 /* L440: */
00967         }
00968 
00969         i__3 = *kb - 1;
00970         for (k = 1; k <= i__3; ++k) {
00971 /* Computing MAX */
00972             i__4 = 1, i__1 = k - i0 + 2;
00973             j2 = i__ - k - 1 + max(i__4,i__1) * ka1;
00974 
00975 /*           finish applying rotations in 1st set from the right */
00976 
00977             for (l = *kb - k; l >= 1; --l) {
00978                 nrt = (*n - j2 + l) / ka1;
00979                 if (nrt > 0) {
00980                     dlartv_(&nrt, &ab[ka1 - l + 1 + j2 * ab_dim1], &inca, &ab[
00981                             ka1 - l + (j2 + 1) * ab_dim1], &inca, &work[*n + 
00982                             j2 - m], &work[j2 - m], &ka1);
00983                 }
00984 /* L450: */
00985             }
00986 /* L460: */
00987         }
00988 
00989         if (*kb > 1) {
00990             i__3 = i__ - *kb + (*ka << 1) + 1;
00991             for (j = *n - 1; j >= i__3; --j) {
00992                 work[*n + j - m] = work[*n + j - *ka - m];
00993                 work[j - m] = work[j - *ka - m];
00994 /* L470: */
00995             }
00996         }
00997 
00998     }
00999 
01000     goto L10;
01001 
01002 L480:
01003 
01004 /*     **************************** Phase 2 ***************************** */
01005 
01006 /*     The logical structure of this phase is: */
01007 
01008 /*     UPDATE = .TRUE. */
01009 /*     DO I = 1, M */
01010 /*        use S(i) to update A and create a new bulge */
01011 /*        apply rotations to push all bulges KA positions upward */
01012 /*     END DO */
01013 /*     UPDATE = .FALSE. */
01014 /*     DO I = M - KA - 1, 2, -1 */
01015 /*        apply rotations to push all bulges KA positions upward */
01016 /*     END DO */
01017 
01018 /*     To avoid duplicating code, the two loops are merged. */
01019 
01020     update = TRUE_;
01021     i__ = 0;
01022 L490:
01023     if (update) {
01024         ++i__;
01025 /* Computing MIN */
01026         i__3 = *kb, i__4 = m - i__;
01027         kbt = min(i__3,i__4);
01028         i0 = i__ + 1;
01029 /* Computing MAX */
01030         i__3 = 1, i__4 = i__ - *ka;
01031         i1 = max(i__3,i__4);
01032         i2 = i__ + kbt - ka1;
01033         if (i__ > m) {
01034             update = FALSE_;
01035             --i__;
01036             i0 = m + 1;
01037             if (*ka == 0) {
01038                 return 0;
01039             }
01040             goto L490;
01041         }
01042     } else {
01043         i__ -= *ka;
01044         if (i__ < 2) {
01045             return 0;
01046         }
01047     }
01048 
01049     if (i__ < m - kbt) {
01050         nx = m;
01051     } else {
01052         nx = *n;
01053     }
01054 
01055     if (upper) {
01056 
01057 /*        Transform A, working with the upper triangle */
01058 
01059         if (update) {
01060 
01061 /*           Form  inv(S(i))**T * A * inv(S(i)) */
01062 
01063             bii = bb[kb1 + i__ * bb_dim1];
01064             i__3 = i__;
01065             for (j = i1; j <= i__3; ++j) {
01066                 ab[j - i__ + ka1 + i__ * ab_dim1] /= bii;
01067 /* L500: */
01068             }
01069 /* Computing MIN */
01070             i__4 = *n, i__1 = i__ + *ka;
01071             i__3 = min(i__4,i__1);
01072             for (j = i__; j <= i__3; ++j) {
01073                 ab[i__ - j + ka1 + j * ab_dim1] /= bii;
01074 /* L510: */
01075             }
01076             i__3 = i__ + kbt;
01077             for (k = i__ + 1; k <= i__3; ++k) {
01078                 i__4 = i__ + kbt;
01079                 for (j = k; j <= i__4; ++j) {
01080                     ab[k - j + ka1 + j * ab_dim1] = ab[k - j + ka1 + j * 
01081                             ab_dim1] - bb[i__ - j + kb1 + j * bb_dim1] * ab[
01082                             i__ - k + ka1 + k * ab_dim1] - bb[i__ - k + kb1 + 
01083                             k * bb_dim1] * ab[i__ - j + ka1 + j * ab_dim1] + 
01084                             ab[ka1 + i__ * ab_dim1] * bb[i__ - j + kb1 + j * 
01085                             bb_dim1] * bb[i__ - k + kb1 + k * bb_dim1];
01086 /* L520: */
01087                 }
01088 /* Computing MIN */
01089                 i__1 = *n, i__2 = i__ + *ka;
01090                 i__4 = min(i__1,i__2);
01091                 for (j = i__ + kbt + 1; j <= i__4; ++j) {
01092                     ab[k - j + ka1 + j * ab_dim1] -= bb[i__ - k + kb1 + k * 
01093                             bb_dim1] * ab[i__ - j + ka1 + j * ab_dim1];
01094 /* L530: */
01095                 }
01096 /* L540: */
01097             }
01098             i__3 = i__;
01099             for (j = i1; j <= i__3; ++j) {
01100 /* Computing MIN */
01101                 i__1 = j + *ka, i__2 = i__ + kbt;
01102                 i__4 = min(i__1,i__2);
01103                 for (k = i__ + 1; k <= i__4; ++k) {
01104                     ab[j - k + ka1 + k * ab_dim1] -= bb[i__ - k + kb1 + k * 
01105                             bb_dim1] * ab[j - i__ + ka1 + i__ * ab_dim1];
01106 /* L550: */
01107                 }
01108 /* L560: */
01109             }
01110 
01111             if (wantx) {
01112 
01113 /*              post-multiply X by inv(S(i)) */
01114 
01115                 d__1 = 1. / bii;
01116                 dscal_(&nx, &d__1, &x[i__ * x_dim1 + 1], &c__1);
01117                 if (kbt > 0) {
01118                     i__3 = *ldbb - 1;
01119                     dger_(&nx, &kbt, &c_b20, &x[i__ * x_dim1 + 1], &c__1, &bb[
01120                             *kb + (i__ + 1) * bb_dim1], &i__3, &x[(i__ + 1) * 
01121                             x_dim1 + 1], ldx);
01122                 }
01123             }
01124 
01125 /*           store a(i1,i) in RA1 for use in next loop over K */
01126 
01127             ra1 = ab[i1 - i__ + ka1 + i__ * ab_dim1];
01128         }
01129 
01130 /*        Generate and apply vectors of rotations to chase all the */
01131 /*        existing bulges KA positions up toward the top of the band */
01132 
01133         i__3 = *kb - 1;
01134         for (k = 1; k <= i__3; ++k) {
01135             if (update) {
01136 
01137 /*              Determine the rotations which would annihilate the bulge */
01138 /*              which has in theory just been created */
01139 
01140                 if (i__ + k - ka1 > 0 && i__ + k < m) {
01141 
01142 /*                 generate rotation to annihilate a(i+k-ka-1,i) */
01143 
01144                     dlartg_(&ab[k + 1 + i__ * ab_dim1], &ra1, &work[*n + i__ 
01145                             + k - *ka], &work[i__ + k - *ka], &ra);
01146 
01147 /*                 create nonzero element a(i+k-ka-1,i+k) outside the */
01148 /*                 band and store it in WORK(m-kb+i+k) */
01149 
01150                     t = -bb[kb1 - k + (i__ + k) * bb_dim1] * ra1;
01151                     work[m - *kb + i__ + k] = work[*n + i__ + k - *ka] * t - 
01152                             work[i__ + k - *ka] * ab[(i__ + k) * ab_dim1 + 1];
01153                     ab[(i__ + k) * ab_dim1 + 1] = work[i__ + k - *ka] * t + 
01154                             work[*n + i__ + k - *ka] * ab[(i__ + k) * ab_dim1 
01155                             + 1];
01156                     ra1 = ra;
01157                 }
01158             }
01159 /* Computing MAX */
01160             i__4 = 1, i__1 = k + i0 - m + 1;
01161             j2 = i__ + k + 1 - max(i__4,i__1) * ka1;
01162             nr = (j2 + *ka - 1) / ka1;
01163             j1 = j2 - (nr - 1) * ka1;
01164             if (update) {
01165 /* Computing MIN */
01166                 i__4 = j2, i__1 = i__ - (*ka << 1) + k - 1;
01167                 j2t = min(i__4,i__1);
01168             } else {
01169                 j2t = j2;
01170             }
01171             nrt = (j2t + *ka - 1) / ka1;
01172             i__4 = j2t;
01173             i__1 = ka1;
01174             for (j = j1; i__1 < 0 ? j >= i__4 : j <= i__4; j += i__1) {
01175 
01176 /*              create nonzero element a(j-1,j+ka) outside the band */
01177 /*              and store it in WORK(j) */
01178 
01179                 work[j] *= ab[(j + *ka - 1) * ab_dim1 + 1];
01180                 ab[(j + *ka - 1) * ab_dim1 + 1] = work[*n + j] * ab[(j + *ka 
01181                         - 1) * ab_dim1 + 1];
01182 /* L570: */
01183             }
01184 
01185 /*           generate rotations in 1st set to annihilate elements which */
01186 /*           have been created outside the band */
01187 
01188             if (nrt > 0) {
01189                 dlargv_(&nrt, &ab[(j1 + *ka) * ab_dim1 + 1], &inca, &work[j1], 
01190                          &ka1, &work[*n + j1], &ka1);
01191             }
01192             if (nr > 0) {
01193 
01194 /*              apply rotations in 1st set from the left */
01195 
01196                 i__1 = *ka - 1;
01197                 for (l = 1; l <= i__1; ++l) {
01198                     dlartv_(&nr, &ab[ka1 - l + (j1 + l) * ab_dim1], &inca, &
01199                             ab[*ka - l + (j1 + l) * ab_dim1], &inca, &work[*n 
01200                             + j1], &work[j1], &ka1);
01201 /* L580: */
01202                 }
01203 
01204 /*              apply rotations in 1st set from both sides to diagonal */
01205 /*              blocks */
01206 
01207                 dlar2v_(&nr, &ab[ka1 + j1 * ab_dim1], &ab[ka1 + (j1 - 1) * 
01208                         ab_dim1], &ab[*ka + j1 * ab_dim1], &inca, &work[*n + 
01209                         j1], &work[j1], &ka1);
01210 
01211             }
01212 
01213 /*           start applying rotations in 1st set from the right */
01214 
01215             i__1 = *kb - k + 1;
01216             for (l = *ka - 1; l >= i__1; --l) {
01217                 nrt = (j2 + l - 1) / ka1;
01218                 j1t = j2 - (nrt - 1) * ka1;
01219                 if (nrt > 0) {
01220                     dlartv_(&nrt, &ab[l + j1t * ab_dim1], &inca, &ab[l + 1 + (
01221                             j1t - 1) * ab_dim1], &inca, &work[*n + j1t], &
01222                             work[j1t], &ka1);
01223                 }
01224 /* L590: */
01225             }
01226 
01227             if (wantx) {
01228 
01229 /*              post-multiply X by product of rotations in 1st set */
01230 
01231                 i__1 = j2;
01232                 i__4 = ka1;
01233                 for (j = j1; i__4 < 0 ? j >= i__1 : j <= i__1; j += i__4) {
01234                     drot_(&nx, &x[j * x_dim1 + 1], &c__1, &x[(j - 1) * x_dim1 
01235                             + 1], &c__1, &work[*n + j], &work[j]);
01236 /* L600: */
01237                 }
01238             }
01239 /* L610: */
01240         }
01241 
01242         if (update) {
01243             if (i2 > 0 && kbt > 0) {
01244 
01245 /*              create nonzero element a(i+kbt-ka-1,i+kbt) outside the */
01246 /*              band and store it in WORK(m-kb+i+kbt) */
01247 
01248                 work[m - *kb + i__ + kbt] = -bb[kb1 - kbt + (i__ + kbt) * 
01249                         bb_dim1] * ra1;
01250             }
01251         }
01252 
01253         for (k = *kb; k >= 1; --k) {
01254             if (update) {
01255 /* Computing MAX */
01256                 i__3 = 2, i__4 = k + i0 - m;
01257                 j2 = i__ + k + 1 - max(i__3,i__4) * ka1;
01258             } else {
01259 /* Computing MAX */
01260                 i__3 = 1, i__4 = k + i0 - m;
01261                 j2 = i__ + k + 1 - max(i__3,i__4) * ka1;
01262             }
01263 
01264 /*           finish applying rotations in 2nd set from the right */
01265 
01266             for (l = *kb - k; l >= 1; --l) {
01267                 nrt = (j2 + *ka + l - 1) / ka1;
01268                 j1t = j2 - (nrt - 1) * ka1;
01269                 if (nrt > 0) {
01270                     dlartv_(&nrt, &ab[l + (j1t + *ka) * ab_dim1], &inca, &ab[
01271                             l + 1 + (j1t + *ka - 1) * ab_dim1], &inca, &work[*
01272                             n + m - *kb + j1t + *ka], &work[m - *kb + j1t + *
01273                             ka], &ka1);
01274                 }
01275 /* L620: */
01276             }
01277             nr = (j2 + *ka - 1) / ka1;
01278             j1 = j2 - (nr - 1) * ka1;
01279             i__3 = j2;
01280             i__4 = ka1;
01281             for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
01282                 work[m - *kb + j] = work[m - *kb + j + *ka];
01283                 work[*n + m - *kb + j] = work[*n + m - *kb + j + *ka];
01284 /* L630: */
01285             }
01286             i__4 = j2;
01287             i__3 = ka1;
01288             for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) {
01289 
01290 /*              create nonzero element a(j-1,j+ka) outside the band */
01291 /*              and store it in WORK(m-kb+j) */
01292 
01293                 work[m - *kb + j] *= ab[(j + *ka - 1) * ab_dim1 + 1];
01294                 ab[(j + *ka - 1) * ab_dim1 + 1] = work[*n + m - *kb + j] * ab[
01295                         (j + *ka - 1) * ab_dim1 + 1];
01296 /* L640: */
01297             }
01298             if (update) {
01299                 if (i__ + k > ka1 && k <= kbt) {
01300                     work[m - *kb + i__ + k - *ka] = work[m - *kb + i__ + k];
01301                 }
01302             }
01303 /* L650: */
01304         }
01305 
01306         for (k = *kb; k >= 1; --k) {
01307 /* Computing MAX */
01308             i__3 = 1, i__4 = k + i0 - m;
01309             j2 = i__ + k + 1 - max(i__3,i__4) * ka1;
01310             nr = (j2 + *ka - 1) / ka1;
01311             j1 = j2 - (nr - 1) * ka1;
01312             if (nr > 0) {
01313 
01314 /*              generate rotations in 2nd set to annihilate elements */
01315 /*              which have been created outside the band */
01316 
01317                 dlargv_(&nr, &ab[(j1 + *ka) * ab_dim1 + 1], &inca, &work[m - *
01318                         kb + j1], &ka1, &work[*n + m - *kb + j1], &ka1);
01319 
01320 /*              apply rotations in 2nd set from the left */
01321 
01322                 i__3 = *ka - 1;
01323                 for (l = 1; l <= i__3; ++l) {
01324                     dlartv_(&nr, &ab[ka1 - l + (j1 + l) * ab_dim1], &inca, &
01325                             ab[*ka - l + (j1 + l) * ab_dim1], &inca, &work[*n 
01326                             + m - *kb + j1], &work[m - *kb + j1], &ka1);
01327 /* L660: */
01328                 }
01329 
01330 /*              apply rotations in 2nd set from both sides to diagonal */
01331 /*              blocks */
01332 
01333                 dlar2v_(&nr, &ab[ka1 + j1 * ab_dim1], &ab[ka1 + (j1 - 1) * 
01334                         ab_dim1], &ab[*ka + j1 * ab_dim1], &inca, &work[*n + 
01335                         m - *kb + j1], &work[m - *kb + j1], &ka1);
01336 
01337             }
01338 
01339 /*           start applying rotations in 2nd set from the right */
01340 
01341             i__3 = *kb - k + 1;
01342             for (l = *ka - 1; l >= i__3; --l) {
01343                 nrt = (j2 + l - 1) / ka1;
01344                 j1t = j2 - (nrt - 1) * ka1;
01345                 if (nrt > 0) {
01346                     dlartv_(&nrt, &ab[l + j1t * ab_dim1], &inca, &ab[l + 1 + (
01347                             j1t - 1) * ab_dim1], &inca, &work[*n + m - *kb + 
01348                             j1t], &work[m - *kb + j1t], &ka1);
01349                 }
01350 /* L670: */
01351             }
01352 
01353             if (wantx) {
01354 
01355 /*              post-multiply X by product of rotations in 2nd set */
01356 
01357                 i__3 = j2;
01358                 i__4 = ka1;
01359                 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
01360                     drot_(&nx, &x[j * x_dim1 + 1], &c__1, &x[(j - 1) * x_dim1 
01361                             + 1], &c__1, &work[*n + m - *kb + j], &work[m - *
01362                             kb + j]);
01363 /* L680: */
01364                 }
01365             }
01366 /* L690: */
01367         }
01368 
01369         i__4 = *kb - 1;
01370         for (k = 1; k <= i__4; ++k) {
01371 /* Computing MAX */
01372             i__3 = 1, i__1 = k + i0 - m + 1;
01373             j2 = i__ + k + 1 - max(i__3,i__1) * ka1;
01374 
01375 /*           finish applying rotations in 1st set from the right */
01376 
01377             for (l = *kb - k; l >= 1; --l) {
01378                 nrt = (j2 + l - 1) / ka1;
01379                 j1t = j2 - (nrt - 1) * ka1;
01380                 if (nrt > 0) {
01381                     dlartv_(&nrt, &ab[l + j1t * ab_dim1], &inca, &ab[l + 1 + (
01382                             j1t - 1) * ab_dim1], &inca, &work[*n + j1t], &
01383                             work[j1t], &ka1);
01384                 }
01385 /* L700: */
01386             }
01387 /* L710: */
01388         }
01389 
01390         if (*kb > 1) {
01391 /* Computing MIN */
01392             i__3 = i__ + *kb;
01393             i__4 = min(i__3,m) - (*ka << 1) - 1;
01394             for (j = 2; j <= i__4; ++j) {
01395                 work[*n + j] = work[*n + j + *ka];
01396                 work[j] = work[j + *ka];
01397 /* L720: */
01398             }
01399         }
01400 
01401     } else {
01402 
01403 /*        Transform A, working with the lower triangle */
01404 
01405         if (update) {
01406 
01407 /*           Form  inv(S(i))**T * A * inv(S(i)) */
01408 
01409             bii = bb[i__ * bb_dim1 + 1];
01410             i__4 = i__;
01411             for (j = i1; j <= i__4; ++j) {
01412                 ab[i__ - j + 1 + j * ab_dim1] /= bii;
01413 /* L730: */
01414             }
01415 /* Computing MIN */
01416             i__3 = *n, i__1 = i__ + *ka;
01417             i__4 = min(i__3,i__1);
01418             for (j = i__; j <= i__4; ++j) {
01419                 ab[j - i__ + 1 + i__ * ab_dim1] /= bii;
01420 /* L740: */
01421             }
01422             i__4 = i__ + kbt;
01423             for (k = i__ + 1; k <= i__4; ++k) {
01424                 i__3 = i__ + kbt;
01425                 for (j = k; j <= i__3; ++j) {
01426                     ab[j - k + 1 + k * ab_dim1] = ab[j - k + 1 + k * ab_dim1] 
01427                             - bb[j - i__ + 1 + i__ * bb_dim1] * ab[k - i__ + 
01428                             1 + i__ * ab_dim1] - bb[k - i__ + 1 + i__ * 
01429                             bb_dim1] * ab[j - i__ + 1 + i__ * ab_dim1] + ab[
01430                             i__ * ab_dim1 + 1] * bb[j - i__ + 1 + i__ * 
01431                             bb_dim1] * bb[k - i__ + 1 + i__ * bb_dim1];
01432 /* L750: */
01433                 }
01434 /* Computing MIN */
01435                 i__1 = *n, i__2 = i__ + *ka;
01436                 i__3 = min(i__1,i__2);
01437                 for (j = i__ + kbt + 1; j <= i__3; ++j) {
01438                     ab[j - k + 1 + k * ab_dim1] -= bb[k - i__ + 1 + i__ * 
01439                             bb_dim1] * ab[j - i__ + 1 + i__ * ab_dim1];
01440 /* L760: */
01441                 }
01442 /* L770: */
01443             }
01444             i__4 = i__;
01445             for (j = i1; j <= i__4; ++j) {
01446 /* Computing MIN */
01447                 i__1 = j + *ka, i__2 = i__ + kbt;
01448                 i__3 = min(i__1,i__2);
01449                 for (k = i__ + 1; k <= i__3; ++k) {
01450                     ab[k - j + 1 + j * ab_dim1] -= bb[k - i__ + 1 + i__ * 
01451                             bb_dim1] * ab[i__ - j + 1 + j * ab_dim1];
01452 /* L780: */
01453                 }
01454 /* L790: */
01455             }
01456 
01457             if (wantx) {
01458 
01459 /*              post-multiply X by inv(S(i)) */
01460 
01461                 d__1 = 1. / bii;
01462                 dscal_(&nx, &d__1, &x[i__ * x_dim1 + 1], &c__1);
01463                 if (kbt > 0) {
01464                     dger_(&nx, &kbt, &c_b20, &x[i__ * x_dim1 + 1], &c__1, &bb[
01465                             i__ * bb_dim1 + 2], &c__1, &x[(i__ + 1) * x_dim1 
01466                             + 1], ldx);
01467                 }
01468             }
01469 
01470 /*           store a(i,i1) in RA1 for use in next loop over K */
01471 
01472             ra1 = ab[i__ - i1 + 1 + i1 * ab_dim1];
01473         }
01474 
01475 /*        Generate and apply vectors of rotations to chase all the */
01476 /*        existing bulges KA positions up toward the top of the band */
01477 
01478         i__4 = *kb - 1;
01479         for (k = 1; k <= i__4; ++k) {
01480             if (update) {
01481 
01482 /*              Determine the rotations which would annihilate the bulge */
01483 /*              which has in theory just been created */
01484 
01485                 if (i__ + k - ka1 > 0 && i__ + k < m) {
01486 
01487 /*                 generate rotation to annihilate a(i,i+k-ka-1) */
01488 
01489                     dlartg_(&ab[ka1 - k + (i__ + k - *ka) * ab_dim1], &ra1, &
01490                             work[*n + i__ + k - *ka], &work[i__ + k - *ka], &
01491                             ra);
01492 
01493 /*                 create nonzero element a(i+k,i+k-ka-1) outside the */
01494 /*                 band and store it in WORK(m-kb+i+k) */
01495 
01496                     t = -bb[k + 1 + i__ * bb_dim1] * ra1;
01497                     work[m - *kb + i__ + k] = work[*n + i__ + k - *ka] * t - 
01498                             work[i__ + k - *ka] * ab[ka1 + (i__ + k - *ka) * 
01499                             ab_dim1];
01500                     ab[ka1 + (i__ + k - *ka) * ab_dim1] = work[i__ + k - *ka] 
01501                             * t + work[*n + i__ + k - *ka] * ab[ka1 + (i__ + 
01502                             k - *ka) * ab_dim1];
01503                     ra1 = ra;
01504                 }
01505             }
01506 /* Computing MAX */
01507             i__3 = 1, i__1 = k + i0 - m + 1;
01508             j2 = i__ + k + 1 - max(i__3,i__1) * ka1;
01509             nr = (j2 + *ka - 1) / ka1;
01510             j1 = j2 - (nr - 1) * ka1;
01511             if (update) {
01512 /* Computing MIN */
01513                 i__3 = j2, i__1 = i__ - (*ka << 1) + k - 1;
01514                 j2t = min(i__3,i__1);
01515             } else {
01516                 j2t = j2;
01517             }
01518             nrt = (j2t + *ka - 1) / ka1;
01519             i__3 = j2t;
01520             i__1 = ka1;
01521             for (j = j1; i__1 < 0 ? j >= i__3 : j <= i__3; j += i__1) {
01522 
01523 /*              create nonzero element a(j+ka,j-1) outside the band */
01524 /*              and store it in WORK(j) */
01525 
01526                 work[j] *= ab[ka1 + (j - 1) * ab_dim1];
01527                 ab[ka1 + (j - 1) * ab_dim1] = work[*n + j] * ab[ka1 + (j - 1) 
01528                         * ab_dim1];
01529 /* L800: */
01530             }
01531 
01532 /*           generate rotations in 1st set to annihilate elements which */
01533 /*           have been created outside the band */
01534 
01535             if (nrt > 0) {
01536                 dlargv_(&nrt, &ab[ka1 + j1 * ab_dim1], &inca, &work[j1], &ka1, 
01537                          &work[*n + j1], &ka1);
01538             }
01539             if (nr > 0) {
01540 
01541 /*              apply rotations in 1st set from the right */
01542 
01543                 i__1 = *ka - 1;
01544                 for (l = 1; l <= i__1; ++l) {
01545                     dlartv_(&nr, &ab[l + 1 + j1 * ab_dim1], &inca, &ab[l + 2 
01546                             + (j1 - 1) * ab_dim1], &inca, &work[*n + j1], &
01547                             work[j1], &ka1);
01548 /* L810: */
01549                 }
01550 
01551 /*              apply rotations in 1st set from both sides to diagonal */
01552 /*              blocks */
01553 
01554                 dlar2v_(&nr, &ab[j1 * ab_dim1 + 1], &ab[(j1 - 1) * ab_dim1 + 
01555                         1], &ab[(j1 - 1) * ab_dim1 + 2], &inca, &work[*n + j1]
01556 , &work[j1], &ka1);
01557 
01558             }
01559 
01560 /*           start applying rotations in 1st set from the left */
01561 
01562             i__1 = *kb - k + 1;
01563             for (l = *ka - 1; l >= i__1; --l) {
01564                 nrt = (j2 + l - 1) / ka1;
01565                 j1t = j2 - (nrt - 1) * ka1;
01566                 if (nrt > 0) {
01567                     dlartv_(&nrt, &ab[ka1 - l + 1 + (j1t - ka1 + l) * ab_dim1]
01568 , &inca, &ab[ka1 - l + (j1t - ka1 + l) * ab_dim1], 
01569                              &inca, &work[*n + j1t], &work[j1t], &ka1);
01570                 }
01571 /* L820: */
01572             }
01573 
01574             if (wantx) {
01575 
01576 /*              post-multiply X by product of rotations in 1st set */
01577 
01578                 i__1 = j2;
01579                 i__3 = ka1;
01580                 for (j = j1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
01581                     drot_(&nx, &x[j * x_dim1 + 1], &c__1, &x[(j - 1) * x_dim1 
01582                             + 1], &c__1, &work[*n + j], &work[j]);
01583 /* L830: */
01584                 }
01585             }
01586 /* L840: */
01587         }
01588 
01589         if (update) {
01590             if (i2 > 0 && kbt > 0) {
01591 
01592 /*              create nonzero element a(i+kbt,i+kbt-ka-1) outside the */
01593 /*              band and store it in WORK(m-kb+i+kbt) */
01594 
01595                 work[m - *kb + i__ + kbt] = -bb[kbt + 1 + i__ * bb_dim1] * 
01596                         ra1;
01597             }
01598         }
01599 
01600         for (k = *kb; k >= 1; --k) {
01601             if (update) {
01602 /* Computing MAX */
01603                 i__4 = 2, i__3 = k + i0 - m;
01604                 j2 = i__ + k + 1 - max(i__4,i__3) * ka1;
01605             } else {
01606 /* Computing MAX */
01607                 i__4 = 1, i__3 = k + i0 - m;
01608                 j2 = i__ + k + 1 - max(i__4,i__3) * ka1;
01609             }
01610 
01611 /*           finish applying rotations in 2nd set from the left */
01612 
01613             for (l = *kb - k; l >= 1; --l) {
01614                 nrt = (j2 + *ka + l - 1) / ka1;
01615                 j1t = j2 - (nrt - 1) * ka1;
01616                 if (nrt > 0) {
01617                     dlartv_(&nrt, &ab[ka1 - l + 1 + (j1t + l - 1) * ab_dim1], 
01618                             &inca, &ab[ka1 - l + (j1t + l - 1) * ab_dim1], &
01619                             inca, &work[*n + m - *kb + j1t + *ka], &work[m - *
01620                             kb + j1t + *ka], &ka1);
01621                 }
01622 /* L850: */
01623             }
01624             nr = (j2 + *ka - 1) / ka1;
01625             j1 = j2 - (nr - 1) * ka1;
01626             i__4 = j2;
01627             i__3 = ka1;
01628             for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) {
01629                 work[m - *kb + j] = work[m - *kb + j + *ka];
01630                 work[*n + m - *kb + j] = work[*n + m - *kb + j + *ka];
01631 /* L860: */
01632             }
01633             i__3 = j2;
01634             i__4 = ka1;
01635             for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
01636 
01637 /*              create nonzero element a(j+ka,j-1) outside the band */
01638 /*              and store it in WORK(m-kb+j) */
01639 
01640                 work[m - *kb + j] *= ab[ka1 + (j - 1) * ab_dim1];
01641                 ab[ka1 + (j - 1) * ab_dim1] = work[*n + m - *kb + j] * ab[ka1 
01642                         + (j - 1) * ab_dim1];
01643 /* L870: */
01644             }
01645             if (update) {
01646                 if (i__ + k > ka1 && k <= kbt) {
01647                     work[m - *kb + i__ + k - *ka] = work[m - *kb + i__ + k];
01648                 }
01649             }
01650 /* L880: */
01651         }
01652 
01653         for (k = *kb; k >= 1; --k) {
01654 /* Computing MAX */
01655             i__4 = 1, i__3 = k + i0 - m;
01656             j2 = i__ + k + 1 - max(i__4,i__3) * ka1;
01657             nr = (j2 + *ka - 1) / ka1;
01658             j1 = j2 - (nr - 1) * ka1;
01659             if (nr > 0) {
01660 
01661 /*              generate rotations in 2nd set to annihilate elements */
01662 /*              which have been created outside the band */
01663 
01664                 dlargv_(&nr, &ab[ka1 + j1 * ab_dim1], &inca, &work[m - *kb + 
01665                         j1], &ka1, &work[*n + m - *kb + j1], &ka1);
01666 
01667 /*              apply rotations in 2nd set from the right */
01668 
01669                 i__4 = *ka - 1;
01670                 for (l = 1; l <= i__4; ++l) {
01671                     dlartv_(&nr, &ab[l + 1 + j1 * ab_dim1], &inca, &ab[l + 2 
01672                             + (j1 - 1) * ab_dim1], &inca, &work[*n + m - *kb 
01673                             + j1], &work[m - *kb + j1], &ka1);
01674 /* L890: */
01675                 }
01676 
01677 /*              apply rotations in 2nd set from both sides to diagonal */
01678 /*              blocks */
01679 
01680                 dlar2v_(&nr, &ab[j1 * ab_dim1 + 1], &ab[(j1 - 1) * ab_dim1 + 
01681                         1], &ab[(j1 - 1) * ab_dim1 + 2], &inca, &work[*n + m 
01682                         - *kb + j1], &work[m - *kb + j1], &ka1);
01683 
01684             }
01685 
01686 /*           start applying rotations in 2nd set from the left */
01687 
01688             i__4 = *kb - k + 1;
01689             for (l = *ka - 1; l >= i__4; --l) {
01690                 nrt = (j2 + l - 1) / ka1;
01691                 j1t = j2 - (nrt - 1) * ka1;
01692                 if (nrt > 0) {
01693                     dlartv_(&nrt, &ab[ka1 - l + 1 + (j1t - ka1 + l) * ab_dim1]
01694 , &inca, &ab[ka1 - l + (j1t - ka1 + l) * ab_dim1], 
01695                              &inca, &work[*n + m - *kb + j1t], &work[m - *kb 
01696                             + j1t], &ka1);
01697                 }
01698 /* L900: */
01699             }
01700 
01701             if (wantx) {
01702 
01703 /*              post-multiply X by product of rotations in 2nd set */
01704 
01705                 i__4 = j2;
01706                 i__3 = ka1;
01707                 for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3) {
01708                     drot_(&nx, &x[j * x_dim1 + 1], &c__1, &x[(j - 1) * x_dim1 
01709                             + 1], &c__1, &work[*n + m - *kb + j], &work[m - *
01710                             kb + j]);
01711 /* L910: */
01712                 }
01713             }
01714 /* L920: */
01715         }
01716 
01717         i__3 = *kb - 1;
01718         for (k = 1; k <= i__3; ++k) {
01719 /* Computing MAX */
01720             i__4 = 1, i__1 = k + i0 - m + 1;
01721             j2 = i__ + k + 1 - max(i__4,i__1) * ka1;
01722 
01723 /*           finish applying rotations in 1st set from the left */
01724 
01725             for (l = *kb - k; l >= 1; --l) {
01726                 nrt = (j2 + l - 1) / ka1;
01727                 j1t = j2 - (nrt - 1) * ka1;
01728                 if (nrt > 0) {
01729                     dlartv_(&nrt, &ab[ka1 - l + 1 + (j1t - ka1 + l) * ab_dim1]
01730 , &inca, &ab[ka1 - l + (j1t - ka1 + l) * ab_dim1], 
01731                              &inca, &work[*n + j1t], &work[j1t], &ka1);
01732                 }
01733 /* L930: */
01734             }
01735 /* L940: */
01736         }
01737 
01738         if (*kb > 1) {
01739 /* Computing MIN */
01740             i__4 = i__ + *kb;
01741             i__3 = min(i__4,m) - (*ka << 1) - 1;
01742             for (j = 2; j <= i__3; ++j) {
01743                 work[*n + j] = work[*n + j + *ka];
01744                 work[j] = work[j + *ka];
01745 /* L950: */
01746             }
01747         }
01748 
01749     }
01750 
01751     goto L490;
01752 
01753 /*     End of DSBGST */
01754 
01755 } /* dsbgst_ */


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