You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sstebz.f 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. *> \brief \b SSTEBZ
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SSTEBZ + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstebz.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstebz.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstebz.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E,
  22. * M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK,
  23. * INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER ORDER, RANGE
  27. * INTEGER IL, INFO, IU, M, N, NSPLIT
  28. * REAL ABSTOL, VL, VU
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * )
  32. * REAL D( * ), E( * ), W( * ), WORK( * )
  33. * ..
  34. *
  35. *
  36. *> \par Purpose:
  37. * =============
  38. *>
  39. *> \verbatim
  40. *>
  41. *> SSTEBZ computes the eigenvalues of a symmetric tridiagonal
  42. *> matrix T. The user may ask for all eigenvalues, all eigenvalues
  43. *> in the half-open interval (VL, VU], or the IL-th through IU-th
  44. *> eigenvalues.
  45. *>
  46. *> To avoid overflow, the matrix must be scaled so that its
  47. *> largest element is no greater than overflow**(1/2) * underflow**(1/4) in absolute value, and for greatest
  48. *> accuracy, it should not be much smaller than that.
  49. *>
  50. *> See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal
  51. *> Matrix", Report CS41, Computer Science Dept., Stanford
  52. *> University, July 21, 1966.
  53. *> \endverbatim
  54. *
  55. * Arguments:
  56. * ==========
  57. *
  58. *> \param[in] RANGE
  59. *> \verbatim
  60. *> RANGE is CHARACTER*1
  61. *> = 'A': ("All") all eigenvalues will be found.
  62. *> = 'V': ("Value") all eigenvalues in the half-open interval
  63. *> (VL, VU] will be found.
  64. *> = 'I': ("Index") the IL-th through IU-th eigenvalues (of the
  65. *> entire matrix) will be found.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] ORDER
  69. *> \verbatim
  70. *> ORDER is CHARACTER*1
  71. *> = 'B': ("By Block") the eigenvalues will be grouped by
  72. *> split-off block (see IBLOCK, ISPLIT) and
  73. *> ordered from smallest to largest within
  74. *> the block.
  75. *> = 'E': ("Entire matrix")
  76. *> the eigenvalues for the entire matrix
  77. *> will be ordered from smallest to
  78. *> largest.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] N
  82. *> \verbatim
  83. *> N is INTEGER
  84. *> The order of the tridiagonal matrix T. N >= 0.
  85. *> \endverbatim
  86. *>
  87. *> \param[in] VL
  88. *> \verbatim
  89. *> VL is REAL
  90. *> \endverbatim
  91. *>
  92. *> \param[in] VU
  93. *> \verbatim
  94. *> VU is REAL
  95. *>
  96. *> If RANGE='V', the lower and upper bounds of the interval to
  97. *> be searched for eigenvalues. Eigenvalues less than or equal
  98. *> to VL, or greater than VU, will not be returned. VL < VU.
  99. *> Not referenced if RANGE = 'A' or 'I'.
  100. *> \endverbatim
  101. *>
  102. *> \param[in] IL
  103. *> \verbatim
  104. *> IL is INTEGER
  105. *> \endverbatim
  106. *>
  107. *> \param[in] IU
  108. *> \verbatim
  109. *> IU is INTEGER
  110. *>
  111. *> If RANGE='I', the indices (in ascending order) of the
  112. *> smallest and largest eigenvalues to be returned.
  113. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  114. *> Not referenced if RANGE = 'A' or 'V'.
  115. *> \endverbatim
  116. *>
  117. *> \param[in] ABSTOL
  118. *> \verbatim
  119. *> ABSTOL is REAL
  120. *> The absolute tolerance for the eigenvalues. An eigenvalue
  121. *> (or cluster) is considered to be located if it has been
  122. *> determined to lie in an interval whose width is ABSTOL or
  123. *> less. If ABSTOL is less than or equal to zero, then ULP*|T|
  124. *> will be used, where |T| means the 1-norm of T.
  125. *>
  126. *> Eigenvalues will be computed most accurately when ABSTOL is
  127. *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
  128. *> \endverbatim
  129. *>
  130. *> \param[in] D
  131. *> \verbatim
  132. *> D is REAL array, dimension (N)
  133. *> The n diagonal elements of the tridiagonal matrix T.
  134. *> \endverbatim
  135. *>
  136. *> \param[in] E
  137. *> \verbatim
  138. *> E is REAL array, dimension (N-1)
  139. *> The (n-1) off-diagonal elements of the tridiagonal matrix T.
  140. *> \endverbatim
  141. *>
  142. *> \param[out] M
  143. *> \verbatim
  144. *> M is INTEGER
  145. *> The actual number of eigenvalues found. 0 <= M <= N.
  146. *> (See also the description of INFO=2,3.)
  147. *> \endverbatim
  148. *>
  149. *> \param[out] NSPLIT
  150. *> \verbatim
  151. *> NSPLIT is INTEGER
  152. *> The number of diagonal blocks in the matrix T.
  153. *> 1 <= NSPLIT <= N.
  154. *> \endverbatim
  155. *>
  156. *> \param[out] W
  157. *> \verbatim
  158. *> W is REAL array, dimension (N)
  159. *> On exit, the first M elements of W will contain the
  160. *> eigenvalues. (SSTEBZ may use the remaining N-M elements as
  161. *> workspace.)
  162. *> \endverbatim
  163. *>
  164. *> \param[out] IBLOCK
  165. *> \verbatim
  166. *> IBLOCK is INTEGER array, dimension (N)
  167. *> At each row/column j where E(j) is zero or small, the
  168. *> matrix T is considered to split into a block diagonal
  169. *> matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which
  170. *> block (from 1 to the number of blocks) the eigenvalue W(i)
  171. *> belongs. (SSTEBZ may use the remaining N-M elements as
  172. *> workspace.)
  173. *> \endverbatim
  174. *>
  175. *> \param[out] ISPLIT
  176. *> \verbatim
  177. *> ISPLIT is INTEGER array, dimension (N)
  178. *> The splitting points, at which T breaks up into submatrices.
  179. *> The first submatrix consists of rows/columns 1 to ISPLIT(1),
  180. *> the second of rows/columns ISPLIT(1)+1 through ISPLIT(2),
  181. *> etc., and the NSPLIT-th consists of rows/columns
  182. *> ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N.
  183. *> (Only the first NSPLIT elements will actually be used, but
  184. *> since the user cannot know a priori what value NSPLIT will
  185. *> have, N words must be reserved for ISPLIT.)
  186. *> \endverbatim
  187. *>
  188. *> \param[out] WORK
  189. *> \verbatim
  190. *> WORK is REAL array, dimension (4*N)
  191. *> \endverbatim
  192. *>
  193. *> \param[out] IWORK
  194. *> \verbatim
  195. *> IWORK is INTEGER array, dimension (3*N)
  196. *> \endverbatim
  197. *>
  198. *> \param[out] INFO
  199. *> \verbatim
  200. *> INFO is INTEGER
  201. *> = 0: successful exit
  202. *> < 0: if INFO = -i, the i-th argument had an illegal value
  203. *> > 0: some or all of the eigenvalues failed to converge or
  204. *> were not computed:
  205. *> =1 or 3: Bisection failed to converge for some
  206. *> eigenvalues; these eigenvalues are flagged by a
  207. *> negative block number. The effect is that the
  208. *> eigenvalues may not be as accurate as the
  209. *> absolute and relative tolerances. This is
  210. *> generally caused by unexpectedly inaccurate
  211. *> arithmetic.
  212. *> =2 or 3: RANGE='I' only: Not all of the eigenvalues
  213. *> IL:IU were found.
  214. *> Effect: M < IU+1-IL
  215. *> Cause: non-monotonic arithmetic, causing the
  216. *> Sturm sequence to be non-monotonic.
  217. *> Cure: recalculate, using RANGE='A', and pick
  218. *> out eigenvalues IL:IU. In some cases,
  219. *> increasing the PARAMETER "FUDGE" may
  220. *> make things work.
  221. *> = 4: RANGE='I', and the Gershgorin interval
  222. *> initially used was too small. No eigenvalues
  223. *> were computed.
  224. *> Probable cause: your machine has sloppy
  225. *> floating-point arithmetic.
  226. *> Cure: Increase the PARAMETER "FUDGE",
  227. *> recompile, and try again.
  228. *> \endverbatim
  229. *
  230. *> \par Internal Parameters:
  231. * =========================
  232. *>
  233. *> \verbatim
  234. *> RELFAC REAL, default = 2.0e0
  235. *> The relative tolerance. An interval (a,b] lies within
  236. *> "relative tolerance" if b-a < RELFAC*ulp*max(|a|,|b|),
  237. *> where "ulp" is the machine precision (distance from 1 to
  238. *> the next larger floating point number.)
  239. *>
  240. *> FUDGE REAL, default = 2
  241. *> A "fudge factor" to widen the Gershgorin intervals. Ideally,
  242. *> a value of 1 should work, but on machines with sloppy
  243. *> arithmetic, this needs to be larger. The default for
  244. *> publicly released versions should be large enough to handle
  245. *> the worst machine around. Note that this has no effect
  246. *> on accuracy of the solution.
  247. *> \endverbatim
  248. *
  249. * Authors:
  250. * ========
  251. *
  252. *> \author Univ. of Tennessee
  253. *> \author Univ. of California Berkeley
  254. *> \author Univ. of Colorado Denver
  255. *> \author NAG Ltd.
  256. *
  257. *> \date November 2011
  258. *
  259. *> \ingroup auxOTHERcomputational
  260. *
  261. * =====================================================================
  262. SUBROUTINE SSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL, D, E,
  263. $ M, NSPLIT, W, IBLOCK, ISPLIT, WORK, IWORK,
  264. $ INFO )
  265. *
  266. * -- LAPACK computational routine (version 3.4.0) --
  267. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  268. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  269. * November 2011
  270. *
  271. * .. Scalar Arguments ..
  272. CHARACTER ORDER, RANGE
  273. INTEGER IL, INFO, IU, M, N, NSPLIT
  274. REAL ABSTOL, VL, VU
  275. * ..
  276. * .. Array Arguments ..
  277. INTEGER IBLOCK( * ), ISPLIT( * ), IWORK( * )
  278. REAL D( * ), E( * ), W( * ), WORK( * )
  279. * ..
  280. *
  281. * =====================================================================
  282. *
  283. * .. Parameters ..
  284. REAL ZERO, ONE, TWO, HALF
  285. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0,
  286. $ HALF = 1.0E0 / TWO )
  287. REAL FUDGE, RELFAC
  288. PARAMETER ( FUDGE = 2.1E0, RELFAC = 2.0E0 )
  289. * ..
  290. * .. Local Scalars ..
  291. LOGICAL NCNVRG, TOOFEW
  292. INTEGER IB, IBEGIN, IDISCL, IDISCU, IE, IEND, IINFO,
  293. $ IM, IN, IOFF, IORDER, IOUT, IRANGE, ITMAX,
  294. $ ITMP1, IW, IWOFF, J, JB, JDISC, JE, NB, NWL,
  295. $ NWU
  296. REAL ATOLI, BNORM, GL, GU, PIVMIN, RTOLI, SAFEMN,
  297. $ TMP1, TMP2, TNORM, ULP, WKILL, WL, WLU, WU, WUL
  298. * ..
  299. * .. Local Arrays ..
  300. INTEGER IDUMMA( 1 )
  301. * ..
  302. * .. External Functions ..
  303. LOGICAL LSAME
  304. INTEGER ILAENV
  305. REAL SLAMCH
  306. EXTERNAL LSAME, ILAENV, SLAMCH
  307. * ..
  308. * .. External Subroutines ..
  309. EXTERNAL SLAEBZ, XERBLA
  310. * ..
  311. * .. Intrinsic Functions ..
  312. INTRINSIC ABS, INT, LOG, MAX, MIN, SQRT
  313. * ..
  314. * .. Executable Statements ..
  315. *
  316. INFO = 0
  317. *
  318. * Decode RANGE
  319. *
  320. IF( LSAME( RANGE, 'A' ) ) THEN
  321. IRANGE = 1
  322. ELSE IF( LSAME( RANGE, 'V' ) ) THEN
  323. IRANGE = 2
  324. ELSE IF( LSAME( RANGE, 'I' ) ) THEN
  325. IRANGE = 3
  326. ELSE
  327. IRANGE = 0
  328. END IF
  329. *
  330. * Decode ORDER
  331. *
  332. IF( LSAME( ORDER, 'B' ) ) THEN
  333. IORDER = 2
  334. ELSE IF( LSAME( ORDER, 'E' ) ) THEN
  335. IORDER = 1
  336. ELSE
  337. IORDER = 0
  338. END IF
  339. *
  340. * Check for Errors
  341. *
  342. IF( IRANGE.LE.0 ) THEN
  343. INFO = -1
  344. ELSE IF( IORDER.LE.0 ) THEN
  345. INFO = -2
  346. ELSE IF( N.LT.0 ) THEN
  347. INFO = -3
  348. ELSE IF( IRANGE.EQ.2 ) THEN
  349. IF( VL.GE.VU ) INFO = -5
  350. ELSE IF( IRANGE.EQ.3 .AND. ( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) )
  351. $ THEN
  352. INFO = -6
  353. ELSE IF( IRANGE.EQ.3 .AND. ( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) )
  354. $ THEN
  355. INFO = -7
  356. END IF
  357. *
  358. IF( INFO.NE.0 ) THEN
  359. CALL XERBLA( 'SSTEBZ', -INFO )
  360. RETURN
  361. END IF
  362. *
  363. * Initialize error flags
  364. *
  365. INFO = 0
  366. NCNVRG = .FALSE.
  367. TOOFEW = .FALSE.
  368. *
  369. * Quick return if possible
  370. *
  371. M = 0
  372. IF( N.EQ.0 )
  373. $ RETURN
  374. *
  375. * Simplifications:
  376. *
  377. IF( IRANGE.EQ.3 .AND. IL.EQ.1 .AND. IU.EQ.N )
  378. $ IRANGE = 1
  379. *
  380. * Get machine constants
  381. * NB is the minimum vector length for vector bisection, or 0
  382. * if only scalar is to be done.
  383. *
  384. SAFEMN = SLAMCH( 'S' )
  385. ULP = SLAMCH( 'P' )
  386. RTOLI = ULP*RELFAC
  387. NB = ILAENV( 1, 'SSTEBZ', ' ', N, -1, -1, -1 )
  388. IF( NB.LE.1 )
  389. $ NB = 0
  390. *
  391. * Special Case when N=1
  392. *
  393. IF( N.EQ.1 ) THEN
  394. NSPLIT = 1
  395. ISPLIT( 1 ) = 1
  396. IF( IRANGE.EQ.2 .AND. ( VL.GE.D( 1 ) .OR. VU.LT.D( 1 ) ) ) THEN
  397. M = 0
  398. ELSE
  399. W( 1 ) = D( 1 )
  400. IBLOCK( 1 ) = 1
  401. M = 1
  402. END IF
  403. RETURN
  404. END IF
  405. *
  406. * Compute Splitting Points
  407. *
  408. NSPLIT = 1
  409. WORK( N ) = ZERO
  410. PIVMIN = ONE
  411. *
  412. DO 10 J = 2, N
  413. TMP1 = E( J-1 )**2
  414. IF( ABS( D( J )*D( J-1 ) )*ULP**2+SAFEMN.GT.TMP1 ) THEN
  415. ISPLIT( NSPLIT ) = J - 1
  416. NSPLIT = NSPLIT + 1
  417. WORK( J-1 ) = ZERO
  418. ELSE
  419. WORK( J-1 ) = TMP1
  420. PIVMIN = MAX( PIVMIN, TMP1 )
  421. END IF
  422. 10 CONTINUE
  423. ISPLIT( NSPLIT ) = N
  424. PIVMIN = PIVMIN*SAFEMN
  425. *
  426. * Compute Interval and ATOLI
  427. *
  428. IF( IRANGE.EQ.3 ) THEN
  429. *
  430. * RANGE='I': Compute the interval containing eigenvalues
  431. * IL through IU.
  432. *
  433. * Compute Gershgorin interval for entire (split) matrix
  434. * and use it as the initial interval
  435. *
  436. GU = D( 1 )
  437. GL = D( 1 )
  438. TMP1 = ZERO
  439. *
  440. DO 20 J = 1, N - 1
  441. TMP2 = SQRT( WORK( J ) )
  442. GU = MAX( GU, D( J )+TMP1+TMP2 )
  443. GL = MIN( GL, D( J )-TMP1-TMP2 )
  444. TMP1 = TMP2
  445. 20 CONTINUE
  446. *
  447. GU = MAX( GU, D( N )+TMP1 )
  448. GL = MIN( GL, D( N )-TMP1 )
  449. TNORM = MAX( ABS( GL ), ABS( GU ) )
  450. GL = GL - FUDGE*TNORM*ULP*N - FUDGE*TWO*PIVMIN
  451. GU = GU + FUDGE*TNORM*ULP*N + FUDGE*PIVMIN
  452. *
  453. * Compute Iteration parameters
  454. *
  455. ITMAX = INT( ( LOG( TNORM+PIVMIN )-LOG( PIVMIN ) ) /
  456. $ LOG( TWO ) ) + 2
  457. IF( ABSTOL.LE.ZERO ) THEN
  458. ATOLI = ULP*TNORM
  459. ELSE
  460. ATOLI = ABSTOL
  461. END IF
  462. *
  463. WORK( N+1 ) = GL
  464. WORK( N+2 ) = GL
  465. WORK( N+3 ) = GU
  466. WORK( N+4 ) = GU
  467. WORK( N+5 ) = GL
  468. WORK( N+6 ) = GU
  469. IWORK( 1 ) = -1
  470. IWORK( 2 ) = -1
  471. IWORK( 3 ) = N + 1
  472. IWORK( 4 ) = N + 1
  473. IWORK( 5 ) = IL - 1
  474. IWORK( 6 ) = IU
  475. *
  476. CALL SLAEBZ( 3, ITMAX, N, 2, 2, NB, ATOLI, RTOLI, PIVMIN, D, E,
  477. $ WORK, IWORK( 5 ), WORK( N+1 ), WORK( N+5 ), IOUT,
  478. $ IWORK, W, IBLOCK, IINFO )
  479. *
  480. IF( IWORK( 6 ).EQ.IU ) THEN
  481. WL = WORK( N+1 )
  482. WLU = WORK( N+3 )
  483. NWL = IWORK( 1 )
  484. WU = WORK( N+4 )
  485. WUL = WORK( N+2 )
  486. NWU = IWORK( 4 )
  487. ELSE
  488. WL = WORK( N+2 )
  489. WLU = WORK( N+4 )
  490. NWL = IWORK( 2 )
  491. WU = WORK( N+3 )
  492. WUL = WORK( N+1 )
  493. NWU = IWORK( 3 )
  494. END IF
  495. *
  496. IF( NWL.LT.0 .OR. NWL.GE.N .OR. NWU.LT.1 .OR. NWU.GT.N ) THEN
  497. INFO = 4
  498. RETURN
  499. END IF
  500. ELSE
  501. *
  502. * RANGE='A' or 'V' -- Set ATOLI
  503. *
  504. TNORM = MAX( ABS( D( 1 ) )+ABS( E( 1 ) ),
  505. $ ABS( D( N ) )+ABS( E( N-1 ) ) )
  506. *
  507. DO 30 J = 2, N - 1
  508. TNORM = MAX( TNORM, ABS( D( J ) )+ABS( E( J-1 ) )+
  509. $ ABS( E( J ) ) )
  510. 30 CONTINUE
  511. *
  512. IF( ABSTOL.LE.ZERO ) THEN
  513. ATOLI = ULP*TNORM
  514. ELSE
  515. ATOLI = ABSTOL
  516. END IF
  517. *
  518. IF( IRANGE.EQ.2 ) THEN
  519. WL = VL
  520. WU = VU
  521. ELSE
  522. WL = ZERO
  523. WU = ZERO
  524. END IF
  525. END IF
  526. *
  527. * Find Eigenvalues -- Loop Over Blocks and recompute NWL and NWU.
  528. * NWL accumulates the number of eigenvalues .le. WL,
  529. * NWU accumulates the number of eigenvalues .le. WU
  530. *
  531. M = 0
  532. IEND = 0
  533. INFO = 0
  534. NWL = 0
  535. NWU = 0
  536. *
  537. DO 70 JB = 1, NSPLIT
  538. IOFF = IEND
  539. IBEGIN = IOFF + 1
  540. IEND = ISPLIT( JB )
  541. IN = IEND - IOFF
  542. *
  543. IF( IN.EQ.1 ) THEN
  544. *
  545. * Special Case -- IN=1
  546. *
  547. IF( IRANGE.EQ.1 .OR. WL.GE.D( IBEGIN )-PIVMIN )
  548. $ NWL = NWL + 1
  549. IF( IRANGE.EQ.1 .OR. WU.GE.D( IBEGIN )-PIVMIN )
  550. $ NWU = NWU + 1
  551. IF( IRANGE.EQ.1 .OR. ( WL.LT.D( IBEGIN )-PIVMIN .AND. WU.GE.
  552. $ D( IBEGIN )-PIVMIN ) ) THEN
  553. M = M + 1
  554. W( M ) = D( IBEGIN )
  555. IBLOCK( M ) = JB
  556. END IF
  557. ELSE
  558. *
  559. * General Case -- IN > 1
  560. *
  561. * Compute Gershgorin Interval
  562. * and use it as the initial interval
  563. *
  564. GU = D( IBEGIN )
  565. GL = D( IBEGIN )
  566. TMP1 = ZERO
  567. *
  568. DO 40 J = IBEGIN, IEND - 1
  569. TMP2 = ABS( E( J ) )
  570. GU = MAX( GU, D( J )+TMP1+TMP2 )
  571. GL = MIN( GL, D( J )-TMP1-TMP2 )
  572. TMP1 = TMP2
  573. 40 CONTINUE
  574. *
  575. GU = MAX( GU, D( IEND )+TMP1 )
  576. GL = MIN( GL, D( IEND )-TMP1 )
  577. BNORM = MAX( ABS( GL ), ABS( GU ) )
  578. GL = GL - FUDGE*BNORM*ULP*IN - FUDGE*PIVMIN
  579. GU = GU + FUDGE*BNORM*ULP*IN + FUDGE*PIVMIN
  580. *
  581. * Compute ATOLI for the current submatrix
  582. *
  583. IF( ABSTOL.LE.ZERO ) THEN
  584. ATOLI = ULP*MAX( ABS( GL ), ABS( GU ) )
  585. ELSE
  586. ATOLI = ABSTOL
  587. END IF
  588. *
  589. IF( IRANGE.GT.1 ) THEN
  590. IF( GU.LT.WL ) THEN
  591. NWL = NWL + IN
  592. NWU = NWU + IN
  593. GO TO 70
  594. END IF
  595. GL = MAX( GL, WL )
  596. GU = MIN( GU, WU )
  597. IF( GL.GE.GU )
  598. $ GO TO 70
  599. END IF
  600. *
  601. * Set Up Initial Interval
  602. *
  603. WORK( N+1 ) = GL
  604. WORK( N+IN+1 ) = GU
  605. CALL SLAEBZ( 1, 0, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN,
  606. $ D( IBEGIN ), E( IBEGIN ), WORK( IBEGIN ),
  607. $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IM,
  608. $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO )
  609. *
  610. NWL = NWL + IWORK( 1 )
  611. NWU = NWU + IWORK( IN+1 )
  612. IWOFF = M - IWORK( 1 )
  613. *
  614. * Compute Eigenvalues
  615. *
  616. ITMAX = INT( ( LOG( GU-GL+PIVMIN )-LOG( PIVMIN ) ) /
  617. $ LOG( TWO ) ) + 2
  618. CALL SLAEBZ( 2, ITMAX, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN,
  619. $ D( IBEGIN ), E( IBEGIN ), WORK( IBEGIN ),
  620. $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IOUT,
  621. $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO )
  622. *
  623. * Copy Eigenvalues Into W and IBLOCK
  624. * Use -JB for block number for unconverged eigenvalues.
  625. *
  626. DO 60 J = 1, IOUT
  627. TMP1 = HALF*( WORK( J+N )+WORK( J+IN+N ) )
  628. *
  629. * Flag non-convergence.
  630. *
  631. IF( J.GT.IOUT-IINFO ) THEN
  632. NCNVRG = .TRUE.
  633. IB = -JB
  634. ELSE
  635. IB = JB
  636. END IF
  637. DO 50 JE = IWORK( J ) + 1 + IWOFF,
  638. $ IWORK( J+IN ) + IWOFF
  639. W( JE ) = TMP1
  640. IBLOCK( JE ) = IB
  641. 50 CONTINUE
  642. 60 CONTINUE
  643. *
  644. M = M + IM
  645. END IF
  646. 70 CONTINUE
  647. *
  648. * If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU
  649. * If NWL+1 < IL or NWU > IU, discard extra eigenvalues.
  650. *
  651. IF( IRANGE.EQ.3 ) THEN
  652. IM = 0
  653. IDISCL = IL - 1 - NWL
  654. IDISCU = NWU - IU
  655. *
  656. IF( IDISCL.GT.0 .OR. IDISCU.GT.0 ) THEN
  657. DO 80 JE = 1, M
  658. IF( W( JE ).LE.WLU .AND. IDISCL.GT.0 ) THEN
  659. IDISCL = IDISCL - 1
  660. ELSE IF( W( JE ).GE.WUL .AND. IDISCU.GT.0 ) THEN
  661. IDISCU = IDISCU - 1
  662. ELSE
  663. IM = IM + 1
  664. W( IM ) = W( JE )
  665. IBLOCK( IM ) = IBLOCK( JE )
  666. END IF
  667. 80 CONTINUE
  668. M = IM
  669. END IF
  670. IF( IDISCL.GT.0 .OR. IDISCU.GT.0 ) THEN
  671. *
  672. * Code to deal with effects of bad arithmetic:
  673. * Some low eigenvalues to be discarded are not in (WL,WLU],
  674. * or high eigenvalues to be discarded are not in (WUL,WU]
  675. * so just kill off the smallest IDISCL/largest IDISCU
  676. * eigenvalues, by simply finding the smallest/largest
  677. * eigenvalue(s).
  678. *
  679. * (If N(w) is monotone non-decreasing, this should never
  680. * happen.)
  681. *
  682. IF( IDISCL.GT.0 ) THEN
  683. WKILL = WU
  684. DO 100 JDISC = 1, IDISCL
  685. IW = 0
  686. DO 90 JE = 1, M
  687. IF( IBLOCK( JE ).NE.0 .AND.
  688. $ ( W( JE ).LT.WKILL .OR. IW.EQ.0 ) ) THEN
  689. IW = JE
  690. WKILL = W( JE )
  691. END IF
  692. 90 CONTINUE
  693. IBLOCK( IW ) = 0
  694. 100 CONTINUE
  695. END IF
  696. IF( IDISCU.GT.0 ) THEN
  697. *
  698. WKILL = WL
  699. DO 120 JDISC = 1, IDISCU
  700. IW = 0
  701. DO 110 JE = 1, M
  702. IF( IBLOCK( JE ).NE.0 .AND.
  703. $ ( W( JE ).GT.WKILL .OR. IW.EQ.0 ) ) THEN
  704. IW = JE
  705. WKILL = W( JE )
  706. END IF
  707. 110 CONTINUE
  708. IBLOCK( IW ) = 0
  709. 120 CONTINUE
  710. END IF
  711. IM = 0
  712. DO 130 JE = 1, M
  713. IF( IBLOCK( JE ).NE.0 ) THEN
  714. IM = IM + 1
  715. W( IM ) = W( JE )
  716. IBLOCK( IM ) = IBLOCK( JE )
  717. END IF
  718. 130 CONTINUE
  719. M = IM
  720. END IF
  721. IF( IDISCL.LT.0 .OR. IDISCU.LT.0 ) THEN
  722. TOOFEW = .TRUE.
  723. END IF
  724. END IF
  725. *
  726. * If ORDER='B', do nothing -- the eigenvalues are already sorted
  727. * by block.
  728. * If ORDER='E', sort the eigenvalues from smallest to largest
  729. *
  730. IF( IORDER.EQ.1 .AND. NSPLIT.GT.1 ) THEN
  731. DO 150 JE = 1, M - 1
  732. IE = 0
  733. TMP1 = W( JE )
  734. DO 140 J = JE + 1, M
  735. IF( W( J ).LT.TMP1 ) THEN
  736. IE = J
  737. TMP1 = W( J )
  738. END IF
  739. 140 CONTINUE
  740. *
  741. IF( IE.NE.0 ) THEN
  742. ITMP1 = IBLOCK( IE )
  743. W( IE ) = W( JE )
  744. IBLOCK( IE ) = IBLOCK( JE )
  745. W( JE ) = TMP1
  746. IBLOCK( JE ) = ITMP1
  747. END IF
  748. 150 CONTINUE
  749. END IF
  750. *
  751. INFO = 0
  752. IF( NCNVRG )
  753. $ INFO = INFO + 1
  754. IF( TOOFEW )
  755. $ INFO = INFO + 2
  756. RETURN
  757. *
  758. * End of SSTEBZ
  759. *
  760. END