1 *> \brief <b> CHBEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CHBEVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chbevx.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chbevx.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chbevx.f">
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 )
25 * .. Scalar Arguments ..
26 * CHARACTER JOBZ, RANGE, UPLO
27 * INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
30 * .. Array Arguments ..
31 * INTEGER IFAIL( * ), IWORK( * )
32 * REAL RWORK( * ), W( * )
33 * COMPLEX AB( LDAB, * ), Q( LDQ, * ), WORK( * ),
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.
54 *> JOBZ is CHARACTER*1
55 *> = 'N': Compute eigenvalues only;
56 *> = 'V': Compute eigenvalues and eigenvectors.
61 *> RANGE is CHARACTER*1
62 *> = 'A': all eigenvalues will be found;
63 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
65 *> = 'I': the IL-th through IU-th eigenvalues will be found.
70 *> UPLO is CHARACTER*1
71 *> = 'U': Upper triangle of A is stored;
72 *> = 'L': Lower triangle of A is stored.
78 *> The order of the matrix A. N >= 0.
84 *> The number of superdiagonals of the matrix A if UPLO = 'U',
85 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
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
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).
98 *> On exit, AB is overwritten by values generated during the
99 *> reduction to tridiagonal form.
105 *> The leading dimension of the array AB. LDAB >= KD + 1.
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.
119 *> The leading dimension of the array Q. If JOBZ = 'V', then
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'.
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'.
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'.
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'.
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
165 *> ABSTOL + EPS * max( |a|,|b| ) ,
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.
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
178 *> See "Computing Small Singular Values of Bidiagonal Matrices
179 *> with Guaranteed High Relative Accuracy," by Demmel and
180 *> Kahan, LAPACK Working Note #3.
186 *> The total number of eigenvalues found. 0 <= M <= N.
187 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
192 *> W is REAL array, dimension (N)
193 *> The first M elements contain the selected eigenvalues in
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.
216 *> The leading dimension of the array Z. LDZ >= 1, and if
217 *> JOBZ = 'V', LDZ >= max(1,N).
222 *> WORK is COMPLEX array, dimension (N)
227 *> RWORK is REAL array, dimension (7*N)
232 *> IWORK is INTEGER array, dimension (5*N)
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.
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.
256 *> \author Univ. of Tennessee
257 *> \author Univ. of California Berkeley
258 *> \author Univ. of Colorado Denver
263 *> \ingroup complexOTHEReigen
265 * =====================================================================
266 SUBROUTINE CHBEVX( JOBZ, RANGE, UPLO, N, KD, AB, LDAB, Q, LDQ, VL,
267 $ VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
268 $ IWORK, IFAIL, INFO )
270 * -- LAPACK driver routine (version 3.6.1) --
271 * -- LAPACK is a software package provided by Univ. of Tennessee, --
272 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
275 * .. Scalar Arguments ..
276 CHARACTER JOBZ, RANGE, UPLO
277 INTEGER IL, INFO, IU, KD, LDAB, LDQ, LDZ, M, N
280 * .. Array Arguments ..
281 INTEGER IFAIL( * ), IWORK( * )
282 REAL RWORK( * ), W( * )
283 COMPLEX AB( LDAB, * ), Q( LDQ, * ), WORK( * ),
287 * =====================================================================
291 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
293 PARAMETER ( CZERO = ( 0.0E0, 0.0E0 ),
294 $ CONE = ( 1.0E0, 0.0E0 ) )
296 * .. Local Scalars ..
297 LOGICAL ALLEIG, INDEIG, LOWER, TEST, VALEIG, WANTZ
299 INTEGER I, IINFO, IMAX, INDD, INDE, INDEE, INDIBL,
300 $ INDISP, INDIWK, INDRWK, INDWRK, ISCALE, ITMP1,
302 REAL ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN,
303 $ SIGMA, SMLNUM, TMP1, VLL, VUU
306 * .. External Functions ..
309 EXTERNAL LSAME, CLANHB, SLAMCH
311 * .. External Subroutines ..
312 EXTERNAL CCOPY, CGEMV, CHBTRD, CLACPY, CLASCL, CSTEIN,
313 $ CSTEQR, CSWAP, SCOPY, SSCAL, SSTEBZ, SSTERF,
316 * .. Intrinsic Functions ..
317 INTRINSIC MAX, MIN, REAL, SQRT
319 * .. Executable Statements ..
321 * Test the input parameters.
323 WANTZ = LSAME( JOBZ, 'V' )
324 ALLEIG = LSAME( RANGE, 'A' )
325 VALEIG = LSAME( RANGE, 'V' )
326 INDEIG = LSAME( RANGE, 'I' )
327 LOWER = LSAME( UPLO, 'L' )
330 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
332 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
334 ELSE IF( .NOT.( LOWER .OR. LSAME( UPLO, 'U' ) ) ) THEN
336 ELSE IF( N.LT.0 ) THEN
338 ELSE IF( KD.LT.0 ) THEN
340 ELSE IF( LDAB.LT.KD+1 ) THEN
342 ELSE IF( WANTZ .AND. LDQ.LT.MAX( 1, N ) ) THEN
346 IF( N.GT.0 .AND. VU.LE.VL )
348 ELSE IF( INDEIG ) THEN
349 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
351 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
357 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
362 CALL XERBLA( 'CHBEVX', -INFO )
366 * Quick return if possible
377 CTMP1 = AB( KD+1, 1 )
381 IF( .NOT.( VL.LT.TMP1 .AND. VU.GE.TMP1 ) )
392 * Get machine constants.
394 SAFMIN = SLAMCH( 'Safe minimum' )
395 EPS = SLAMCH( 'Precision' )
396 SMLNUM = SAFMIN / EPS
397 BIGNUM = ONE / SMLNUM
398 RMIN = SQRT( SMLNUM )
399 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
401 * Scale matrix to allowable range, if necessary.
412 ANRM = CLANHB( 'M', UPLO, N, KD, AB, LDAB, RWORK )
413 IF( ANRM.GT.ZERO .AND. ANRM.LT.RMIN ) THEN
416 ELSE IF( ANRM.GT.RMAX ) THEN
420 IF( ISCALE.EQ.1 ) THEN
422 CALL CLASCL( 'B', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
424 CALL CLASCL( 'Q', KD, KD, ONE, SIGMA, N, N, AB, LDAB, INFO )
427 $ ABSTLL = ABSTOL*SIGMA
434 * Call CHBTRD to reduce Hermitian band matrix to tridiagonal form.
440 CALL CHBTRD( JOBZ, UPLO, N, KD, AB, LDAB, RWORK( INDD ),
441 $ RWORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO )
443 * If all eigenvalues are desired and ABSTOL is less than or equal
444 * to zero, then call SSTERF or CSTEQR. If this fails for some
445 * eigenvalue, then try SSTEBZ.
449 IF (IL.EQ.1 .AND. IU.EQ.N) THEN
453 IF ((ALLEIG .OR. TEST) .AND. (ABSTOL.LE.ZERO)) THEN
454 CALL SCOPY( N, RWORK( INDD ), 1, W, 1 )
456 IF( .NOT.WANTZ ) THEN
457 CALL SCOPY( N-1, RWORK( INDE ), 1, RWORK( INDEE ), 1 )
458 CALL SSTERF( N, W, RWORK( INDEE ), INFO )
460 CALL CLACPY( 'A', N, N, Q, LDQ, Z, LDZ )
461 CALL SCOPY( N-1, RWORK( INDE ), 1, RWORK( INDEE ), 1 )
462 CALL CSTEQR( JOBZ, N, W, RWORK( INDEE ), Z, LDZ,
463 $ RWORK( INDRWK ), INFO )
477 * Otherwise, call SSTEBZ and, if eigenvectors are desired, CSTEIN.
487 CALL SSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTLL,
488 $ RWORK( INDD ), RWORK( INDE ), M, NSPLIT, W,
489 $ IWORK( INDIBL ), IWORK( INDISP ), RWORK( INDRWK ),
490 $ IWORK( INDIWK ), INFO )
493 CALL CSTEIN( N, RWORK( INDD ), RWORK( INDE ), M, W,
494 $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
495 $ RWORK( INDRWK ), IWORK( INDIWK ), IFAIL, INFO )
497 * Apply unitary matrix used in reduction to tridiagonal
498 * form to eigenvectors returned by CSTEIN.
501 CALL CCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 )
502 CALL CGEMV( 'N', N, N, CONE, Q, LDQ, WORK, 1, CZERO,
507 * If matrix was scaled, then rescale eigenvalues appropriately.
510 IF( ISCALE.EQ.1 ) THEN
516 CALL SSCAL( IMAX, ONE / SIGMA, W, 1 )
519 * If eigenvalues are not in order, then sort them, along with
527 IF( W( JJ ).LT.TMP1 ) THEN
534 ITMP1 = IWORK( INDIBL+I-1 )
536 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
538 IWORK( INDIBL+J-1 ) = ITMP1
539 CALL CSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
542 IFAIL( I ) = IFAIL( J )