Annotation of rpl/lapack/lapack/zhbgvx.f, revision 1.5
1.1 bertrand 1: SUBROUTINE ZHBGVX( JOBZ, RANGE, UPLO, N, KA, KB, AB, LDAB, BB,
2: $ LDBB, Q, LDQ, VL, VU, IL, IU, ABSTOL, M, W, Z,
3: $ LDZ, WORK, RWORK, IWORK, IFAIL, INFO )
4: *
5: * -- LAPACK driver routine (version 3.2) --
6: * -- LAPACK is a software package provided by Univ. of Tennessee, --
7: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
8: * November 2006
9: *
10: * .. Scalar Arguments ..
11: CHARACTER JOBZ, RANGE, UPLO
12: INTEGER IL, INFO, IU, KA, KB, LDAB, LDBB, LDQ, LDZ, M,
13: $ N
14: DOUBLE PRECISION ABSTOL, VL, VU
15: * ..
16: * .. Array Arguments ..
17: INTEGER IFAIL( * ), IWORK( * )
18: DOUBLE PRECISION RWORK( * ), W( * )
19: COMPLEX*16 AB( LDAB, * ), BB( LDBB, * ), Q( LDQ, * ),
20: $ WORK( * ), Z( LDZ, * )
21: * ..
22: *
23: * Purpose
24: * =======
25: *
26: * ZHBGVX computes all the eigenvalues, and optionally, the eigenvectors
27: * of a complex generalized Hermitian-definite banded eigenproblem, of
28: * the form A*x=(lambda)*B*x. Here A and B are assumed to be Hermitian
29: * and banded, and B is also positive definite. Eigenvalues and
30: * eigenvectors can be selected by specifying either all eigenvalues,
31: * a range of values or a range of indices for the desired eigenvalues.
32: *
33: * Arguments
34: * =========
35: *
36: * JOBZ (input) CHARACTER*1
37: * = 'N': Compute eigenvalues only;
38: * = 'V': Compute eigenvalues and eigenvectors.
39: *
40: * RANGE (input) CHARACTER*1
41: * = 'A': all eigenvalues will be found;
42: * = 'V': all eigenvalues in the half-open interval (VL,VU]
43: * will be found;
44: * = 'I': the IL-th through IU-th eigenvalues will be found.
45: *
46: * UPLO (input) CHARACTER*1
47: * = 'U': Upper triangles of A and B are stored;
48: * = 'L': Lower triangles of A and B are stored.
49: *
50: * N (input) INTEGER
51: * The order of the matrices A and B. N >= 0.
52: *
53: * KA (input) INTEGER
54: * The number of superdiagonals of the matrix A if UPLO = 'U',
55: * or the number of subdiagonals if UPLO = 'L'. KA >= 0.
56: *
57: * KB (input) INTEGER
58: * The number of superdiagonals of the matrix B if UPLO = 'U',
59: * or the number of subdiagonals if UPLO = 'L'. KB >= 0.
60: *
61: * AB (input/output) COMPLEX*16 array, dimension (LDAB, N)
62: * On entry, the upper or lower triangle of the Hermitian band
63: * matrix A, stored in the first ka+1 rows of the array. The
64: * j-th column of A is stored in the j-th column of the array AB
65: * as follows:
66: * if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
67: * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
68: *
69: * On exit, the contents of AB are destroyed.
70: *
71: * LDAB (input) INTEGER
72: * The leading dimension of the array AB. LDAB >= KA+1.
73: *
74: * BB (input/output) COMPLEX*16 array, dimension (LDBB, N)
75: * On entry, the upper or lower triangle of the Hermitian band
76: * matrix B, stored in the first kb+1 rows of the array. The
77: * j-th column of B is stored in the j-th column of the array BB
78: * as follows:
79: * if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
80: * if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb).
81: *
82: * On exit, the factor S from the split Cholesky factorization
83: * B = S**H*S, as returned by ZPBSTF.
84: *
85: * LDBB (input) INTEGER
86: * The leading dimension of the array BB. LDBB >= KB+1.
87: *
88: * Q (output) COMPLEX*16 array, dimension (LDQ, N)
89: * If JOBZ = 'V', the n-by-n matrix used in the reduction of
90: * A*x = (lambda)*B*x to standard form, i.e. C*x = (lambda)*x,
91: * and consequently C to tridiagonal form.
92: * If JOBZ = 'N', the array Q is not referenced.
93: *
94: * LDQ (input) INTEGER
95: * The leading dimension of the array Q. If JOBZ = 'N',
96: * LDQ >= 1. If JOBZ = 'V', LDQ >= max(1,N).
97: *
98: * VL (input) DOUBLE PRECISION
99: * VU (input) DOUBLE PRECISION
100: * If RANGE='V', the lower and upper bounds of the interval to
101: * be searched for eigenvalues. VL < VU.
102: * Not referenced if RANGE = 'A' or 'I'.
103: *
104: * IL (input) INTEGER
105: * IU (input) INTEGER
106: * If RANGE='I', the indices (in ascending order) of the
107: * smallest and largest eigenvalues to be returned.
108: * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
109: * Not referenced if RANGE = 'A' or 'V'.
110: *
111: * ABSTOL (input) DOUBLE PRECISION
112: * The absolute error tolerance for the eigenvalues.
113: * An approximate eigenvalue is accepted as converged
114: * when it is determined to lie in an interval [a,b]
115: * of width less than or equal to
116: *
117: * ABSTOL + EPS * max( |a|,|b| ) ,
118: *
119: * where EPS is the machine precision. If ABSTOL is less than
120: * or equal to zero, then EPS*|T| will be used in its place,
121: * where |T| is the 1-norm of the tridiagonal matrix obtained
122: * by reducing AP to tridiagonal form.
123: *
124: * Eigenvalues will be computed most accurately when ABSTOL is
125: * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
126: * If this routine returns with INFO>0, indicating that some
127: * eigenvectors did not converge, try setting ABSTOL to
128: * 2*DLAMCH('S').
129: *
130: * M (output) INTEGER
131: * The total number of eigenvalues found. 0 <= M <= N.
132: * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
133: *
134: * W (output) DOUBLE PRECISION array, dimension (N)
135: * If INFO = 0, the eigenvalues in ascending order.
136: *
137: * Z (output) COMPLEX*16 array, dimension (LDZ, N)
138: * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
139: * eigenvectors, with the i-th column of Z holding the
140: * eigenvector associated with W(i). The eigenvectors are
141: * normalized so that Z**H*B*Z = I.
142: * If JOBZ = 'N', then Z is not referenced.
143: *
144: * LDZ (input) INTEGER
145: * The leading dimension of the array Z. LDZ >= 1, and if
146: * JOBZ = 'V', LDZ >= N.
147: *
148: * WORK (workspace) COMPLEX*16 array, dimension (N)
149: *
150: * RWORK (workspace) DOUBLE PRECISION array, dimension (7*N)
151: *
152: * IWORK (workspace) INTEGER array, dimension (5*N)
153: *
154: * IFAIL (output) INTEGER array, dimension (N)
155: * If JOBZ = 'V', then if INFO = 0, the first M elements of
156: * IFAIL are zero. If INFO > 0, then IFAIL contains the
157: * indices of the eigenvectors that failed to converge.
158: * If JOBZ = 'N', then IFAIL is not referenced.
159: *
160: * INFO (output) INTEGER
161: * = 0: successful exit
162: * < 0: if INFO = -i, the i-th argument had an illegal value
163: * > 0: if INFO = i, and i is:
164: * <= N: then i eigenvectors failed to converge. Their
165: * indices are stored in array IFAIL.
166: * > N: if INFO = N + i, for 1 <= i <= N, then ZPBSTF
167: * returned INFO = i: B is not positive definite.
168: * The factorization of B could not be completed and
169: * no eigenvalues or eigenvectors were computed.
170: *
171: * Further Details
172: * ===============
173: *
174: * Based on contributions by
175: * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
176: *
177: * =====================================================================
178: *
179: * .. Parameters ..
180: DOUBLE PRECISION ZERO
181: PARAMETER ( ZERO = 0.0D+0 )
182: COMPLEX*16 CZERO, CONE
183: PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ),
184: $ CONE = ( 1.0D+0, 0.0D+0 ) )
185: * ..
186: * .. Local Scalars ..
187: LOGICAL ALLEIG, INDEIG, TEST, UPPER, VALEIG, WANTZ
188: CHARACTER ORDER, VECT
189: INTEGER I, IINFO, INDD, INDE, INDEE, INDIBL, INDISP,
190: $ INDIWK, INDRWK, INDWRK, ITMP1, J, JJ, NSPLIT
191: DOUBLE PRECISION TMP1
192: * ..
193: * .. External Functions ..
194: LOGICAL LSAME
195: EXTERNAL LSAME
196: * ..
197: * .. External Subroutines ..
198: EXTERNAL DCOPY, DSTEBZ, DSTERF, XERBLA, ZCOPY, ZGEMV,
199: $ ZHBGST, ZHBTRD, ZLACPY, ZPBSTF, ZSTEIN, ZSTEQR,
200: $ ZSWAP
201: * ..
202: * .. Intrinsic Functions ..
203: INTRINSIC MIN
204: * ..
205: * .. Executable Statements ..
206: *
207: * Test the input parameters.
208: *
209: WANTZ = LSAME( JOBZ, 'V' )
210: UPPER = LSAME( UPLO, 'U' )
211: ALLEIG = LSAME( RANGE, 'A' )
212: VALEIG = LSAME( RANGE, 'V' )
213: INDEIG = LSAME( RANGE, 'I' )
214: *
215: INFO = 0
216: IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
217: INFO = -1
218: ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
219: INFO = -2
220: ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
221: INFO = -3
222: ELSE IF( N.LT.0 ) THEN
223: INFO = -4
224: ELSE IF( KA.LT.0 ) THEN
225: INFO = -5
226: ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN
227: INFO = -6
228: ELSE IF( LDAB.LT.KA+1 ) THEN
229: INFO = -8
230: ELSE IF( LDBB.LT.KB+1 ) THEN
231: INFO = -10
232: ELSE IF( LDQ.LT.1 .OR. ( WANTZ .AND. LDQ.LT.N ) ) THEN
233: INFO = -12
234: ELSE
235: IF( VALEIG ) THEN
236: IF( N.GT.0 .AND. VU.LE.VL )
237: $ INFO = -14
238: ELSE IF( INDEIG ) THEN
239: IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
240: INFO = -15
241: ELSE IF ( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
242: INFO = -16
243: END IF
244: END IF
245: END IF
246: IF( INFO.EQ.0) THEN
247: IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
248: INFO = -21
249: END IF
250: END IF
251: *
252: IF( INFO.NE.0 ) THEN
253: CALL XERBLA( 'ZHBGVX', -INFO )
254: RETURN
255: END IF
256: *
257: * Quick return if possible
258: *
259: M = 0
260: IF( N.EQ.0 )
261: $ RETURN
262: *
263: * Form a split Cholesky factorization of B.
264: *
265: CALL ZPBSTF( UPLO, N, KB, BB, LDBB, INFO )
266: IF( INFO.NE.0 ) THEN
267: INFO = N + INFO
268: RETURN
269: END IF
270: *
271: * Transform problem to standard eigenvalue problem.
272: *
273: CALL ZHBGST( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, Q, LDQ,
274: $ WORK, RWORK, IINFO )
275: *
276: * Solve the standard eigenvalue problem.
277: * Reduce Hermitian band matrix to tridiagonal form.
278: *
279: INDD = 1
280: INDE = INDD + N
281: INDRWK = INDE + N
282: INDWRK = 1
283: IF( WANTZ ) THEN
284: VECT = 'U'
285: ELSE
286: VECT = 'N'
287: END IF
288: CALL ZHBTRD( VECT, UPLO, N, KA, AB, LDAB, RWORK( INDD ),
289: $ RWORK( INDE ), Q, LDQ, WORK( INDWRK ), IINFO )
290: *
291: * If all eigenvalues are desired and ABSTOL is less than or equal
292: * to zero, then call DSTERF or ZSTEQR. If this fails for some
293: * eigenvalue, then try DSTEBZ.
294: *
295: TEST = .FALSE.
296: IF( INDEIG ) THEN
297: IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
298: TEST = .TRUE.
299: END IF
300: END IF
301: IF( ( ALLEIG .OR. TEST ) .AND. ( ABSTOL.LE.ZERO ) ) THEN
302: CALL DCOPY( N, RWORK( INDD ), 1, W, 1 )
303: INDEE = INDRWK + 2*N
304: CALL DCOPY( N-1, RWORK( INDE ), 1, RWORK( INDEE ), 1 )
305: IF( .NOT.WANTZ ) THEN
306: CALL DSTERF( N, W, RWORK( INDEE ), INFO )
307: ELSE
308: CALL ZLACPY( 'A', N, N, Q, LDQ, Z, LDZ )
309: CALL ZSTEQR( JOBZ, N, W, RWORK( INDEE ), Z, LDZ,
310: $ RWORK( INDRWK ), INFO )
311: IF( INFO.EQ.0 ) THEN
312: DO 10 I = 1, N
313: IFAIL( I ) = 0
314: 10 CONTINUE
315: END IF
316: END IF
317: IF( INFO.EQ.0 ) THEN
318: M = N
319: GO TO 30
320: END IF
321: INFO = 0
322: END IF
323: *
324: * Otherwise, call DSTEBZ and, if eigenvectors are desired,
325: * call ZSTEIN.
326: *
327: IF( WANTZ ) THEN
328: ORDER = 'B'
329: ELSE
330: ORDER = 'E'
331: END IF
332: INDIBL = 1
333: INDISP = INDIBL + N
334: INDIWK = INDISP + N
335: CALL DSTEBZ( RANGE, ORDER, N, VL, VU, IL, IU, ABSTOL,
336: $ RWORK( INDD ), RWORK( INDE ), M, NSPLIT, W,
337: $ IWORK( INDIBL ), IWORK( INDISP ), RWORK( INDRWK ),
338: $ IWORK( INDIWK ), INFO )
339: *
340: IF( WANTZ ) THEN
341: CALL ZSTEIN( N, RWORK( INDD ), RWORK( INDE ), M, W,
342: $ IWORK( INDIBL ), IWORK( INDISP ), Z, LDZ,
343: $ RWORK( INDRWK ), IWORK( INDIWK ), IFAIL, INFO )
344: *
345: * Apply unitary matrix used in reduction to tridiagonal
346: * form to eigenvectors returned by ZSTEIN.
347: *
348: DO 20 J = 1, M
349: CALL ZCOPY( N, Z( 1, J ), 1, WORK( 1 ), 1 )
350: CALL ZGEMV( 'N', N, N, CONE, Q, LDQ, WORK, 1, CZERO,
351: $ Z( 1, J ), 1 )
352: 20 CONTINUE
353: END IF
354: *
355: 30 CONTINUE
356: *
357: * If eigenvalues are not in order, then sort them, along with
358: * eigenvectors.
359: *
360: IF( WANTZ ) THEN
361: DO 50 J = 1, M - 1
362: I = 0
363: TMP1 = W( J )
364: DO 40 JJ = J + 1, M
365: IF( W( JJ ).LT.TMP1 ) THEN
366: I = JJ
367: TMP1 = W( JJ )
368: END IF
369: 40 CONTINUE
370: *
371: IF( I.NE.0 ) THEN
372: ITMP1 = IWORK( INDIBL+I-1 )
373: W( I ) = W( J )
374: IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
375: W( J ) = TMP1
376: IWORK( INDIBL+J-1 ) = ITMP1
377: CALL ZSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
378: IF( INFO.NE.0 ) THEN
379: ITMP1 = IFAIL( I )
380: IFAIL( I ) = IFAIL( J )
381: IFAIL( J ) = ITMP1
382: END IF
383: END IF
384: 50 CONTINUE
385: END IF
386: *
387: RETURN
388: *
389: * End of ZHBGVX
390: *
391: END
CVSweb interface <joel.bertrand@systella.fr>