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.

slarrd.f 30 kB

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