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