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.

sstevr.f 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. *> \brief <b> SSTEVR computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SSTEVR + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstevr.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstevr.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstevr.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SSTEVR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
  22. * M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,
  23. * LIWORK, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER JOBZ, RANGE
  27. * INTEGER IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
  28. * REAL ABSTOL, VL, VU
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER ISUPPZ( * ), IWORK( * )
  32. * REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
  33. * ..
  34. *
  35. *
  36. *> \par Purpose:
  37. * =============
  38. *>
  39. *> \verbatim
  40. *>
  41. *> SSTEVR computes selected eigenvalues and, optionally, eigenvectors
  42. *> of a real symmetric tridiagonal matrix T. Eigenvalues and
  43. *> eigenvectors can be selected by specifying either a range of values
  44. *> or a range of indices for the desired eigenvalues.
  45. *>
  46. *> Whenever possible, SSTEVR calls SSTEMR to compute the
  47. *> eigenspectrum using Relatively Robust Representations. SSTEMR
  48. *> computes eigenvalues by the dqds algorithm, while orthogonal
  49. *> eigenvectors are computed from various "good" L D L^T representations
  50. *> (also known as Relatively Robust Representations). Gram-Schmidt
  51. *> orthogonalization is avoided as far as possible. More specifically,
  52. *> the various steps of the algorithm are as follows. For the i-th
  53. *> unreduced block of T,
  54. *> (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
  55. *> is a relatively robust representation,
  56. *> (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
  57. *> relative accuracy by the dqds algorithm,
  58. *> (c) If there is a cluster of close eigenvalues, "choose" sigma_i
  59. *> close to the cluster, and go to step (a),
  60. *> (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
  61. *> compute the corresponding eigenvector by forming a
  62. *> rank-revealing twisted factorization.
  63. *> The desired accuracy of the output can be specified by the input
  64. *> parameter ABSTOL.
  65. *>
  66. *> For more details, see "A new O(n^2) algorithm for the symmetric
  67. *> tridiagonal eigenvalue/eigenvector problem", by Inderjit Dhillon,
  68. *> Computer Science Division Technical Report No. UCB//CSD-97-971,
  69. *> UC Berkeley, May 1997.
  70. *>
  71. *>
  72. *> Note 1 : SSTEVR calls SSTEMR when the full spectrum is requested
  73. *> on machines which conform to the ieee-754 floating point standard.
  74. *> SSTEVR calls SSTEBZ and SSTEIN on non-ieee machines and
  75. *> when partial spectrum requests are made.
  76. *>
  77. *> Normal execution of SSTEMR may create NaNs and infinities and
  78. *> hence may abort due to a floating point exception in environments
  79. *> which do not handle NaNs and infinities in the ieee standard default
  80. *> manner.
  81. *> \endverbatim
  82. *
  83. * Arguments:
  84. * ==========
  85. *
  86. *> \param[in] JOBZ
  87. *> \verbatim
  88. *> JOBZ is CHARACTER*1
  89. *> = 'N': Compute eigenvalues only;
  90. *> = 'V': Compute eigenvalues and eigenvectors.
  91. *> \endverbatim
  92. *>
  93. *> \param[in] RANGE
  94. *> \verbatim
  95. *> RANGE is CHARACTER*1
  96. *> = 'A': all eigenvalues will be found.
  97. *> = 'V': all eigenvalues in the half-open interval (VL,VU]
  98. *> will be found.
  99. *> = 'I': the IL-th through IU-th eigenvalues will be found.
  100. *> For RANGE = 'V' or 'I' and IU - IL < N - 1, SSTEBZ and
  101. *> SSTEIN are called
  102. *> \endverbatim
  103. *>
  104. *> \param[in] N
  105. *> \verbatim
  106. *> N is INTEGER
  107. *> The order of the matrix. N >= 0.
  108. *> \endverbatim
  109. *>
  110. *> \param[in,out] D
  111. *> \verbatim
  112. *> D is REAL array, dimension (N)
  113. *> On entry, the n diagonal elements of the tridiagonal matrix
  114. *> A.
  115. *> On exit, D may be multiplied by a constant factor chosen
  116. *> to avoid over/underflow in computing the eigenvalues.
  117. *> \endverbatim
  118. *>
  119. *> \param[in,out] E
  120. *> \verbatim
  121. *> E is REAL array, dimension (max(1,N-1))
  122. *> On entry, the (n-1) subdiagonal elements of the tridiagonal
  123. *> matrix A in elements 1 to N-1 of E.
  124. *> On exit, E may be multiplied by a constant factor chosen
  125. *> to avoid over/underflow in computing the eigenvalues.
  126. *> \endverbatim
  127. *>
  128. *> \param[in] VL
  129. *> \verbatim
  130. *> VL is REAL
  131. *> \endverbatim
  132. *>
  133. *> \param[in] VU
  134. *> \verbatim
  135. *> VU is REAL
  136. *> If RANGE='V', the lower and upper bounds of the interval to
  137. *> be searched for eigenvalues. VL < VU.
  138. *> Not referenced if RANGE = 'A' or 'I'.
  139. *> \endverbatim
  140. *>
  141. *> \param[in] IL
  142. *> \verbatim
  143. *> IL is INTEGER
  144. *> \endverbatim
  145. *>
  146. *> \param[in] IU
  147. *> \verbatim
  148. *> IU is INTEGER
  149. *> If RANGE='I', the indices (in ascending order) of the
  150. *> smallest and largest eigenvalues to be returned.
  151. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  152. *> Not referenced if RANGE = 'A' or 'V'.
  153. *> \endverbatim
  154. *>
  155. *> \param[in] ABSTOL
  156. *> \verbatim
  157. *> ABSTOL is REAL
  158. *> The absolute error tolerance for the eigenvalues.
  159. *> An approximate eigenvalue is accepted as converged
  160. *> when it is determined to lie in an interval [a,b]
  161. *> of width less than or equal to
  162. *>
  163. *> ABSTOL + EPS * max( |a|,|b| ) ,
  164. *>
  165. *> where EPS is the machine precision. If ABSTOL is less than
  166. *> or equal to zero, then EPS*|T| will be used in its place,
  167. *> where |T| is the 1-norm of the tridiagonal matrix obtained
  168. *> by reducing A to tridiagonal form.
  169. *>
  170. *> See "Computing Small Singular Values of Bidiagonal Matrices
  171. *> with Guaranteed High Relative Accuracy," by Demmel and
  172. *> Kahan, LAPACK Working Note #3.
  173. *>
  174. *> If high relative accuracy is important, set ABSTOL to
  175. *> SLAMCH( 'Safe minimum' ). Doing so will guarantee that
  176. *> eigenvalues are computed to high relative accuracy when
  177. *> possible in future releases. The current code does not
  178. *> make any guarantees about high relative accuracy, but
  179. *> future releases will. See J. Barlow and J. Demmel,
  180. *> "Computing Accurate Eigensystems of Scaled Diagonally
  181. *> Dominant Matrices", LAPACK Working Note #7, for a discussion
  182. *> of which matrices define their eigenvalues to high relative
  183. *> accuracy.
  184. *> \endverbatim
  185. *>
  186. *> \param[out] M
  187. *> \verbatim
  188. *> M is INTEGER
  189. *> The total number of eigenvalues found. 0 <= M <= N.
  190. *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  191. *> \endverbatim
  192. *>
  193. *> \param[out] W
  194. *> \verbatim
  195. *> W is REAL array, dimension (N)
  196. *> The first M elements contain the selected eigenvalues in
  197. *> ascending order.
  198. *> \endverbatim
  199. *>
  200. *> \param[out] Z
  201. *> \verbatim
  202. *> Z is REAL array, dimension (LDZ, max(1,M) )
  203. *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  204. *> contain the orthonormal eigenvectors of the matrix A
  205. *> corresponding to the selected eigenvalues, with the i-th
  206. *> column of Z holding the eigenvector associated with W(i).
  207. *> Note: the user must ensure that at least max(1,M) columns are
  208. *> supplied in the array Z; if RANGE = 'V', the exact value of M
  209. *> is not known in advance and an upper bound must be used.
  210. *> \endverbatim
  211. *>
  212. *> \param[in] LDZ
  213. *> \verbatim
  214. *> LDZ is INTEGER
  215. *> The leading dimension of the array Z. LDZ >= 1, and if
  216. *> JOBZ = 'V', LDZ >= max(1,N).
  217. *> \endverbatim
  218. *>
  219. *> \param[out] ISUPPZ
  220. *> \verbatim
  221. *> ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
  222. *> The support of the eigenvectors in Z, i.e., the indices
  223. *> indicating the nonzero elements in Z. The i-th eigenvector
  224. *> is nonzero only in elements ISUPPZ( 2*i-1 ) through
  225. *> ISUPPZ( 2*i ).
  226. *> Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
  227. *> \endverbatim
  228. *>
  229. *> \param[out] WORK
  230. *> \verbatim
  231. *> WORK is REAL array, dimension (MAX(1,LWORK))
  232. *> On exit, if INFO = 0, WORK(1) returns the optimal (and
  233. *> minimal) LWORK.
  234. *> \endverbatim
  235. *>
  236. *> \param[in] LWORK
  237. *> \verbatim
  238. *> LWORK is INTEGER
  239. *> The dimension of the array WORK. LWORK >= 20*N.
  240. *>
  241. *> If LWORK = -1, then a workspace query is assumed; the routine
  242. *> only calculates the optimal sizes of the WORK and IWORK
  243. *> arrays, returns these values as the first entries of the WORK
  244. *> and IWORK arrays, and no error message related to LWORK or
  245. *> LIWORK is issued by XERBLA.
  246. *> \endverbatim
  247. *>
  248. *> \param[out] IWORK
  249. *> \verbatim
  250. *> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
  251. *> On exit, if INFO = 0, IWORK(1) returns the optimal (and
  252. *> minimal) LIWORK.
  253. *> \endverbatim
  254. *>
  255. *> \param[in] LIWORK
  256. *> \verbatim
  257. *> LIWORK is INTEGER
  258. *> The dimension of the array IWORK. LIWORK >= 10*N.
  259. *>
  260. *> If LIWORK = -1, then a workspace query is assumed; the
  261. *> routine only calculates the optimal sizes of the WORK and
  262. *> IWORK arrays, returns these values as the first entries of
  263. *> the WORK and IWORK arrays, and no error message related to
  264. *> LWORK or LIWORK is issued by XERBLA.
  265. *> \endverbatim
  266. *>
  267. *> \param[out] INFO
  268. *> \verbatim
  269. *> INFO is INTEGER
  270. *> = 0: successful exit
  271. *> < 0: if INFO = -i, the i-th argument had an illegal value
  272. *> > 0: Internal error
  273. *> \endverbatim
  274. *
  275. * Authors:
  276. * ========
  277. *
  278. *> \author Univ. of Tennessee
  279. *> \author Univ. of California Berkeley
  280. *> \author Univ. of Colorado Denver
  281. *> \author NAG Ltd.
  282. *
  283. *> \date November 2011
  284. *
  285. *> \ingroup realOTHEReigen
  286. *
  287. *> \par Contributors:
  288. * ==================
  289. *>
  290. *> Inderjit Dhillon, IBM Almaden, USA \n
  291. *> Osni Marques, LBNL/NERSC, USA \n
  292. *> Ken Stanley, Computer Science Division, University of
  293. *> California at Berkeley, USA \n
  294. *> Jason Riedy, Computer Science Division, University of
  295. *> California at Berkeley, USA \n
  296. *>
  297. * =====================================================================
  298. SUBROUTINE SSTEVR( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
  299. $ M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK,
  300. $ LIWORK, INFO )
  301. *
  302. * -- LAPACK driver routine (version 3.4.0) --
  303. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  304. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  305. * November 2011
  306. *
  307. * .. Scalar Arguments ..
  308. CHARACTER JOBZ, RANGE
  309. INTEGER IL, INFO, IU, LDZ, LIWORK, LWORK, M, N
  310. REAL ABSTOL, VL, VU
  311. * ..
  312. * .. Array Arguments ..
  313. INTEGER ISUPPZ( * ), IWORK( * )
  314. REAL D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
  315. * ..
  316. *
  317. * =====================================================================
  318. *
  319. * .. Parameters ..
  320. REAL ZERO, ONE, TWO
  321. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
  322. * ..
  323. * .. Local Scalars ..
  324. LOGICAL ALLEIG, INDEIG, TEST, LQUERY, VALEIG, WANTZ,
  325. $ TRYRAC
  326. CHARACTER ORDER
  327. INTEGER I, IEEEOK, IMAX, INDIBL, INDIFL, INDISP,
  328. $ INDIWO, ISCALE, J, JJ, LIWMIN, LWMIN, NSPLIT
  329. REAL BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
  330. $ TMP1, TNRM, VLL, VUU
  331. * ..
  332. * .. External Functions ..
  333. LOGICAL LSAME
  334. INTEGER ILAENV
  335. REAL SLAMCH, SLANST
  336. EXTERNAL LSAME, ILAENV, SLAMCH, SLANST
  337. * ..
  338. * .. External Subroutines ..
  339. EXTERNAL SCOPY, SSCAL, SSTEBZ, SSTEMR, SSTEIN, SSTERF,
  340. $ SSWAP, XERBLA
  341. * ..
  342. * .. Intrinsic Functions ..
  343. INTRINSIC MAX, MIN, SQRT
  344. * ..
  345. * .. Executable Statements ..
  346. *
  347. *
  348. * Test the input parameters.
  349. *
  350. IEEEOK = ILAENV( 10, 'SSTEVR', 'N', 1, 2, 3, 4 )
  351. *
  352. WANTZ = LSAME( JOBZ, 'V' )
  353. ALLEIG = LSAME( RANGE, 'A' )
  354. VALEIG = LSAME( RANGE, 'V' )
  355. INDEIG = LSAME( RANGE, 'I' )
  356. *
  357. LQUERY = ( ( LWORK.EQ.-1 ) .OR. ( LIWORK.EQ.-1 ) )
  358. LWMIN = MAX( 1, 20*N )
  359. LIWMIN = MAX(1, 10*N )
  360. *
  361. *
  362. INFO = 0
  363. IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  364. INFO = -1
  365. ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
  366. INFO = -2
  367. ELSE IF( N.LT.0 ) THEN
  368. INFO = -3
  369. ELSE
  370. IF( VALEIG ) THEN
  371. IF( N.GT.0 .AND. VU.LE.VL )
  372. $ INFO = -7
  373. ELSE IF( INDEIG ) THEN
  374. IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
  375. INFO = -8
  376. ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
  377. INFO = -9
  378. END IF
  379. END IF
  380. END IF
  381. IF( INFO.EQ.0 ) THEN
  382. IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
  383. INFO = -14
  384. END IF
  385. END IF
  386. *
  387. IF( INFO.EQ.0 ) THEN
  388. WORK( 1 ) = LWMIN
  389. IWORK( 1 ) = LIWMIN
  390. *
  391. IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
  392. INFO = -17
  393. ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
  394. INFO = -19
  395. END IF
  396. END IF
  397. *
  398. IF( INFO.NE.0 ) THEN
  399. CALL XERBLA( 'SSTEVR', -INFO )
  400. RETURN
  401. ELSE IF( LQUERY ) THEN
  402. RETURN
  403. END IF
  404. *
  405. * Quick return if possible
  406. *
  407. M = 0
  408. IF( N.EQ.0 )
  409. $ RETURN
  410. *
  411. IF( N.EQ.1 ) THEN
  412. IF( ALLEIG .OR. INDEIG ) THEN
  413. M = 1
  414. W( 1 ) = D( 1 )
  415. ELSE
  416. IF( VL.LT.D( 1 ) .AND. VU.GE.D( 1 ) ) THEN
  417. M = 1
  418. W( 1 ) = D( 1 )
  419. END IF
  420. END IF
  421. IF( WANTZ )
  422. $ Z( 1, 1 ) = ONE
  423. RETURN
  424. END IF
  425. *
  426. * Get machine constants.
  427. *
  428. SAFMIN = SLAMCH( 'Safe minimum' )
  429. EPS = SLAMCH( 'Precision' )
  430. SMLNUM = SAFMIN / EPS
  431. BIGNUM = ONE / SMLNUM
  432. RMIN = SQRT( SMLNUM )
  433. RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
  434. *
  435. *
  436. * Scale matrix to allowable range, if necessary.
  437. *
  438. ISCALE = 0
  439. VLL = VL
  440. VUU = VU
  441. *
  442. TNRM = SLANST( 'M', N, D, E )
  443. IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
  444. ISCALE = 1
  445. SIGMA = RMIN / TNRM
  446. ELSE IF( TNRM.GT.RMAX ) THEN
  447. ISCALE = 1
  448. SIGMA = RMAX / TNRM
  449. END IF
  450. IF( ISCALE.EQ.1 ) THEN
  451. CALL SSCAL( N, SIGMA, D, 1 )
  452. CALL SSCAL( N-1, SIGMA, E( 1 ), 1 )
  453. IF( VALEIG ) THEN
  454. VLL = VL*SIGMA
  455. VUU = VU*SIGMA
  456. END IF
  457. END IF
  458. * Initialize indices into workspaces. Note: These indices are used only
  459. * if SSTERF or SSTEMR fail.
  460. * IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in SSTEBZ and
  461. * stores the block indices of each of the M<=N eigenvalues.
  462. INDIBL = 1
  463. * IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in SSTEBZ and
  464. * stores the starting and finishing indices of each block.
  465. INDISP = INDIBL + N
  466. * IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors
  467. * that corresponding to eigenvectors that fail to converge in
  468. * SSTEIN. This information is discarded; if any fail, the driver
  469. * returns INFO > 0.
  470. INDIFL = INDISP + N
  471. * INDIWO is the offset of the remaining integer workspace.
  472. INDIWO = INDISP + N
  473. *
  474. * If all eigenvalues are desired, then
  475. * call SSTERF or SSTEMR. If this fails for some eigenvalue, then
  476. * try SSTEBZ.
  477. *
  478. *
  479. TEST = .FALSE.
  480. IF( INDEIG ) THEN
  481. IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
  482. TEST = .TRUE.
  483. END IF
  484. END IF
  485. IF( ( ALLEIG .OR. TEST ) .AND. IEEEOK.EQ.1 ) THEN
  486. CALL SCOPY( N-1, E( 1 ), 1, WORK( 1 ), 1 )
  487. IF( .NOT.WANTZ ) THEN
  488. CALL SCOPY( N, D, 1, W, 1 )
  489. CALL SSTERF( N, W, WORK, INFO )
  490. ELSE
  491. CALL SCOPY( N, D, 1, WORK( N+1 ), 1 )
  492. IF (ABSTOL .LE. TWO*N*EPS) THEN
  493. TRYRAC = .TRUE.
  494. ELSE
  495. TRYRAC = .FALSE.
  496. END IF
  497. CALL SSTEMR( JOBZ, 'A', N, WORK( N+1 ), WORK, VL, VU, IL,
  498. $ IU, M, W, Z, LDZ, N, ISUPPZ, TRYRAC,
  499. $ WORK( 2*N+1 ), LWORK-2*N, IWORK, LIWORK, INFO )
  500. *
  501. END IF
  502. IF( INFO.EQ.0 ) THEN
  503. M = N
  504. GO TO 10
  505. END IF
  506. INFO = 0
  507. END IF
  508. *
  509. * Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN.
  510. *
  511. IF( WANTZ ) THEN
  512. ORDER = 'B'
  513. ELSE
  514. ORDER = 'E'
  515. END IF
  516. CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTOL, D, E, M,
  517. $ NSPLIT, W, IWORK( INDIBL ), IWORK( INDISP ), WORK,
  518. $ IWORK( INDIWO ), INFO )
  519. *
  520. IF( WANTZ ) THEN
  521. CALL SSTEIN( N, D, E, M, W, IWORK( INDIBL ), IWORK( INDISP ),
  522. $ Z, LDZ, WORK, IWORK( INDIWO ), IWORK( INDIFL ),
  523. $ INFO )
  524. END IF
  525. *
  526. * If matrix was scaled, then rescale eigenvalues appropriately.
  527. *
  528. 10 CONTINUE
  529. IF( ISCALE.EQ.1 ) THEN
  530. IF( INFO.EQ.0 ) THEN
  531. IMAX = M
  532. ELSE
  533. IMAX = INFO - 1
  534. END IF
  535. CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
  536. END IF
  537. *
  538. * If eigenvalues are not in order, then sort them, along with
  539. * eigenvectors.
  540. *
  541. IF( WANTZ ) THEN
  542. DO 30 J = 1, M - 1
  543. I = 0
  544. TMP1 = W( J )
  545. DO 20 JJ = J + 1, M
  546. IF( W( JJ ).LT.TMP1 ) THEN
  547. I = JJ
  548. TMP1 = W( JJ )
  549. END IF
  550. 20 CONTINUE
  551. *
  552. IF( I.NE.0 ) THEN
  553. W( I ) = W( J )
  554. W( J ) = TMP1
  555. CALL SSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
  556. END IF
  557. 30 CONTINUE
  558. END IF
  559. *
  560. * Causes problems with tests 19 & 20:
  561. * IF (wantz .and. INDEIG ) Z( 1,1) = Z(1,1) / 1.002 + .002
  562. *
  563. *
  564. WORK( 1 ) = LWMIN
  565. IWORK( 1 ) = LIWMIN
  566. RETURN
  567. *
  568. * End of SSTEVR
  569. *
  570. END