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

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