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.

chbevx.f 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. *> \brief <b> CHBEVX 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 CHBEVX + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chbevx.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chbevx.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chbevx.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CHBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
  22. * VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
  23. * IWORK, IFAIL, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER JOBZ, RANGE, UPLO
  27. * INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
  28. * REAL ABSTOL, VL, VU
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER IFAIL( * ), IWORK( * )
  32. * REAL RWORK( * ), W( * )
  33. * COMPLEX AB( LDAB, * ), Q( LDQ, * ), WORK( * ),
  34. * $ Z( LDZ, * )
  35. * ..
  36. *
  37. *
  38. *> \par Purpose:
  39. * =============
  40. *>
  41. *> \verbatim
  42. *>
  43. *> CHBEVX computes selected eigenvalues and, optionally, eigenvectors
  44. *> of a complex Hermitian band matrix A. Eigenvalues and eigenvectors
  45. *> can be selected by specifying either a range of values or a range of
  46. *> indices for the desired eigenvalues.
  47. *> \endverbatim
  48. *
  49. * Arguments:
  50. * ==========
  51. *
  52. *> \param[in] JOBZ
  53. *> \verbatim
  54. *> JOBZ is CHARACTER*1
  55. *> = 'N': Compute eigenvalues only;
  56. *> = 'V': Compute eigenvalues and eigenvectors.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] RANGE
  60. *> \verbatim
  61. *> RANGE is CHARACTER*1
  62. *> = 'A': all eigenvalues will be found;
  63. *> = 'V': all eigenvalues in the half-open interval (VL,VU]
  64. *> will be found;
  65. *> = 'I': the IL-th through IU-th eigenvalues will be found.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] UPLO
  69. *> \verbatim
  70. *> UPLO is CHARACTER*1
  71. *> = 'U': Upper triangle of A is stored;
  72. *> = 'L': Lower triangle of A is stored.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] N
  76. *> \verbatim
  77. *> N is INTEGER
  78. *> The order of the matrix A. N >= 0.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] KD
  82. *> \verbatim
  83. *> KD is INTEGER
  84. *> The number of superdiagonals of the matrix A if UPLO = 'U',
  85. *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  86. *> \endverbatim
  87. *>
  88. *> \param[in,out] AB
  89. *> \verbatim
  90. *> AB is COMPLEX array, dimension (LDAB, N)
  91. *> On entry, the upper or lower triangle of the Hermitian band
  92. *> matrix A, stored in the first KD+1 rows of the array. The
  93. *> j-th column of A is stored in the j-th column of the array AB
  94. *> as follows:
  95. *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  96. *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  97. *>
  98. *> On exit, AB is overwritten by values generated during the
  99. *> reduction to tridiagonal form.
  100. *> \endverbatim
  101. *>
  102. *> \param[in] LDAB
  103. *> \verbatim
  104. *> LDAB is INTEGER
  105. *> The leading dimension of the array AB. LDAB >= KD + 1.
  106. *> \endverbatim
  107. *>
  108. *> \param[out] Q
  109. *> \verbatim
  110. *> Q is COMPLEX array, dimension (LDQ, N)
  111. *> If JOBZ = 'V', the N-by-N unitary matrix used in the
  112. *> reduction to tridiagonal form.
  113. *> If JOBZ = 'N', the array Q is not referenced.
  114. *> \endverbatim
  115. *>
  116. *> \param[in] LDQ
  117. *> \verbatim
  118. *> LDQ is INTEGER
  119. *> The leading dimension of the array Q. If JOBZ = 'V', then
  120. *> LDQ >= max(1,N).
  121. *> \endverbatim
  122. *>
  123. *> \param[in] VL
  124. *> \verbatim
  125. *> VL is REAL
  126. *> If RANGE='V', the lower bound of the interval to
  127. *> be searched for eigenvalues. VL < VU.
  128. *> Not referenced if RANGE = 'A' or 'I'.
  129. *> \endverbatim
  130. *>
  131. *> \param[in] VU
  132. *> \verbatim
  133. *> VU is REAL
  134. *> If RANGE='V', the upper bound of the interval to
  135. *> be searched for eigenvalues. VL < VU.
  136. *> Not referenced if RANGE = 'A' or 'I'.
  137. *> \endverbatim
  138. *>
  139. *> \param[in] IL
  140. *> \verbatim
  141. *> IL is INTEGER
  142. *> If RANGE='I', the index of the
  143. *> smallest eigenvalue to be returned.
  144. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  145. *> Not referenced if RANGE = 'A' or 'V'.
  146. *> \endverbatim
  147. *>
  148. *> \param[in] IU
  149. *> \verbatim
  150. *> IU is INTEGER
  151. *> If RANGE='I', the index of the
  152. *> largest eigenvalue to be returned.
  153. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  154. *> Not referenced if RANGE = 'A' or 'V'.
  155. *> \endverbatim
  156. *>
  157. *> \param[in] ABSTOL
  158. *> \verbatim
  159. *> ABSTOL is REAL
  160. *> The absolute error tolerance for the eigenvalues.
  161. *> An approximate eigenvalue is accepted as converged
  162. *> when it is determined to lie in an interval [a,b]
  163. *> of width less than or equal to
  164. *>
  165. *> ABSTOL + EPS * max( |a|,|b| ) ,
  166. *>
  167. *> where EPS is the machine precision. If ABSTOL is less than
  168. *> or equal to zero, then EPS*|T| will be used in its place,
  169. *> where |T| is the 1-norm of the tridiagonal matrix obtained
  170. *> by reducing AB to tridiagonal form.
  171. *>
  172. *> Eigenvalues will be computed most accurately when ABSTOL is
  173. *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
  174. *> If this routine returns with INFO>0, indicating that some
  175. *> eigenvectors did not converge, try setting ABSTOL to
  176. *> 2*SLAMCH('S').
  177. *>
  178. *> See "Computing Small Singular Values of Bidiagonal Matrices
  179. *> with Guaranteed High Relative Accuracy," by Demmel and
  180. *> Kahan, LAPACK Working Note #3.
  181. *> \endverbatim
  182. *>
  183. *> \param[out] M
  184. *> \verbatim
  185. *> M is INTEGER
  186. *> The total number of eigenvalues found. 0 <= M <= N.
  187. *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  188. *> \endverbatim
  189. *>
  190. *> \param[out] W
  191. *> \verbatim
  192. *> W is REAL array, dimension (N)
  193. *> The first M elements contain the selected eigenvalues in
  194. *> ascending order.
  195. *> \endverbatim
  196. *>
  197. *> \param[out] Z
  198. *> \verbatim
  199. *> Z is COMPLEX array, dimension (LDZ, max(1,M))
  200. *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  201. *> contain the orthonormal eigenvectors of the matrix A
  202. *> corresponding to the selected eigenvalues, with the i-th
  203. *> column of Z holding the eigenvector associated with W(i).
  204. *> If an eigenvector fails to converge, then that column of Z
  205. *> contains the latest approximation to the eigenvector, and the
  206. *> index of the eigenvector is returned in IFAIL.
  207. *> If JOBZ = 'N', then Z is not referenced.
  208. *> Note: the user must ensure that at least max(1,M) columns are
  209. *> supplied in the array Z; if RANGE = 'V', the exact value of M
  210. *> is not known in advance and an upper bound must be used.
  211. *> \endverbatim
  212. *>
  213. *> \param[in] LDZ
  214. *> \verbatim
  215. *> LDZ is INTEGER
  216. *> The leading dimension of the array Z. LDZ >= 1, and if
  217. *> JOBZ = 'V', LDZ >= max(1,N).
  218. *> \endverbatim
  219. *>
  220. *> \param[out] WORK
  221. *> \verbatim
  222. *> WORK is COMPLEX array, dimension (N)
  223. *> \endverbatim
  224. *>
  225. *> \param[out] RWORK
  226. *> \verbatim
  227. *> RWORK is REAL array, dimension (7*N)
  228. *> \endverbatim
  229. *>
  230. *> \param[out] IWORK
  231. *> \verbatim
  232. *> IWORK is INTEGER array, dimension (5*N)
  233. *> \endverbatim
  234. *>
  235. *> \param[out] IFAIL
  236. *> \verbatim
  237. *> IFAIL is INTEGER array, dimension (N)
  238. *> If JOBZ = 'V', then if INFO = 0, the first M elements of
  239. *> IFAIL are zero. If INFO > 0, then IFAIL contains the
  240. *> indices of the eigenvectors that failed to converge.
  241. *> If JOBZ = 'N', then IFAIL is not referenced.
  242. *> \endverbatim
  243. *>
  244. *> \param[out] INFO
  245. *> \verbatim
  246. *> INFO is INTEGER
  247. *> = 0: successful exit
  248. *> < 0: if INFO = -i, the i-th argument had an illegal value
  249. *> > 0: if INFO = i, then i eigenvectors failed to converge.
  250. *> Their indices are stored in array IFAIL.
  251. *> \endverbatim
  252. *
  253. * Authors:
  254. * ========
  255. *
  256. *> \author Univ. of Tennessee
  257. *> \author Univ. of California Berkeley
  258. *> \author Univ. of Colorado Denver
  259. *> \author NAG Ltd.
  260. *
  261. *> \ingroup complexOTHEReigen
  262. *
  263. * =====================================================================
  264. SUBROUTINE CHBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
  265. $ VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
  266. $ IWORK, IFAIL, INFO )
  267. *
  268. * -- LAPACK driver routine --
  269. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  270. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  271. *
  272. * .. Scalar Arguments ..
  273. CHARACTER JOBZ, RANGE, UPLO
  274. INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
  275. REAL ABSTOL, VL, VU
  276. * ..
  277. * .. Array Arguments ..
  278. INTEGER IFAIL( * ), IWORK( * )
  279. REAL RWORK( * ), W( * )
  280. COMPLEX AB( LDAB, * ), Q( LDQ, * ), WORK( * ),
  281. $ Z( LDZ, * )
  282. * ..
  283. *
  284. * =====================================================================
  285. *
  286. * .. Parameters ..
  287. REAL ZERO, ONE
  288. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  289. COMPLEX CZERO, CONE
  290. PARAMETER ( CZERO = ( 0.0E0, 0.0E0 ),
  291. $ CONE = ( 1.0E0, 0.0E0 ) )
  292. * ..
  293. * .. Local Scalars ..
  294. LOGICAL ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ
  295. CHARACTER ORDER
  296. INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
  297. $ INDISP, INDIWK, INDRWK, INDWRK, ISCALE, ITMP1,
  298. $ J, JJ, NSPLIT
  299. REAL ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
  300. $ SIGMA, SMLNUM, TMP1, VLL, VUU
  301. COMPLEX CTMP1
  302. * ..
  303. * .. External Functions ..
  304. LOGICAL LSAME
  305. REAL CLANHB, SLAMCH
  306. EXTERNAL LSAME, CLANHB, SLAMCH
  307. * ..
  308. * .. External Subroutines ..
  309. EXTERNAL CCOPY, CGEMV, CHBTRD, CLACPY, CLASCL, CSTEIN,
  310. $ CSTEQR, CSWAP, SCOPY, SSCAL, SSTEBZ, SSTERF,
  311. $ XERBLA
  312. * ..
  313. * .. Intrinsic Functions ..
  314. INTRINSIC MAX, MIN, REAL, SQRT
  315. * ..
  316. * .. Executable Statements ..
  317. *
  318. * Test the input parameters.
  319. *
  320. WANTZ = LSAME( JOBZ, 'V' )
  321. ALLEIG = LSAME( RANGE, 'A' )
  322. VALEIG = LSAME( RANGE, 'V' )
  323. INDEIG = LSAME( RANGE, 'I' )
  324. LOWER = LSAME( UPLO, 'L' )
  325. *
  326. INFO = 0
  327. IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  328. INFO = -1
  329. ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
  330. INFO = -2
  331. ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
  332. INFO = -3
  333. ELSE IF( N.LT.0 ) THEN
  334. INFO = -4
  335. ELSE IF( KD.LT.0 ) THEN
  336. INFO = -5
  337. ELSE IF( LDAB.LT.KD+1 ) THEN
  338. INFO = -7
  339. ELSE IF( WANTZ .AND. LDQ.LT.MAX( 1, N ) ) THEN
  340. INFO = -9
  341. ELSE
  342. IF( VALEIG ) THEN
  343. IF( N.GT.0 .AND. VU.LE.VL )
  344. $ INFO = -11
  345. ELSE IF( INDEIG ) THEN
  346. IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
  347. INFO = -12
  348. ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
  349. INFO = -13
  350. END IF
  351. END IF
  352. END IF
  353. IF( INFO.EQ.0 ) THEN
  354. IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
  355. $ INFO = -18
  356. END IF
  357. *
  358. IF( INFO.NE.0 ) THEN
  359. CALL XERBLA( 'CHBEVX', -INFO )
  360. RETURN
  361. END IF
  362. *
  363. * Quick return if possible
  364. *
  365. M = 0
  366. IF( N.EQ.0 )
  367. $ RETURN
  368. *
  369. IF( N.EQ.1 ) THEN
  370. M = 1
  371. IF( LOWER ) THEN
  372. CTMP1 = AB( 1, 1 )
  373. ELSE
  374. CTMP1 = AB( KD+1, 1 )
  375. END IF
  376. TMP1 = REAL( CTMP1 )
  377. IF( VALEIG ) THEN
  378. IF( .NOT.( VL.LT.TMP1 .AND. VU.GE.TMP1 ) )
  379. $ M = 0
  380. END IF
  381. IF( M.EQ.1 ) THEN
  382. W( 1 ) = REAL( CTMP1 )
  383. IF( WANTZ )
  384. $ Z( 1, 1 ) = CONE
  385. END IF
  386. RETURN
  387. END IF
  388. *
  389. * Get machine constants.
  390. *
  391. SAFMIN = SLAMCH( 'Safe minimum' )
  392. EPS = SLAMCH( 'Precision' )
  393. SMLNUM = SAFMIN / EPS
  394. BIGNUM = ONE / SMLNUM
  395. RMIN = SQRT( SMLNUM )
  396. RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
  397. *
  398. * Scale matrix to allowable range, if necessary.
  399. *
  400. ISCALE = 0
  401. ABSTLL = ABSTOL
  402. IF ( VALEIG ) THEN
  403. VLL = VL
  404. VUU = VU
  405. ELSE
  406. VLL = ZERO
  407. VUU = ZERO
  408. ENDIF
  409. ANRM = CLANHB( 'M', UPLO, N, KD, AB, LDAB, RWORK )
  410. IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
  411. ISCALE = 1
  412. SIGMA = RMIN / ANRM
  413. ELSE IF( ANRM.GT.RMAX ) THEN
  414. ISCALE = 1
  415. SIGMA = RMAX / ANRM
  416. END IF
  417. IF( ISCALE.EQ.1 ) THEN
  418. IF( LOWER ) THEN
  419. CALL CLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
  420. ELSE
  421. CALL CLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
  422. END IF
  423. IF( ABSTOL.GT.0 )
  424. $ ABSTLL = ABSTOL*SIGMA
  425. IF( VALEIG ) THEN
  426. VLL = VL*SIGMA
  427. VUU = VU*SIGMA
  428. END IF
  429. END IF
  430. *
  431. * Call CHBTRD to reduce Hermitian band matrix to tridiagonal form.
  432. *
  433. INDD = 1
  434. INDE = INDD + N
  435. INDRWK = INDE + N
  436. INDWRK = 1
  437. CALL CHBTRD( JOBZ, UPLO, N, KD, AB, LDAB, RWORK( INDD ),
  438. $ RWORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO )
  439. *
  440. * If all eigenvalues are desired and ABSTOL is less than or equal
  441. * to zero, then call SSTERF or CSTEQR. If this fails for some
  442. * eigenvalue, then try SSTEBZ.
  443. *
  444. TEST = .FALSE.
  445. IF (INDEIG) THEN
  446. IF (IL.EQ.1 .AND. IU.EQ.N) THEN
  447. TEST = .TRUE.
  448. END IF
  449. END IF
  450. IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
  451. CALL SCOPY( N, RWORK( INDD ), 1, W, 1 )
  452. INDEE = INDRWK + 2*N
  453. IF( .NOT.WANTZ ) THEN
  454. CALL SCOPY( N-1, RWORK( INDE ), 1, RWORK( INDEE ), 1 )
  455. CALL SSTERF( N, W, RWORK( INDEE ), INFO )
  456. ELSE
  457. CALL CLACPY( 'A', N, N, Q, LDQ, Z, LDZ )
  458. CALL SCOPY( N-1, RWORK( INDE ), 1, RWORK( INDEE ), 1 )
  459. CALL CSTEQR( JOBZ, N, W, RWORK( INDEE ), Z, LDZ,
  460. $ RWORK( INDRWK ), INFO )
  461. IF( INFO.EQ.0 ) THEN
  462. DO 10 I = 1, N
  463. IFAIL( I ) = 0
  464. 10 CONTINUE
  465. END IF
  466. END IF
  467. IF( INFO.EQ.0 ) THEN
  468. M = N
  469. GO TO 30
  470. END IF
  471. INFO = 0
  472. END IF
  473. *
  474. * Otherwise, call SSTEBZ and, if eigenvectors are desired, CSTEIN.
  475. *
  476. IF( WANTZ ) THEN
  477. ORDER = 'B'
  478. ELSE
  479. ORDER = 'E'
  480. END IF
  481. INDIBL = 1
  482. INDISP = INDIBL + N
  483. INDIWK = INDISP + N
  484. CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
  485. $ RWORK( INDD ), RWORK( INDE ), M, NSPLIT, W,
  486. $ IWORK( INDIBL ), IWORK( INDISP ), RWORK( INDRWK ),
  487. $ IWORK( INDIWK ), INFO )
  488. *
  489. IF( WANTZ ) THEN
  490. CALL CSTEIN( N, RWORK( INDD ), RWORK( INDE ), M, W,
  491. $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
  492. $ RWORK( INDRWK ), IWORK( INDIWK ), IFAIL, INFO )
  493. *
  494. * Apply unitary matrix used in reduction to tridiagonal
  495. * form to eigenvectors returned by CSTEIN.
  496. *
  497. DO 20 J = 1, M
  498. CALL CCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 )
  499. CALL CGEMV( 'N', N, N, CONE, Q, LDQ, WORK, 1, CZERO,
  500. $ Z( 1, J ), 1 )
  501. 20 CONTINUE
  502. END IF
  503. *
  504. * If matrix was scaled, then rescale eigenvalues appropriately.
  505. *
  506. 30 CONTINUE
  507. IF( ISCALE.EQ.1 ) THEN
  508. IF( INFO.EQ.0 ) THEN
  509. IMAX = M
  510. ELSE
  511. IMAX = INFO - 1
  512. END IF
  513. CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
  514. END IF
  515. *
  516. * If eigenvalues are not in order, then sort them, along with
  517. * eigenvectors.
  518. *
  519. IF( WANTZ ) THEN
  520. DO 50 J = 1, M - 1
  521. I = 0
  522. TMP1 = W( J )
  523. DO 40 JJ = J + 1, M
  524. IF( W( JJ ).LT.TMP1 ) THEN
  525. I = JJ
  526. TMP1 = W( JJ )
  527. END IF
  528. 40 CONTINUE
  529. *
  530. IF( I.NE.0 ) THEN
  531. ITMP1 = IWORK( INDIBL+I-1 )
  532. W( I ) = W( J )
  533. IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
  534. W( J ) = TMP1
  535. IWORK( INDIBL+J-1 ) = ITMP1
  536. CALL CSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
  537. IF( INFO.NE.0 ) THEN
  538. ITMP1 = IFAIL( I )
  539. IFAIL( I ) = IFAIL( J )
  540. IFAIL( J ) = ITMP1
  541. END IF
  542. END IF
  543. 50 CONTINUE
  544. END IF
  545. *
  546. RETURN
  547. *
  548. * End of CHBEVX
  549. *
  550. END