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