3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZHEGV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhegv.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhegv.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhegv.f">
21 * SUBROUTINE ZHEGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
22 * LWORK, RWORK, INFO )
24 * .. Scalar Arguments ..
25 * CHARACTER JOBZ, UPLO
26 * INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
28 * .. Array Arguments ..
29 * DOUBLE PRECISION RWORK( * ), W( * )
30 * COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
39 *> ZHEGV computes all the eigenvalues, and optionally, the eigenvectors
40 *> of a complex generalized Hermitian-definite eigenproblem, of the form
41 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
42 *> Here A and B are assumed to be Hermitian and B is also
52 *> Specifies the problem type to be solved:
53 *> = 1: A*x = (lambda)*B*x
54 *> = 2: A*B*x = (lambda)*x
55 *> = 3: B*A*x = (lambda)*x
60 *> JOBZ is CHARACTER*1
61 *> = 'N': Compute eigenvalues only;
62 *> = 'V': Compute eigenvalues and eigenvectors.
67 *> UPLO is CHARACTER*1
68 *> = 'U': Upper triangles of A and B are stored;
69 *> = 'L': Lower triangles of A and B are stored.
75 *> The order of the matrices A and B. N >= 0.
80 *> A is COMPLEX*16 array, dimension (LDA, N)
81 *> On entry, the Hermitian matrix A. If UPLO = 'U', the
82 *> leading N-by-N upper triangular part of A contains the
83 *> upper triangular part of the matrix A. If UPLO = 'L',
84 *> the leading N-by-N lower triangular part of A contains
85 *> the lower triangular part of the matrix A.
87 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
88 *> matrix Z of eigenvectors. The eigenvectors are normalized
90 *> if ITYPE = 1 or 2, Z**H*B*Z = I;
91 *> if ITYPE = 3, Z**H*inv(B)*Z = I.
92 *> If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
93 *> or the lower triangle (if UPLO='L') of A, including the
94 *> diagonal, is destroyed.
100 *> The leading dimension of the array A. LDA >= max(1,N).
105 *> B is COMPLEX*16 array, dimension (LDB, N)
106 *> On entry, the Hermitian positive definite matrix B.
107 *> If UPLO = 'U', the leading N-by-N upper triangular part of B
108 *> contains the upper triangular part of the matrix B.
109 *> If UPLO = 'L', the leading N-by-N lower triangular part of B
110 *> contains the lower triangular part of the matrix B.
112 *> On exit, if INFO <= N, the part of B containing the matrix is
113 *> overwritten by the triangular factor U or L from the Cholesky
114 *> factorization B = U**H*U or B = L*L**H.
120 *> The leading dimension of the array B. LDB >= max(1,N).
125 *> W is DOUBLE PRECISION array, dimension (N)
126 *> If INFO = 0, the eigenvalues in ascending order.
131 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
132 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
138 *> The length of the array WORK. LWORK >= max(1,2*N-1).
139 *> For optimal efficiency, LWORK >= (NB+1)*N,
140 *> where NB is the blocksize for ZHETRD returned by ILAENV.
142 *> If LWORK = -1, then a workspace query is assumed; the routine
143 *> only calculates the optimal size of the WORK array, returns
144 *> this value as the first entry of the WORK array, and no error
145 *> message related to LWORK is issued by XERBLA.
150 *> RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2))
156 *> = 0: successful exit
157 *> < 0: if INFO = -i, the i-th argument had an illegal value
158 *> > 0: ZPOTRF or ZHEEV returned an error code:
159 *> <= N: if INFO = i, ZHEEV failed to converge;
160 *> i off-diagonal elements of an intermediate
161 *> tridiagonal form did not converge to zero;
162 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading
163 *> minor of order i of B is not positive definite.
164 *> The factorization of B could not be completed and
165 *> no eigenvalues or eigenvectors were computed.
171 *> \author Univ. of Tennessee
172 *> \author Univ. of California Berkeley
173 *> \author Univ. of Colorado Denver
176 *> \date November 2015
178 *> \ingroup complex16HEeigen
180 * =====================================================================
181 SUBROUTINE ZHEGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
182 $ LWORK, RWORK, INFO )
184 * -- LAPACK driver routine (version 3.6.0) --
185 * -- LAPACK is a software package provided by Univ. of Tennessee, --
186 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
189 * .. Scalar Arguments ..
191 INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
193 * .. Array Arguments ..
194 DOUBLE PRECISION RWORK( * ), W( * )
195 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
198 * =====================================================================
202 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
204 * .. Local Scalars ..
205 LOGICAL LQUERY, UPPER, WANTZ
207 INTEGER LWKOPT, NB, NEIG
209 * .. External Functions ..
212 EXTERNAL LSAME, ILAENV
214 * .. External Subroutines ..
215 EXTERNAL XERBLA, ZHEEV, ZHEGST, ZPOTRF, ZTRMM, ZTRSM
217 * .. Intrinsic Functions ..
220 * .. Executable Statements ..
222 * Test the input parameters.
224 WANTZ = LSAME( JOBZ, 'V' )
225 UPPER = LSAME( UPLO, 'U' )
226 LQUERY = ( LWORK.EQ.-1 )
229 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
231 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
233 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
235 ELSE IF( N.LT.0 ) THEN
237 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
239 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
244 NB = ILAENV( 1, 'ZHETRD', UPLO, N, -1, -1, -1 )
245 LWKOPT = MAX( 1, ( NB + 1 )*N )
248 IF( LWORK.LT.MAX( 1, 2*N - 1 ) .AND. .NOT.LQUERY ) THEN
254 CALL XERBLA( 'ZHEGV ', -INFO )
256 ELSE IF( LQUERY ) THEN
260 * Quick return if possible
265 * Form a Cholesky factorization of B.
267 CALL ZPOTRF( UPLO, N, B, LDB, INFO )
273 * Transform problem to standard eigenvalue problem and solve.
275 CALL ZHEGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
276 CALL ZHEEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, RWORK, INFO )
280 * Backtransform eigenvectors to the original problem.
285 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
287 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
288 * backtransform eigenvectors: x = inv(L)**H *y or inv(U)*y
296 CALL ZTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,
299 ELSE IF( ITYPE.EQ.3 ) THEN
301 * For B*A*x=(lambda)*x;
302 * backtransform eigenvectors: x = L*y or U**H *y
310 CALL ZTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,