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