00001 /* dlarrd.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 static integer c_n1 = -1; 00020 static integer c__3 = 3; 00021 static integer c__2 = 2; 00022 static integer c__0 = 0; 00023 00024 /* Subroutine */ int dlarrd_(char *range, char *order, integer *n, doublereal 00025 *vl, doublereal *vu, integer *il, integer *iu, doublereal *gers, 00026 doublereal *reltol, doublereal *d__, doublereal *e, doublereal *e2, 00027 doublereal *pivmin, integer *nsplit, integer *isplit, integer *m, 00028 doublereal *w, doublereal *werr, doublereal *wl, doublereal *wu, 00029 integer *iblock, integer *indexw, doublereal *work, integer *iwork, 00030 integer *info) 00031 { 00032 /* System generated locals */ 00033 integer i__1, i__2, i__3; 00034 doublereal d__1, d__2; 00035 00036 /* Builtin functions */ 00037 double log(doublereal); 00038 00039 /* Local variables */ 00040 integer i__, j, ib, ie, je, nb; 00041 doublereal gl; 00042 integer im, in; 00043 doublereal gu; 00044 integer iw, jee; 00045 doublereal eps; 00046 integer nwl; 00047 doublereal wlu, wul; 00048 integer nwu; 00049 doublereal tmp1, tmp2; 00050 integer iend, jblk, ioff, iout, itmp1, itmp2, jdisc; 00051 extern logical lsame_(char *, char *); 00052 integer iinfo; 00053 doublereal atoli; 00054 integer iwoff, itmax; 00055 doublereal wkill, rtoli, uflow, tnorm; 00056 extern doublereal dlamch_(char *); 00057 integer ibegin; 00058 extern /* Subroutine */ int dlaebz_(integer *, integer *, integer *, 00059 integer *, integer *, integer *, doublereal *, doublereal *, 00060 doublereal *, doublereal *, doublereal *, doublereal *, integer *, 00061 doublereal *, doublereal *, integer *, integer *, doublereal *, 00062 integer *, integer *); 00063 integer irange, idiscl, idumma[1]; 00064 extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 00065 integer *, integer *); 00066 integer idiscu; 00067 logical ncnvrg, toofew; 00068 00069 00070 /* -- LAPACK auxiliary routine (version 3.2.1) -- */ 00071 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ 00072 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ 00073 /* -- April 2009 -- */ 00074 00075 /* .. Scalar Arguments .. */ 00076 /* .. */ 00077 /* .. Array Arguments .. */ 00078 /* .. */ 00079 00080 /* Purpose */ 00081 /* ======= */ 00082 00083 /* DLARRD computes the eigenvalues of a symmetric tridiagonal */ 00084 /* matrix T to suitable accuracy. This is an auxiliary code to be */ 00085 /* called from DSTEMR. */ 00086 /* The user may ask for all eigenvalues, all eigenvalues */ 00087 /* in the half-open interval (VL, VU], or the IL-th through IU-th */ 00088 /* eigenvalues. */ 00089 00090 /* To avoid overflow, the matrix must be scaled so that its */ 00091 /* largest element is no greater than overflow**(1/2) * */ 00092 /* underflow**(1/4) in absolute value, and for greatest */ 00093 /* accuracy, it should not be much smaller than that. */ 00094 00095 /* See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal */ 00096 /* Matrix", Report CS41, Computer Science Dept., Stanford */ 00097 /* University, July 21, 1966. */ 00098 00099 /* Arguments */ 00100 /* ========= */ 00101 00102 /* RANGE (input) CHARACTER */ 00103 /* = 'A': ("All") all eigenvalues will be found. */ 00104 /* = 'V': ("Value") all eigenvalues in the half-open interval */ 00105 /* (VL, VU] will be found. */ 00106 /* = 'I': ("Index") the IL-th through IU-th eigenvalues (of the */ 00107 /* entire matrix) will be found. */ 00108 00109 /* ORDER (input) CHARACTER */ 00110 /* = 'B': ("By Block") the eigenvalues will be grouped by */ 00111 /* split-off block (see IBLOCK, ISPLIT) and */ 00112 /* ordered from smallest to largest within */ 00113 /* the block. */ 00114 /* = 'E': ("Entire matrix") */ 00115 /* the eigenvalues for the entire matrix */ 00116 /* will be ordered from smallest to */ 00117 /* largest. */ 00118 00119 /* N (input) INTEGER */ 00120 /* The order of the tridiagonal matrix T. N >= 0. */ 00121 00122 /* VL (input) DOUBLE PRECISION */ 00123 /* VU (input) DOUBLE PRECISION */ 00124 /* If RANGE='V', the lower and upper bounds of the interval to */ 00125 /* be searched for eigenvalues. Eigenvalues less than or equal */ 00126 /* to VL, or greater than VU, will not be returned. VL < VU. */ 00127 /* Not referenced if RANGE = 'A' or 'I'. */ 00128 00129 /* IL (input) INTEGER */ 00130 /* IU (input) INTEGER */ 00131 /* If RANGE='I', the indices (in ascending order) of the */ 00132 /* smallest and largest eigenvalues to be returned. */ 00133 /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ 00134 /* Not referenced if RANGE = 'A' or 'V'. */ 00135 00136 /* GERS (input) DOUBLE PRECISION array, dimension (2*N) */ 00137 /* The N Gerschgorin intervals (the i-th Gerschgorin interval */ 00138 /* is (GERS(2*i-1), GERS(2*i)). */ 00139 00140 /* RELTOL (input) DOUBLE PRECISION */ 00141 /* The minimum relative width of an interval. When an interval */ 00142 /* is narrower than RELTOL times the larger (in */ 00143 /* magnitude) endpoint, then it is considered to be */ 00144 /* sufficiently small, i.e., converged. Note: this should */ 00145 /* always be at least radix*machine epsilon. */ 00146 00147 /* D (input) DOUBLE PRECISION array, dimension (N) */ 00148 /* The n diagonal elements of the tridiagonal matrix T. */ 00149 00150 /* E (input) DOUBLE PRECISION array, dimension (N-1) */ 00151 /* The (n-1) off-diagonal elements of the tridiagonal matrix T. */ 00152 00153 /* E2 (input) DOUBLE PRECISION array, dimension (N-1) */ 00154 /* The (n-1) squared off-diagonal elements of the tridiagonal matrix T. */ 00155 00156 /* PIVMIN (input) DOUBLE PRECISION */ 00157 /* The minimum pivot allowed in the Sturm sequence for T. */ 00158 00159 /* NSPLIT (input) INTEGER */ 00160 /* The number of diagonal blocks in the matrix T. */ 00161 /* 1 <= NSPLIT <= N. */ 00162 00163 /* ISPLIT (input) INTEGER array, dimension (N) */ 00164 /* The splitting points, at which T breaks up into submatrices. */ 00165 /* The first submatrix consists of rows/columns 1 to ISPLIT(1), */ 00166 /* the second of rows/columns ISPLIT(1)+1 through ISPLIT(2), */ 00167 /* etc., and the NSPLIT-th consists of rows/columns */ 00168 /* ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N. */ 00169 /* (Only the first NSPLIT elements will actually be used, but */ 00170 /* since the user cannot know a priori what value NSPLIT will */ 00171 /* have, N words must be reserved for ISPLIT.) */ 00172 00173 /* M (output) INTEGER */ 00174 /* The actual number of eigenvalues found. 0 <= M <= N. */ 00175 /* (See also the description of INFO=2,3.) */ 00176 00177 /* W (output) DOUBLE PRECISION array, dimension (N) */ 00178 /* On exit, the first M elements of W will contain the */ 00179 /* eigenvalue approximations. DLARRD computes an interval */ 00180 /* I_j = (a_j, b_j] that includes eigenvalue j. The eigenvalue */ 00181 /* approximation is given as the interval midpoint */ 00182 /* W(j)= ( a_j + b_j)/2. The corresponding error is bounded by */ 00183 /* WERR(j) = abs( a_j - b_j)/2 */ 00184 00185 /* WERR (output) DOUBLE PRECISION array, dimension (N) */ 00186 /* The error bound on the corresponding eigenvalue approximation */ 00187 /* in W. */ 00188 00189 /* WL (output) DOUBLE PRECISION */ 00190 /* WU (output) DOUBLE PRECISION */ 00191 /* The interval (WL, WU] contains all the wanted eigenvalues. */ 00192 /* If RANGE='V', then WL=VL and WU=VU. */ 00193 /* If RANGE='A', then WL and WU are the global Gerschgorin bounds */ 00194 /* on the spectrum. */ 00195 /* If RANGE='I', then WL and WU are computed by DLAEBZ from the */ 00196 /* index range specified. */ 00197 00198 /* IBLOCK (output) INTEGER array, dimension (N) */ 00199 /* At each row/column j where E(j) is zero or small, the */ 00200 /* matrix T is considered to split into a block diagonal */ 00201 /* matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which */ 00202 /* block (from 1 to the number of blocks) the eigenvalue W(i) */ 00203 /* belongs. (DLARRD may use the remaining N-M elements as */ 00204 /* workspace.) */ 00205 00206 /* INDEXW (output) INTEGER array, dimension (N) */ 00207 /* The indices of the eigenvalues within each block (submatrix); */ 00208 /* for example, INDEXW(i)= j and IBLOCK(i)=k imply that the */ 00209 /* i-th eigenvalue W(i) is the j-th eigenvalue in block k. */ 00210 00211 /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */ 00212 00213 /* IWORK (workspace) INTEGER array, dimension (3*N) */ 00214 00215 /* INFO (output) INTEGER */ 00216 /* = 0: successful exit */ 00217 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00218 /* > 0: some or all of the eigenvalues failed to converge or */ 00219 /* were not computed: */ 00220 /* =1 or 3: Bisection failed to converge for some */ 00221 /* eigenvalues; these eigenvalues are flagged by a */ 00222 /* negative block number. The effect is that the */ 00223 /* eigenvalues may not be as accurate as the */ 00224 /* absolute and relative tolerances. This is */ 00225 /* generally caused by unexpectedly inaccurate */ 00226 /* arithmetic. */ 00227 /* =2 or 3: RANGE='I' only: Not all of the eigenvalues */ 00228 /* IL:IU were found. */ 00229 /* Effect: M < IU+1-IL */ 00230 /* Cause: non-monotonic arithmetic, causing the */ 00231 /* Sturm sequence to be non-monotonic. */ 00232 /* Cure: recalculate, using RANGE='A', and pick */ 00233 /* out eigenvalues IL:IU. In some cases, */ 00234 /* increasing the PARAMETER "FUDGE" may */ 00235 /* make things work. */ 00236 /* = 4: RANGE='I', and the Gershgorin interval */ 00237 /* initially used was too small. No eigenvalues */ 00238 /* were computed. */ 00239 /* Probable cause: your machine has sloppy */ 00240 /* floating-point arithmetic. */ 00241 /* Cure: Increase the PARAMETER "FUDGE", */ 00242 /* recompile, and try again. */ 00243 00244 /* Internal Parameters */ 00245 /* =================== */ 00246 00247 /* FUDGE DOUBLE PRECISION, default = 2 */ 00248 /* A "fudge factor" to widen the Gershgorin intervals. Ideally, */ 00249 /* a value of 1 should work, but on machines with sloppy */ 00250 /* arithmetic, this needs to be larger. The default for */ 00251 /* publicly released versions should be large enough to handle */ 00252 /* the worst machine around. Note that this has no effect */ 00253 /* on accuracy of the solution. */ 00254 00255 /* Based on contributions by */ 00256 /* W. Kahan, University of California, Berkeley, USA */ 00257 /* Beresford Parlett, University of California, Berkeley, USA */ 00258 /* Jim Demmel, University of California, Berkeley, USA */ 00259 /* Inderjit Dhillon, University of Texas, Austin, USA */ 00260 /* Osni Marques, LBNL/NERSC, USA */ 00261 /* Christof Voemel, University of California, Berkeley, USA */ 00262 00263 /* ===================================================================== */ 00264 00265 /* .. Parameters .. */ 00266 /* .. */ 00267 /* .. Local Scalars .. */ 00268 /* .. */ 00269 /* .. Local Arrays .. */ 00270 /* .. */ 00271 /* .. External Functions .. */ 00272 /* .. */ 00273 /* .. External Subroutines .. */ 00274 /* .. */ 00275 /* .. Intrinsic Functions .. */ 00276 /* .. */ 00277 /* .. Executable Statements .. */ 00278 00279 /* Parameter adjustments */ 00280 --iwork; 00281 --work; 00282 --indexw; 00283 --iblock; 00284 --werr; 00285 --w; 00286 --isplit; 00287 --e2; 00288 --e; 00289 --d__; 00290 --gers; 00291 00292 /* Function Body */ 00293 *info = 0; 00294 00295 /* Decode RANGE */ 00296 00297 if (lsame_(range, "A")) { 00298 irange = 1; 00299 } else if (lsame_(range, "V")) { 00300 irange = 2; 00301 } else if (lsame_(range, "I")) { 00302 irange = 3; 00303 } else { 00304 irange = 0; 00305 } 00306 00307 /* Check for Errors */ 00308 00309 if (irange <= 0) { 00310 *info = -1; 00311 } else if (! (lsame_(order, "B") || lsame_(order, 00312 "E"))) { 00313 *info = -2; 00314 } else if (*n < 0) { 00315 *info = -3; 00316 } else if (irange == 2) { 00317 if (*vl >= *vu) { 00318 *info = -5; 00319 } 00320 } else if (irange == 3 && (*il < 1 || *il > max(1,*n))) { 00321 *info = -6; 00322 } else if (irange == 3 && (*iu < min(*n,*il) || *iu > *n)) { 00323 *info = -7; 00324 } 00325 00326 if (*info != 0) { 00327 return 0; 00328 } 00329 /* Initialize error flags */ 00330 *info = 0; 00331 ncnvrg = FALSE_; 00332 toofew = FALSE_; 00333 /* Quick return if possible */ 00334 *m = 0; 00335 if (*n == 0) { 00336 return 0; 00337 } 00338 /* Simplification: */ 00339 if (irange == 3 && *il == 1 && *iu == *n) { 00340 irange = 1; 00341 } 00342 /* Get machine constants */ 00343 eps = dlamch_("P"); 00344 uflow = dlamch_("U"); 00345 /* Special Case when N=1 */ 00346 /* Treat case of 1x1 matrix for quick return */ 00347 if (*n == 1) { 00348 if (irange == 1 || irange == 2 && d__[1] > *vl && d__[1] <= *vu || 00349 irange == 3 && *il == 1 && *iu == 1) { 00350 *m = 1; 00351 w[1] = d__[1]; 00352 /* The computation error of the eigenvalue is zero */ 00353 werr[1] = 0.; 00354 iblock[1] = 1; 00355 indexw[1] = 1; 00356 } 00357 return 0; 00358 } 00359 /* NB is the minimum vector length for vector bisection, or 0 */ 00360 /* if only scalar is to be done. */ 00361 nb = ilaenv_(&c__1, "DSTEBZ", " ", n, &c_n1, &c_n1, &c_n1); 00362 if (nb <= 1) { 00363 nb = 0; 00364 } 00365 /* Find global spectral radius */ 00366 gl = d__[1]; 00367 gu = d__[1]; 00368 i__1 = *n; 00369 for (i__ = 1; i__ <= i__1; ++i__) { 00370 /* Computing MIN */ 00371 d__1 = gl, d__2 = gers[(i__ << 1) - 1]; 00372 gl = min(d__1,d__2); 00373 /* Computing MAX */ 00374 d__1 = gu, d__2 = gers[i__ * 2]; 00375 gu = max(d__1,d__2); 00376 /* L5: */ 00377 } 00378 /* Compute global Gerschgorin bounds and spectral diameter */ 00379 /* Computing MAX */ 00380 d__1 = abs(gl), d__2 = abs(gu); 00381 tnorm = max(d__1,d__2); 00382 gl = gl - tnorm * 2. * eps * *n - *pivmin * 4.; 00383 gu = gu + tnorm * 2. * eps * *n + *pivmin * 4.; 00384 /* [JAN/28/2009] remove the line below since SPDIAM variable not use */ 00385 /* SPDIAM = GU - GL */ 00386 /* Input arguments for DLAEBZ: */ 00387 /* The relative tolerance. An interval (a,b] lies within */ 00388 /* "relative tolerance" if b-a < RELTOL*max(|a|,|b|), */ 00389 rtoli = *reltol; 00390 /* Set the absolute tolerance for interval convergence to zero to force */ 00391 /* interval convergence based on relative size of the interval. */ 00392 /* This is dangerous because intervals might not converge when RELTOL is */ 00393 /* small. But at least a very small number should be selected so that for */ 00394 /* strongly graded matrices, the code can get relatively accurate */ 00395 /* eigenvalues. */ 00396 atoli = uflow * 4. + *pivmin * 4.; 00397 if (irange == 3) { 00398 /* RANGE='I': Compute an interval containing eigenvalues */ 00399 /* IL through IU. The initial interval [GL,GU] from the global */ 00400 /* Gerschgorin bounds GL and GU is refined by DLAEBZ. */ 00401 itmax = (integer) ((log(tnorm + *pivmin) - log(*pivmin)) / log(2.)) + 00402 2; 00403 work[*n + 1] = gl; 00404 work[*n + 2] = gl; 00405 work[*n + 3] = gu; 00406 work[*n + 4] = gu; 00407 work[*n + 5] = gl; 00408 work[*n + 6] = gu; 00409 iwork[1] = -1; 00410 iwork[2] = -1; 00411 iwork[3] = *n + 1; 00412 iwork[4] = *n + 1; 00413 iwork[5] = *il - 1; 00414 iwork[6] = *iu; 00415 00416 dlaebz_(&c__3, &itmax, n, &c__2, &c__2, &nb, &atoli, &rtoli, pivmin, & 00417 d__[1], &e[1], &e2[1], &iwork[5], &work[*n + 1], &work[*n + 5] 00418 , &iout, &iwork[1], &w[1], &iblock[1], &iinfo); 00419 if (iinfo != 0) { 00420 *info = iinfo; 00421 return 0; 00422 } 00423 /* On exit, output intervals may not be ordered by ascending negcount */ 00424 if (iwork[6] == *iu) { 00425 *wl = work[*n + 1]; 00426 wlu = work[*n + 3]; 00427 nwl = iwork[1]; 00428 *wu = work[*n + 4]; 00429 wul = work[*n + 2]; 00430 nwu = iwork[4]; 00431 } else { 00432 *wl = work[*n + 2]; 00433 wlu = work[*n + 4]; 00434 nwl = iwork[2]; 00435 *wu = work[*n + 3]; 00436 wul = work[*n + 1]; 00437 nwu = iwork[3]; 00438 } 00439 /* On exit, the interval [WL, WLU] contains a value with negcount NWL, */ 00440 /* and [WUL, WU] contains a value with negcount NWU. */ 00441 if (nwl < 0 || nwl >= *n || nwu < 1 || nwu > *n) { 00442 *info = 4; 00443 return 0; 00444 } 00445 } else if (irange == 2) { 00446 *wl = *vl; 00447 *wu = *vu; 00448 } else if (irange == 1) { 00449 *wl = gl; 00450 *wu = gu; 00451 } 00452 /* Find Eigenvalues -- Loop Over blocks and recompute NWL and NWU. */ 00453 /* NWL accumulates the number of eigenvalues .le. WL, */ 00454 /* NWU accumulates the number of eigenvalues .le. WU */ 00455 *m = 0; 00456 iend = 0; 00457 *info = 0; 00458 nwl = 0; 00459 nwu = 0; 00460 00461 i__1 = *nsplit; 00462 for (jblk = 1; jblk <= i__1; ++jblk) { 00463 ioff = iend; 00464 ibegin = ioff + 1; 00465 iend = isplit[jblk]; 00466 in = iend - ioff; 00467 00468 if (in == 1) { 00469 /* 1x1 block */ 00470 if (*wl >= d__[ibegin] - *pivmin) { 00471 ++nwl; 00472 } 00473 if (*wu >= d__[ibegin] - *pivmin) { 00474 ++nwu; 00475 } 00476 if (irange == 1 || *wl < d__[ibegin] - *pivmin && *wu >= d__[ 00477 ibegin] - *pivmin) { 00478 ++(*m); 00479 w[*m] = d__[ibegin]; 00480 werr[*m] = 0.; 00481 /* The gap for a single block doesn't matter for the later */ 00482 /* algorithm and is assigned an arbitrary large value */ 00483 iblock[*m] = jblk; 00484 indexw[*m] = 1; 00485 } 00486 /* Disabled 2x2 case because of a failure on the following matrix */ 00487 /* RANGE = 'I', IL = IU = 4 */ 00488 /* Original Tridiagonal, d = [ */ 00489 /* -0.150102010615740E+00 */ 00490 /* -0.849897989384260E+00 */ 00491 /* -0.128208148052635E-15 */ 00492 /* 0.128257718286320E-15 */ 00493 /* ]; */ 00494 /* e = [ */ 00495 /* -0.357171383266986E+00 */ 00496 /* -0.180411241501588E-15 */ 00497 /* -0.175152352710251E-15 */ 00498 /* ]; */ 00499 00500 /* ELSE IF( IN.EQ.2 ) THEN */ 00501 /* * 2x2 block */ 00502 /* DISC = SQRT( (HALF*(D(IBEGIN)-D(IEND)))**2 + E(IBEGIN)**2 ) */ 00503 /* TMP1 = HALF*(D(IBEGIN)+D(IEND)) */ 00504 /* L1 = TMP1 - DISC */ 00505 /* IF( WL.GE. L1-PIVMIN ) */ 00506 /* $ NWL = NWL + 1 */ 00507 /* IF( WU.GE. L1-PIVMIN ) */ 00508 /* $ NWU = NWU + 1 */ 00509 /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L1-PIVMIN .AND. WU.GE. */ 00510 /* $ L1-PIVMIN ) ) THEN */ 00511 /* M = M + 1 */ 00512 /* W( M ) = L1 */ 00513 /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */ 00514 /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */ 00515 /* IBLOCK( M ) = JBLK */ 00516 /* INDEXW( M ) = 1 */ 00517 /* ENDIF */ 00518 /* L2 = TMP1 + DISC */ 00519 /* IF( WL.GE. L2-PIVMIN ) */ 00520 /* $ NWL = NWL + 1 */ 00521 /* IF( WU.GE. L2-PIVMIN ) */ 00522 /* $ NWU = NWU + 1 */ 00523 /* IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L2-PIVMIN .AND. WU.GE. */ 00524 /* $ L2-PIVMIN ) ) THEN */ 00525 /* M = M + 1 */ 00526 /* W( M ) = L2 */ 00527 /* * The uncertainty of eigenvalues of a 2x2 matrix is very small */ 00528 /* WERR( M ) = EPS * ABS( W( M ) ) * TWO */ 00529 /* IBLOCK( M ) = JBLK */ 00530 /* INDEXW( M ) = 2 */ 00531 /* ENDIF */ 00532 } else { 00533 /* General Case - block of size IN >= 2 */ 00534 /* Compute local Gerschgorin interval and use it as the initial */ 00535 /* interval for DLAEBZ */ 00536 gu = d__[ibegin]; 00537 gl = d__[ibegin]; 00538 tmp1 = 0.; 00539 i__2 = iend; 00540 for (j = ibegin; j <= i__2; ++j) { 00541 /* Computing MIN */ 00542 d__1 = gl, d__2 = gers[(j << 1) - 1]; 00543 gl = min(d__1,d__2); 00544 /* Computing MAX */ 00545 d__1 = gu, d__2 = gers[j * 2]; 00546 gu = max(d__1,d__2); 00547 /* L40: */ 00548 } 00549 /* [JAN/28/2009] */ 00550 /* change SPDIAM by TNORM in lines 2 and 3 thereafter */ 00551 /* line 1: remove computation of SPDIAM (not useful anymore) */ 00552 /* SPDIAM = GU - GL */ 00553 /* GL = GL - FUDGE*SPDIAM*EPS*IN - FUDGE*PIVMIN */ 00554 /* GU = GU + FUDGE*SPDIAM*EPS*IN + FUDGE*PIVMIN */ 00555 gl = gl - tnorm * 2. * eps * in - *pivmin * 2.; 00556 gu = gu + tnorm * 2. * eps * in + *pivmin * 2.; 00557 00558 if (irange > 1) { 00559 if (gu < *wl) { 00560 /* the local block contains none of the wanted eigenvalues */ 00561 nwl += in; 00562 nwu += in; 00563 goto L70; 00564 } 00565 /* refine search interval if possible, only range (WL,WU] matters */ 00566 gl = max(gl,*wl); 00567 gu = min(gu,*wu); 00568 if (gl >= gu) { 00569 goto L70; 00570 } 00571 } 00572 /* Find negcount of initial interval boundaries GL and GU */ 00573 work[*n + 1] = gl; 00574 work[*n + in + 1] = gu; 00575 dlaebz_(&c__1, &c__0, &in, &in, &c__1, &nb, &atoli, &rtoli, 00576 pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, & 00577 work[*n + 1], &work[*n + (in << 1) + 1], &im, &iwork[1], & 00578 w[*m + 1], &iblock[*m + 1], &iinfo); 00579 if (iinfo != 0) { 00580 *info = iinfo; 00581 return 0; 00582 } 00583 00584 nwl += iwork[1]; 00585 nwu += iwork[in + 1]; 00586 iwoff = *m - iwork[1]; 00587 /* Compute Eigenvalues */ 00588 itmax = (integer) ((log(gu - gl + *pivmin) - log(*pivmin)) / log( 00589 2.)) + 2; 00590 dlaebz_(&c__2, &itmax, &in, &in, &c__1, &nb, &atoli, &rtoli, 00591 pivmin, &d__[ibegin], &e[ibegin], &e2[ibegin], idumma, & 00592 work[*n + 1], &work[*n + (in << 1) + 1], &iout, &iwork[1], 00593 &w[*m + 1], &iblock[*m + 1], &iinfo); 00594 if (iinfo != 0) { 00595 *info = iinfo; 00596 return 0; 00597 } 00598 00599 /* Copy eigenvalues into W and IBLOCK */ 00600 /* Use -JBLK for block number for unconverged eigenvalues. */ 00601 /* Loop over the number of output intervals from DLAEBZ */ 00602 i__2 = iout; 00603 for (j = 1; j <= i__2; ++j) { 00604 /* eigenvalue approximation is middle point of interval */ 00605 tmp1 = (work[j + *n] + work[j + in + *n]) * .5; 00606 /* semi length of error interval */ 00607 tmp2 = (d__1 = work[j + *n] - work[j + in + *n], abs(d__1)) * 00608 .5; 00609 if (j > iout - iinfo) { 00610 /* Flag non-convergence. */ 00611 ncnvrg = TRUE_; 00612 ib = -jblk; 00613 } else { 00614 ib = jblk; 00615 } 00616 i__3 = iwork[j + in] + iwoff; 00617 for (je = iwork[j] + 1 + iwoff; je <= i__3; ++je) { 00618 w[je] = tmp1; 00619 werr[je] = tmp2; 00620 indexw[je] = je - iwoff; 00621 iblock[je] = ib; 00622 /* L50: */ 00623 } 00624 /* L60: */ 00625 } 00626 00627 *m += im; 00628 } 00629 L70: 00630 ; 00631 } 00632 /* If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU */ 00633 /* If NWL+1 < IL or NWU > IU, discard extra eigenvalues. */ 00634 if (irange == 3) { 00635 idiscl = *il - 1 - nwl; 00636 idiscu = nwu - *iu; 00637 00638 if (idiscl > 0) { 00639 im = 0; 00640 i__1 = *m; 00641 for (je = 1; je <= i__1; ++je) { 00642 /* Remove some of the smallest eigenvalues from the left so that */ 00643 /* at the end IDISCL =0. Move all eigenvalues up to the left. */ 00644 if (w[je] <= wlu && idiscl > 0) { 00645 --idiscl; 00646 } else { 00647 ++im; 00648 w[im] = w[je]; 00649 werr[im] = werr[je]; 00650 indexw[im] = indexw[je]; 00651 iblock[im] = iblock[je]; 00652 } 00653 /* L80: */ 00654 } 00655 *m = im; 00656 } 00657 if (idiscu > 0) { 00658 /* Remove some of the largest eigenvalues from the right so that */ 00659 /* at the end IDISCU =0. Move all eigenvalues up to the left. */ 00660 im = *m + 1; 00661 for (je = *m; je >= 1; --je) { 00662 if (w[je] >= wul && idiscu > 0) { 00663 --idiscu; 00664 } else { 00665 --im; 00666 w[im] = w[je]; 00667 werr[im] = werr[je]; 00668 indexw[im] = indexw[je]; 00669 iblock[im] = iblock[je]; 00670 } 00671 /* L81: */ 00672 } 00673 jee = 0; 00674 i__1 = *m; 00675 for (je = im; je <= i__1; ++je) { 00676 ++jee; 00677 w[jee] = w[je]; 00678 werr[jee] = werr[je]; 00679 indexw[jee] = indexw[je]; 00680 iblock[jee] = iblock[je]; 00681 /* L82: */ 00682 } 00683 *m = *m - im + 1; 00684 } 00685 if (idiscl > 0 || idiscu > 0) { 00686 /* Code to deal with effects of bad arithmetic. (If N(w) is */ 00687 /* monotone non-decreasing, this should never happen.) */ 00688 /* Some low eigenvalues to be discarded are not in (WL,WLU], */ 00689 /* or high eigenvalues to be discarded are not in (WUL,WU] */ 00690 /* so just kill off the smallest IDISCL/largest IDISCU */ 00691 /* eigenvalues, by marking the corresponding IBLOCK = 0 */ 00692 if (idiscl > 0) { 00693 wkill = *wu; 00694 i__1 = idiscl; 00695 for (jdisc = 1; jdisc <= i__1; ++jdisc) { 00696 iw = 0; 00697 i__2 = *m; 00698 for (je = 1; je <= i__2; ++je) { 00699 if (iblock[je] != 0 && (w[je] < wkill || iw == 0)) { 00700 iw = je; 00701 wkill = w[je]; 00702 } 00703 /* L90: */ 00704 } 00705 iblock[iw] = 0; 00706 /* L100: */ 00707 } 00708 } 00709 if (idiscu > 0) { 00710 wkill = *wl; 00711 i__1 = idiscu; 00712 for (jdisc = 1; jdisc <= i__1; ++jdisc) { 00713 iw = 0; 00714 i__2 = *m; 00715 for (je = 1; je <= i__2; ++je) { 00716 if (iblock[je] != 0 && (w[je] >= wkill || iw == 0)) { 00717 iw = je; 00718 wkill = w[je]; 00719 } 00720 /* L110: */ 00721 } 00722 iblock[iw] = 0; 00723 /* L120: */ 00724 } 00725 } 00726 /* Now erase all eigenvalues with IBLOCK set to zero */ 00727 im = 0; 00728 i__1 = *m; 00729 for (je = 1; je <= i__1; ++je) { 00730 if (iblock[je] != 0) { 00731 ++im; 00732 w[im] = w[je]; 00733 werr[im] = werr[je]; 00734 indexw[im] = indexw[je]; 00735 iblock[im] = iblock[je]; 00736 } 00737 /* L130: */ 00738 } 00739 *m = im; 00740 } 00741 if (idiscl < 0 || idiscu < 0) { 00742 toofew = TRUE_; 00743 } 00744 } 00745 00746 if (irange == 1 && *m != *n || irange == 3 && *m != *iu - *il + 1) { 00747 toofew = TRUE_; 00748 } 00749 /* If ORDER='B', do nothing the eigenvalues are already sorted by */ 00750 /* block. */ 00751 /* If ORDER='E', sort the eigenvalues from smallest to largest */ 00752 if (lsame_(order, "E") && *nsplit > 1) { 00753 i__1 = *m - 1; 00754 for (je = 1; je <= i__1; ++je) { 00755 ie = 0; 00756 tmp1 = w[je]; 00757 i__2 = *m; 00758 for (j = je + 1; j <= i__2; ++j) { 00759 if (w[j] < tmp1) { 00760 ie = j; 00761 tmp1 = w[j]; 00762 } 00763 /* L140: */ 00764 } 00765 if (ie != 0) { 00766 tmp2 = werr[ie]; 00767 itmp1 = iblock[ie]; 00768 itmp2 = indexw[ie]; 00769 w[ie] = w[je]; 00770 werr[ie] = werr[je]; 00771 iblock[ie] = iblock[je]; 00772 indexw[ie] = indexw[je]; 00773 w[je] = tmp1; 00774 werr[je] = tmp2; 00775 iblock[je] = itmp1; 00776 indexw[je] = itmp2; 00777 } 00778 /* L150: */ 00779 } 00780 } 00781 00782 *info = 0; 00783 if (ncnvrg) { 00784 ++(*info); 00785 } 00786 if (toofew) { 00787 *info += 2; 00788 } 00789 return 0; 00790 00791 /* End of DLARRD */ 00792 00793 } /* dlarrd_ */