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.

dlarrd.f 30 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. *> \brief \b DLARRD 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 DLARRD + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrd.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrd.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrd.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE DLARRD( 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. * DOUBLE PRECISION PIVMIN, RELTOL, VL, VU, WL, WU
  30. * ..
  31. * .. Array Arguments ..
  32. * INTEGER IBLOCK( * ), INDEXW( * ),
  33. * $ ISPLIT( * ), IWORK( * )
  34. * DOUBLE PRECISION D( * ), E( * ), E2( * ),
  35. * $ GERS( * ), W( * ), WERR( * ), WORK( * )
  36. * ..
  37. *
  38. *
  39. *> \par Purpose:
  40. * =============
  41. *>
  42. *> \verbatim
  43. *>
  44. *> DLARRD computes the eigenvalues of a symmetric tridiagonal
  45. *> matrix T to suitable accuracy. This is an auxiliary code to be
  46. *> called from DSTEMR.
  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 DOUBLE PRECISION
  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 DOUBLE PRECISION
  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 DOUBLE PRECISION 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 DOUBLE PRECISION
  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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION
  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 DOUBLE PRECISION array, dimension (N)
  199. *> On exit, the first M elements of W will contain the
  200. *> eigenvalue approximations. DLARRD 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 DOUBLE PRECISION 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 DOUBLE PRECISION
  217. *> \endverbatim
  218. *>
  219. *> \param[out] WU
  220. *> \verbatim
  221. *> WU is DOUBLE PRECISION
  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 DLAEBZ 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. (DLARRD 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 DOUBLE PRECISION 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 DOUBLE PRECISION, 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. *> \ingroup OTHERauxiliary
  323. *
  324. * =====================================================================
  325. SUBROUTINE DLARRD( RANGE, ORDER, N, VL, VU, IL, IU, GERS,
  326. $ RELTOL, D, E, E2, PIVMIN, NSPLIT, ISPLIT,
  327. $ M, W, WERR, WL, WU, IBLOCK, INDEXW,
  328. $ WORK, IWORK, INFO )
  329. *
  330. * -- LAPACK auxiliary routine --
  331. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  332. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  333. *
  334. * .. Scalar Arguments ..
  335. CHARACTER ORDER, RANGE
  336. INTEGER IL, INFO, IU, M, N, NSPLIT
  337. DOUBLE PRECISION PIVMIN, RELTOL, VL, VU, WL, WU
  338. * ..
  339. * .. Array Arguments ..
  340. INTEGER IBLOCK( * ), INDEXW( * ),
  341. $ ISPLIT( * ), IWORK( * )
  342. DOUBLE PRECISION D( * ), E( * ), E2( * ),
  343. $ GERS( * ), W( * ), WERR( * ), WORK( * )
  344. * ..
  345. *
  346. * =====================================================================
  347. *
  348. * .. Parameters ..
  349. DOUBLE PRECISION ZERO, ONE, TWO, HALF, FUDGE
  350. PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0,
  351. $ TWO = 2.0D0, HALF = ONE/TWO,
  352. $ FUDGE = TWO )
  353. INTEGER ALLRNG, VALRNG, INDRNG
  354. PARAMETER ( ALLRNG = 1, VALRNG = 2, INDRNG = 3 )
  355. * ..
  356. * .. Local Scalars ..
  357. LOGICAL NCNVRG, TOOFEW
  358. INTEGER I, IB, IBEGIN, IDISCL, IDISCU, IE, IEND, IINFO,
  359. $ IM, IN, IOFF, IOUT, IRANGE, ITMAX, ITMP1,
  360. $ ITMP2, IW, IWOFF, J, JBLK, JDISC, JE, JEE, NB,
  361. $ NWL, NWU
  362. DOUBLE PRECISION ATOLI, EPS, GL, GU, RTOLI, TMP1, TMP2,
  363. $ TNORM, UFLOW, WKILL, WLU, WUL
  364. * ..
  365. * .. Local Arrays ..
  366. INTEGER IDUMMA( 1 )
  367. * ..
  368. * .. External Functions ..
  369. LOGICAL LSAME
  370. INTEGER ILAENV
  371. DOUBLE PRECISION DLAMCH
  372. EXTERNAL LSAME, ILAENV, DLAMCH
  373. * ..
  374. * .. External Subroutines ..
  375. EXTERNAL DLAEBZ
  376. * ..
  377. * .. Intrinsic Functions ..
  378. INTRINSIC ABS, INT, LOG, MAX, MIN
  379. * ..
  380. * .. Executable Statements ..
  381. *
  382. INFO = 0
  383. M = 0
  384. *
  385. * Quick return if possible
  386. *
  387. IF( N.LE.0 ) THEN
  388. RETURN
  389. END IF
  390. *
  391. * Decode RANGE
  392. *
  393. IF( LSAME( RANGE, 'A' ) ) THEN
  394. IRANGE = ALLRNG
  395. ELSE IF( LSAME( RANGE, 'V' ) ) THEN
  396. IRANGE = VALRNG
  397. ELSE IF( LSAME( RANGE, 'I' ) ) THEN
  398. IRANGE = INDRNG
  399. ELSE
  400. IRANGE = 0
  401. END IF
  402. *
  403. * Check for Errors
  404. *
  405. IF( IRANGE.LE.0 ) THEN
  406. INFO = -1
  407. ELSE IF( .NOT.(LSAME(ORDER,'B').OR.LSAME(ORDER,'E')) ) THEN
  408. INFO = -2
  409. ELSE IF( N.LT.0 ) THEN
  410. INFO = -3
  411. ELSE IF( IRANGE.EQ.VALRNG ) THEN
  412. IF( VL.GE.VU )
  413. $ INFO = -5
  414. ELSE IF( IRANGE.EQ.INDRNG .AND.
  415. $ ( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) ) THEN
  416. INFO = -6
  417. ELSE IF( IRANGE.EQ.INDRNG .AND.
  418. $ ( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) ) THEN
  419. INFO = -7
  420. END IF
  421. *
  422. IF( INFO.NE.0 ) THEN
  423. RETURN
  424. END IF
  425. * Initialize error flags
  426. NCNVRG = .FALSE.
  427. TOOFEW = .FALSE.
  428. * Simplification:
  429. IF( IRANGE.EQ.INDRNG .AND. IL.EQ.1 .AND. IU.EQ.N ) IRANGE = 1
  430. * Get machine constants
  431. EPS = DLAMCH( 'P' )
  432. UFLOW = DLAMCH( 'U' )
  433. * Special Case when N=1
  434. * Treat case of 1x1 matrix for quick return
  435. IF( N.EQ.1 ) THEN
  436. IF( (IRANGE.EQ.ALLRNG).OR.
  437. $ ((IRANGE.EQ.VALRNG).AND.(D(1).GT.VL).AND.(D(1).LE.VU)).OR.
  438. $ ((IRANGE.EQ.INDRNG).AND.(IL.EQ.1).AND.(IU.EQ.1)) ) THEN
  439. M = 1
  440. W(1) = D(1)
  441. * The computation error of the eigenvalue is zero
  442. WERR(1) = ZERO
  443. IBLOCK( 1 ) = 1
  444. INDEXW( 1 ) = 1
  445. ENDIF
  446. RETURN
  447. END IF
  448. * NB is the minimum vector length for vector bisection, or 0
  449. * if only scalar is to be done.
  450. NB = ILAENV( 1, 'DSTEBZ', ' ', N, -1, -1, -1 )
  451. IF( NB.LE.1 ) NB = 0
  452. * Find global spectral radius
  453. GL = D(1)
  454. GU = D(1)
  455. DO 5 I = 1,N
  456. GL = MIN( GL, GERS( 2*I - 1))
  457. GU = MAX( GU, GERS(2*I) )
  458. 5 CONTINUE
  459. * Compute global Gerschgorin bounds and spectral diameter
  460. TNORM = MAX( ABS( GL ), ABS( GU ) )
  461. GL = GL - FUDGE*TNORM*EPS*N - FUDGE*TWO*PIVMIN
  462. GU = GU + FUDGE*TNORM*EPS*N + FUDGE*TWO*PIVMIN
  463. * [JAN/28/2009] remove the line below since SPDIAM variable not use
  464. * SPDIAM = GU - GL
  465. * Input arguments for DLAEBZ:
  466. * The relative tolerance. An interval (a,b] lies within
  467. * "relative tolerance" if b-a < RELTOL*max(|a|,|b|),
  468. RTOLI = RELTOL
  469. * Set the absolute tolerance for interval convergence to zero to force
  470. * interval convergence based on relative size of the interval.
  471. * This is dangerous because intervals might not converge when RELTOL is
  472. * small. But at least a very small number should be selected so that for
  473. * strongly graded matrices, the code can get relatively accurate
  474. * eigenvalues.
  475. ATOLI = FUDGE*TWO*UFLOW + FUDGE*TWO*PIVMIN
  476. IF( IRANGE.EQ.INDRNG ) THEN
  477. * RANGE='I': Compute an interval containing eigenvalues
  478. * IL through IU. The initial interval [GL,GU] from the global
  479. * Gerschgorin bounds GL and GU is refined by DLAEBZ.
  480. ITMAX = INT( ( LOG( TNORM+PIVMIN )-LOG( PIVMIN ) ) /
  481. $ LOG( TWO ) ) + 2
  482. WORK( N+1 ) = GL
  483. WORK( N+2 ) = GL
  484. WORK( N+3 ) = GU
  485. WORK( N+4 ) = GU
  486. WORK( N+5 ) = GL
  487. WORK( N+6 ) = GU
  488. IWORK( 1 ) = -1
  489. IWORK( 2 ) = -1
  490. IWORK( 3 ) = N + 1
  491. IWORK( 4 ) = N + 1
  492. IWORK( 5 ) = IL - 1
  493. IWORK( 6 ) = IU
  494. *
  495. CALL DLAEBZ( 3, ITMAX, N, 2, 2, NB, ATOLI, RTOLI, PIVMIN,
  496. $ D, E, E2, IWORK( 5 ), WORK( N+1 ), WORK( N+5 ), IOUT,
  497. $ IWORK, W, IBLOCK, IINFO )
  498. IF( IINFO .NE. 0 ) THEN
  499. INFO = IINFO
  500. RETURN
  501. END IF
  502. * On exit, output intervals may not be ordered by ascending negcount
  503. IF( IWORK( 6 ).EQ.IU ) THEN
  504. WL = WORK( N+1 )
  505. WLU = WORK( N+3 )
  506. NWL = IWORK( 1 )
  507. WU = WORK( N+4 )
  508. WUL = WORK( N+2 )
  509. NWU = IWORK( 4 )
  510. ELSE
  511. WL = WORK( N+2 )
  512. WLU = WORK( N+4 )
  513. NWL = IWORK( 2 )
  514. WU = WORK( N+3 )
  515. WUL = WORK( N+1 )
  516. NWU = IWORK( 3 )
  517. END IF
  518. * On exit, the interval [WL, WLU] contains a value with negcount NWL,
  519. * and [WUL, WU] contains a value with negcount NWU.
  520. IF( NWL.LT.0 .OR. NWL.GE.N .OR. NWU.LT.1 .OR. NWU.GT.N ) THEN
  521. INFO = 4
  522. RETURN
  523. END IF
  524. ELSEIF( IRANGE.EQ.VALRNG ) THEN
  525. WL = VL
  526. WU = VU
  527. ELSEIF( IRANGE.EQ.ALLRNG ) THEN
  528. WL = GL
  529. WU = GU
  530. ENDIF
  531. * Find Eigenvalues -- Loop Over blocks and recompute NWL and NWU.
  532. * NWL accumulates the number of eigenvalues .le. WL,
  533. * NWU accumulates the number of eigenvalues .le. WU
  534. M = 0
  535. IEND = 0
  536. INFO = 0
  537. NWL = 0
  538. NWU = 0
  539. *
  540. DO 70 JBLK = 1, NSPLIT
  541. IOFF = IEND
  542. IBEGIN = IOFF + 1
  543. IEND = ISPLIT( JBLK )
  544. IN = IEND - IOFF
  545. *
  546. IF( IN.EQ.1 ) THEN
  547. * 1x1 block
  548. IF( WL.GE.D( IBEGIN )-PIVMIN )
  549. $ NWL = NWL + 1
  550. IF( WU.GE.D( IBEGIN )-PIVMIN )
  551. $ NWU = NWU + 1
  552. IF( IRANGE.EQ.ALLRNG .OR.
  553. $ ( WL.LT.D( IBEGIN )-PIVMIN
  554. $ .AND. WU.GE. D( IBEGIN )-PIVMIN ) ) THEN
  555. M = M + 1
  556. W( M ) = D( IBEGIN )
  557. WERR(M) = ZERO
  558. * The gap for a single block doesn't matter for the later
  559. * algorithm and is assigned an arbitrary large value
  560. IBLOCK( M ) = JBLK
  561. INDEXW( M ) = 1
  562. END IF
  563. * Disabled 2x2 case because of a failure on the following matrix
  564. * RANGE = 'I', IL = IU = 4
  565. * Original Tridiagonal, d = [
  566. * -0.150102010615740E+00
  567. * -0.849897989384260E+00
  568. * -0.128208148052635E-15
  569. * 0.128257718286320E-15
  570. * ];
  571. * e = [
  572. * -0.357171383266986E+00
  573. * -0.180411241501588E-15
  574. * -0.175152352710251E-15
  575. * ];
  576. *
  577. * ELSE IF( IN.EQ.2 ) THEN
  578. ** 2x2 block
  579. * DISC = SQRT( (HALF*(D(IBEGIN)-D(IEND)))**2 + E(IBEGIN)**2 )
  580. * TMP1 = HALF*(D(IBEGIN)+D(IEND))
  581. * L1 = TMP1 - DISC
  582. * IF( WL.GE. L1-PIVMIN )
  583. * $ NWL = NWL + 1
  584. * IF( WU.GE. L1-PIVMIN )
  585. * $ NWU = NWU + 1
  586. * IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L1-PIVMIN .AND. WU.GE.
  587. * $ L1-PIVMIN ) ) THEN
  588. * M = M + 1
  589. * W( M ) = L1
  590. ** The uncertainty of eigenvalues of a 2x2 matrix is very small
  591. * WERR( M ) = EPS * ABS( W( M ) ) * TWO
  592. * IBLOCK( M ) = JBLK
  593. * INDEXW( M ) = 1
  594. * ENDIF
  595. * L2 = TMP1 + DISC
  596. * IF( WL.GE. L2-PIVMIN )
  597. * $ NWL = NWL + 1
  598. * IF( WU.GE. L2-PIVMIN )
  599. * $ NWU = NWU + 1
  600. * IF( IRANGE.EQ.ALLRNG .OR. ( WL.LT.L2-PIVMIN .AND. WU.GE.
  601. * $ L2-PIVMIN ) ) THEN
  602. * M = M + 1
  603. * W( M ) = L2
  604. ** The uncertainty of eigenvalues of a 2x2 matrix is very small
  605. * WERR( M ) = EPS * ABS( W( M ) ) * TWO
  606. * IBLOCK( M ) = JBLK
  607. * INDEXW( M ) = 2
  608. * ENDIF
  609. ELSE
  610. * General Case - block of size IN >= 2
  611. * Compute local Gerschgorin interval and use it as the initial
  612. * interval for DLAEBZ
  613. GU = D( IBEGIN )
  614. GL = D( IBEGIN )
  615. TMP1 = ZERO
  616. DO 40 J = IBEGIN, IEND
  617. GL = MIN( GL, GERS( 2*J - 1))
  618. GU = MAX( GU, GERS(2*J) )
  619. 40 CONTINUE
  620. * [JAN/28/2009]
  621. * change SPDIAM by TNORM in lines 2 and 3 thereafter
  622. * line 1: remove computation of SPDIAM (not useful anymore)
  623. * SPDIAM = GU - GL
  624. * GL = GL - FUDGE*SPDIAM*EPS*IN - FUDGE*PIVMIN
  625. * GU = GU + FUDGE*SPDIAM*EPS*IN + FUDGE*PIVMIN
  626. GL = GL - FUDGE*TNORM*EPS*IN - FUDGE*PIVMIN
  627. GU = GU + FUDGE*TNORM*EPS*IN + FUDGE*PIVMIN
  628. *
  629. IF( IRANGE.GT.1 ) THEN
  630. IF( GU.LT.WL ) THEN
  631. * the local block contains none of the wanted eigenvalues
  632. NWL = NWL + IN
  633. NWU = NWU + IN
  634. GO TO 70
  635. END IF
  636. * refine search interval if possible, only range (WL,WU] matters
  637. GL = MAX( GL, WL )
  638. GU = MIN( GU, WU )
  639. IF( GL.GE.GU )
  640. $ GO TO 70
  641. END IF
  642. * Find negcount of initial interval boundaries GL and GU
  643. WORK( N+1 ) = GL
  644. WORK( N+IN+1 ) = GU
  645. CALL DLAEBZ( 1, 0, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN,
  646. $ D( IBEGIN ), E( IBEGIN ), E2( IBEGIN ),
  647. $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IM,
  648. $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO )
  649. IF( IINFO .NE. 0 ) THEN
  650. INFO = IINFO
  651. RETURN
  652. END IF
  653. *
  654. NWL = NWL + IWORK( 1 )
  655. NWU = NWU + IWORK( IN+1 )
  656. IWOFF = M - IWORK( 1 )
  657. * Compute Eigenvalues
  658. ITMAX = INT( ( LOG( GU-GL+PIVMIN )-LOG( PIVMIN ) ) /
  659. $ LOG( TWO ) ) + 2
  660. CALL DLAEBZ( 2, ITMAX, IN, IN, 1, NB, ATOLI, RTOLI, PIVMIN,
  661. $ D( IBEGIN ), E( IBEGIN ), E2( IBEGIN ),
  662. $ IDUMMA, WORK( N+1 ), WORK( N+2*IN+1 ), IOUT,
  663. $ IWORK, W( M+1 ), IBLOCK( M+1 ), IINFO )
  664. IF( IINFO .NE. 0 ) THEN
  665. INFO = IINFO
  666. RETURN
  667. END IF
  668. *
  669. * Copy eigenvalues into W and IBLOCK
  670. * Use -JBLK for block number for unconverged eigenvalues.
  671. * Loop over the number of output intervals from DLAEBZ
  672. DO 60 J = 1, IOUT
  673. * eigenvalue approximation is middle point of interval
  674. TMP1 = HALF*( WORK( J+N )+WORK( J+IN+N ) )
  675. * semi length of error interval
  676. TMP2 = HALF*ABS( WORK( J+N )-WORK( J+IN+N ) )
  677. IF( J.GT.IOUT-IINFO ) THEN
  678. * Flag non-convergence.
  679. NCNVRG = .TRUE.
  680. IB = -JBLK
  681. ELSE
  682. IB = JBLK
  683. END IF
  684. DO 50 JE = IWORK( J ) + 1 + IWOFF,
  685. $ IWORK( J+IN ) + IWOFF
  686. W( JE ) = TMP1
  687. WERR( JE ) = TMP2
  688. INDEXW( JE ) = JE - IWOFF
  689. IBLOCK( JE ) = IB
  690. 50 CONTINUE
  691. 60 CONTINUE
  692. *
  693. M = M + IM
  694. END IF
  695. 70 CONTINUE
  696. * If RANGE='I', then (WL,WU) contains eigenvalues NWL+1,...,NWU
  697. * If NWL+1 < IL or NWU > IU, discard extra eigenvalues.
  698. IF( IRANGE.EQ.INDRNG ) THEN
  699. IDISCL = IL - 1 - NWL
  700. IDISCU = NWU - IU
  701. *
  702. IF( IDISCL.GT.0 ) THEN
  703. IM = 0
  704. DO 80 JE = 1, M
  705. * Remove some of the smallest eigenvalues from the left so that
  706. * at the end IDISCL =0. Move all eigenvalues up to the left.
  707. IF( W( JE ).LE.WLU .AND. IDISCL.GT.0 ) THEN
  708. IDISCL = IDISCL - 1
  709. ELSE
  710. IM = IM + 1
  711. W( IM ) = W( JE )
  712. WERR( IM ) = WERR( JE )
  713. INDEXW( IM ) = INDEXW( JE )
  714. IBLOCK( IM ) = IBLOCK( JE )
  715. END IF
  716. 80 CONTINUE
  717. M = IM
  718. END IF
  719. IF( IDISCU.GT.0 ) THEN
  720. * Remove some of the largest eigenvalues from the right so that
  721. * at the end IDISCU =0. Move all eigenvalues up to the left.
  722. IM=M+1
  723. DO 81 JE = M, 1, -1
  724. IF( W( JE ).GE.WUL .AND. IDISCU.GT.0 ) THEN
  725. IDISCU = IDISCU - 1
  726. ELSE
  727. IM = IM - 1
  728. W( IM ) = W( JE )
  729. WERR( IM ) = WERR( JE )
  730. INDEXW( IM ) = INDEXW( JE )
  731. IBLOCK( IM ) = IBLOCK( JE )
  732. END IF
  733. 81 CONTINUE
  734. JEE = 0
  735. DO 82 JE = IM, M
  736. JEE = JEE + 1
  737. W( JEE ) = W( JE )
  738. WERR( JEE ) = WERR( JE )
  739. INDEXW( JEE ) = INDEXW( JE )
  740. IBLOCK( JEE ) = IBLOCK( JE )
  741. 82 CONTINUE
  742. M = M-IM+1
  743. END IF
  744. IF( IDISCL.GT.0 .OR. IDISCU.GT.0 ) THEN
  745. * Code to deal with effects of bad arithmetic. (If N(w) is
  746. * monotone non-decreasing, this should never happen.)
  747. * Some low eigenvalues to be discarded are not in (WL,WLU],
  748. * or high eigenvalues to be discarded are not in (WUL,WU]
  749. * so just kill off the smallest IDISCL/largest IDISCU
  750. * eigenvalues, by marking the corresponding IBLOCK = 0
  751. IF( IDISCL.GT.0 ) THEN
  752. WKILL = WU
  753. DO 100 JDISC = 1, IDISCL
  754. IW = 0
  755. DO 90 JE = 1, M
  756. IF( IBLOCK( JE ).NE.0 .AND.
  757. $ ( W( JE ).LT.WKILL .OR. IW.EQ.0 ) ) THEN
  758. IW = JE
  759. WKILL = W( JE )
  760. END IF
  761. 90 CONTINUE
  762. IBLOCK( IW ) = 0
  763. 100 CONTINUE
  764. END IF
  765. IF( IDISCU.GT.0 ) THEN
  766. WKILL = WL
  767. DO 120 JDISC = 1, IDISCU
  768. IW = 0
  769. DO 110 JE = 1, M
  770. IF( IBLOCK( JE ).NE.0 .AND.
  771. $ ( W( JE ).GE.WKILL .OR. IW.EQ.0 ) ) THEN
  772. IW = JE
  773. WKILL = W( JE )
  774. END IF
  775. 110 CONTINUE
  776. IBLOCK( IW ) = 0
  777. 120 CONTINUE
  778. END IF
  779. * Now erase all eigenvalues with IBLOCK set to zero
  780. IM = 0
  781. DO 130 JE = 1, M
  782. IF( IBLOCK( JE ).NE.0 ) THEN
  783. IM = IM + 1
  784. W( IM ) = W( JE )
  785. WERR( IM ) = WERR( JE )
  786. INDEXW( IM ) = INDEXW( JE )
  787. IBLOCK( IM ) = IBLOCK( JE )
  788. END IF
  789. 130 CONTINUE
  790. M = IM
  791. END IF
  792. IF( IDISCL.LT.0 .OR. IDISCU.LT.0 ) THEN
  793. TOOFEW = .TRUE.
  794. END IF
  795. END IF
  796. *
  797. IF(( IRANGE.EQ.ALLRNG .AND. M.NE.N ).OR.
  798. $ ( IRANGE.EQ.INDRNG .AND. M.NE.IU-IL+1 ) ) THEN
  799. TOOFEW = .TRUE.
  800. END IF
  801. * If ORDER='B', do nothing the eigenvalues are already sorted by
  802. * block.
  803. * If ORDER='E', sort the eigenvalues from smallest to largest
  804. IF( LSAME(ORDER,'E') .AND. NSPLIT.GT.1 ) THEN
  805. DO 150 JE = 1, M - 1
  806. IE = 0
  807. TMP1 = W( JE )
  808. DO 140 J = JE + 1, M
  809. IF( W( J ).LT.TMP1 ) THEN
  810. IE = J
  811. TMP1 = W( J )
  812. END IF
  813. 140 CONTINUE
  814. IF( IE.NE.0 ) THEN
  815. TMP2 = WERR( IE )
  816. ITMP1 = IBLOCK( IE )
  817. ITMP2 = INDEXW( IE )
  818. W( IE ) = W( JE )
  819. WERR( IE ) = WERR( JE )
  820. IBLOCK( IE ) = IBLOCK( JE )
  821. INDEXW( IE ) = INDEXW( JE )
  822. W( JE ) = TMP1
  823. WERR( JE ) = TMP2
  824. IBLOCK( JE ) = ITMP1
  825. INDEXW( JE ) = ITMP2
  826. END IF
  827. 150 CONTINUE
  828. END IF
  829. *
  830. INFO = 0
  831. IF( NCNVRG )
  832. $ INFO = INFO + 1
  833. IF( TOOFEW )
  834. $ INFO = INFO + 2
  835. RETURN
  836. *
  837. * End of DLARRD
  838. *
  839. END