001:       SUBROUTINE CHBGV( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, W, Z,
002:      $                  LDZ, WORK, RWORK, INFO )
003: *
004: *  -- LAPACK driver routine (version 3.2) --
005: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
006: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
007: *     November 2006
008: *
009: *     .. Scalar Arguments ..
010:       CHARACTER          JOBZ, UPLO
011:       INTEGER            INFO, KA, KB, LDAB, LDBB, LDZ, N
012: *     ..
013: *     .. Array Arguments ..
014:       REAL               RWORK( * ), W( * )
015:       COMPLEX            AB( LDAB, * ), BB( LDBB, * ), WORK( * ),
016:      $                   Z( LDZ, * )
017: *     ..
018: *
019: *  Purpose
020: *  =======
021: *
022: *  CHBGV computes all the eigenvalues, and optionally, the eigenvectors
023: *  of a complex generalized Hermitian-definite banded eigenproblem, of
024: *  the form A*x=(lambda)*B*x. Here A and B are assumed to be Hermitian
025: *  and banded, and B is also positive definite.
026: *
027: *  Arguments
028: *  =========
029: *
030: *  JOBZ    (input) CHARACTER*1
031: *          = 'N':  Compute eigenvalues only;
032: *          = 'V':  Compute eigenvalues and eigenvectors.
033: *
034: *  UPLO    (input) CHARACTER*1
035: *          = 'U':  Upper triangles of A and B are stored;
036: *          = 'L':  Lower triangles of A and B are stored.
037: *
038: *  N       (input) INTEGER
039: *          The order of the matrices A and B.  N >= 0.
040: *
041: *  KA      (input) INTEGER
042: *          The number of superdiagonals of the matrix A if UPLO = 'U',
043: *          or the number of subdiagonals if UPLO = 'L'. KA >= 0.
044: *
045: *  KB      (input) INTEGER
046: *          The number of superdiagonals of the matrix B if UPLO = 'U',
047: *          or the number of subdiagonals if UPLO = 'L'. KB >= 0.
048: *
049: *  AB      (input/output) COMPLEX array, dimension (LDAB, N)
050: *          On entry, the upper or lower triangle of the Hermitian band
051: *          matrix A, stored in the first ka+1 rows of the array.  The
052: *          j-th column of A is stored in the j-th column of the array AB
053: *          as follows:
054: *          if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
055: *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+ka).
056: *
057: *          On exit, the contents of AB are destroyed.
058: *
059: *  LDAB    (input) INTEGER
060: *          The leading dimension of the array AB.  LDAB >= KA+1.
061: *
062: *  BB      (input/output) COMPLEX array, dimension (LDBB, N)
063: *          On entry, the upper or lower triangle of the Hermitian band
064: *          matrix B, stored in the first kb+1 rows of the array.  The
065: *          j-th column of B is stored in the j-th column of the array BB
066: *          as follows:
067: *          if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
068: *          if UPLO = 'L', BB(1+i-j,j)    = B(i,j) for j<=i<=min(n,j+kb).
069: *
070: *          On exit, the factor S from the split Cholesky factorization
071: *          B = S**H*S, as returned by CPBSTF.
072: *
073: *  LDBB    (input) INTEGER
074: *          The leading dimension of the array BB.  LDBB >= KB+1.
075: *
076: *  W       (output) REAL array, dimension (N)
077: *          If INFO = 0, the eigenvalues in ascending order.
078: *
079: *  Z       (output) COMPLEX array, dimension (LDZ, N)
080: *          If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
081: *          eigenvectors, with the i-th column of Z holding the
082: *          eigenvector associated with W(i). The eigenvectors are
083: *          normalized so that Z**H*B*Z = I.
084: *          If JOBZ = 'N', then Z is not referenced.
085: *
086: *  LDZ     (input) INTEGER
087: *          The leading dimension of the array Z.  LDZ >= 1, and if
088: *          JOBZ = 'V', LDZ >= N.
089: *
090: *  WORK    (workspace) COMPLEX array, dimension (N)
091: *
092: *  RWORK   (workspace) REAL array, dimension (3*N)
093: *
094: *  INFO    (output) INTEGER
095: *          = 0:  successful exit
096: *          < 0:  if INFO = -i, the i-th argument had an illegal value
097: *          > 0:  if INFO = i, and i is:
098: *             <= N:  the algorithm failed to converge:
099: *                    i off-diagonal elements of an intermediate
100: *                    tridiagonal form did not converge to zero;
101: *             > N:   if INFO = N + i, for 1 <= i <= N, then CPBSTF
102: *                    returned INFO = i: B is not positive definite.
103: *                    The factorization of B could not be completed and
104: *                    no eigenvalues or eigenvectors were computed.
105: *
106: *  =====================================================================
107: *
108: *     .. Local Scalars ..
109:       LOGICAL            UPPER, WANTZ
110:       CHARACTER          VECT
111:       INTEGER            IINFO, INDE, INDWRK
112: *     ..
113: *     .. External Functions ..
114:       LOGICAL            LSAME
115:       EXTERNAL           LSAME
116: *     ..
117: *     .. External Subroutines ..
118:       EXTERNAL           CHBGST, CHBTRD, CPBSTF, CSTEQR, SSTERF, XERBLA
119: *     ..
120: *     .. Executable Statements ..
121: *
122: *     Test the input parameters.
123: *
124:       WANTZ = LSAME( JOBZ, 'V' )
125:       UPPER = LSAME( UPLO, 'U' )
126: *
127:       INFO = 0
128:       IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
129:          INFO = -1
130:       ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
131:          INFO = -2
132:       ELSE IF( N.LT.0 ) THEN
133:          INFO = -3
134:       ELSE IF( KA.LT.0 ) THEN
135:          INFO = -4
136:       ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN
137:          INFO = -5
138:       ELSE IF( LDAB.LT.KA+1 ) THEN
139:          INFO = -7
140:       ELSE IF( LDBB.LT.KB+1 ) THEN
141:          INFO = -9
142:       ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
143:          INFO = -12
144:       END IF
145:       IF( INFO.NE.0 ) THEN
146:          CALL XERBLA( 'CHBGV ', -INFO )
147:          RETURN
148:       END IF
149: *
150: *     Quick return if possible
151: *
152:       IF( N.EQ.0 )
153:      $   RETURN
154: *
155: *     Form a split Cholesky factorization of B.
156: *
157:       CALL CPBSTF( UPLO, N, KB, BB, LDBB, INFO )
158:       IF( INFO.NE.0 ) THEN
159:          INFO = N + INFO
160:          RETURN
161:       END IF
162: *
163: *     Transform problem to standard eigenvalue problem.
164: *
165:       INDE = 1
166:       INDWRK = INDE + N
167:       CALL CHBGST( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, Z, LDZ,
168:      $             WORK, RWORK( INDWRK ), IINFO )
169: *
170: *     Reduce to tridiagonal form.
171: *
172:       IF( WANTZ ) THEN
173:          VECT = 'U'
174:       ELSE
175:          VECT = 'N'
176:       END IF
177:       CALL CHBTRD( VECT, UPLO, N, KA, AB, LDAB, W, RWORK( INDE ), Z,
178:      $             LDZ, WORK, IINFO )
179: *
180: *     For eigenvalues only, call SSTERF.  For eigenvectors, call CSTEQR.
181: *
182:       IF( .NOT.WANTZ ) THEN
183:          CALL SSTERF( N, W, RWORK( INDE ), INFO )
184:       ELSE
185:          CALL CSTEQR( JOBZ, N, W, RWORK( INDE ), Z, LDZ,
186:      $                RWORK( INDWRK ), INFO )
187:       END IF
188:       RETURN
189: *
190: *     End of CHBGV
191: *
192:       END
193: