LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zhegv.f
Go to the documentation of this file.
1*> \brief \b ZHEGV
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHEGV + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhegv.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhegv.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhegv.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHEGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
20* LWORK, RWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ, UPLO
24* INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
25* ..
26* .. Array Arguments ..
27* DOUBLE PRECISION RWORK( * ), W( * )
28* COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> ZHEGV computes all the eigenvalues, and optionally, the eigenvectors
38*> of a complex generalized Hermitian-definite eigenproblem, of the form
39*> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
40*> Here A and B are assumed to be Hermitian and B is also
41*> positive definite.
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] ITYPE
48*> \verbatim
49*> ITYPE is INTEGER
50*> Specifies the problem type to be solved:
51*> = 1: A*x = (lambda)*B*x
52*> = 2: A*B*x = (lambda)*x
53*> = 3: B*A*x = (lambda)*x
54*> \endverbatim
55*>
56*> \param[in] JOBZ
57*> \verbatim
58*> JOBZ is CHARACTER*1
59*> = 'N': Compute eigenvalues only;
60*> = 'V': Compute eigenvalues and eigenvectors.
61*> \endverbatim
62*>
63*> \param[in] UPLO
64*> \verbatim
65*> UPLO is CHARACTER*1
66*> = 'U': Upper triangles of A and B are stored;
67*> = 'L': Lower triangles of A and B are stored.
68*> \endverbatim
69*>
70*> \param[in] N
71*> \verbatim
72*> N is INTEGER
73*> The order of the matrices A and B. N >= 0.
74*> \endverbatim
75*>
76*> \param[in,out] A
77*> \verbatim
78*> A is COMPLEX*16 array, dimension (LDA, N)
79*> On entry, the Hermitian matrix A. If UPLO = 'U', the
80*> leading N-by-N upper triangular part of A contains the
81*> upper triangular part of the matrix A. If UPLO = 'L',
82*> the leading N-by-N lower triangular part of A contains
83*> the lower triangular part of the matrix A.
84*>
85*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
86*> matrix Z of eigenvectors. The eigenvectors are normalized
87*> as follows:
88*> if ITYPE = 1 or 2, Z**H*B*Z = I;
89*> if ITYPE = 3, Z**H*inv(B)*Z = I.
90*> If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
91*> or the lower triangle (if UPLO='L') of A, including the
92*> diagonal, is destroyed.
93*> \endverbatim
94*>
95*> \param[in] LDA
96*> \verbatim
97*> LDA is INTEGER
98*> The leading dimension of the array A. LDA >= max(1,N).
99*> \endverbatim
100*>
101*> \param[in,out] B
102*> \verbatim
103*> B is COMPLEX*16 array, dimension (LDB, N)
104*> On entry, the Hermitian positive definite matrix B.
105*> If UPLO = 'U', the leading N-by-N upper triangular part of B
106*> contains the upper triangular part of the matrix B.
107*> If UPLO = 'L', the leading N-by-N lower triangular part of B
108*> contains the lower triangular part of the matrix B.
109*>
110*> On exit, if INFO <= N, the part of B containing the matrix is
111*> overwritten by the triangular factor U or L from the Cholesky
112*> factorization B = U**H*U or B = L*L**H.
113*> \endverbatim
114*>
115*> \param[in] LDB
116*> \verbatim
117*> LDB is INTEGER
118*> The leading dimension of the array B. LDB >= max(1,N).
119*> \endverbatim
120*>
121*> \param[out] W
122*> \verbatim
123*> W is DOUBLE PRECISION array, dimension (N)
124*> If INFO = 0, the eigenvalues in ascending order.
125*> \endverbatim
126*>
127*> \param[out] WORK
128*> \verbatim
129*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
130*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
131*> \endverbatim
132*>
133*> \param[in] LWORK
134*> \verbatim
135*> LWORK is INTEGER
136*> The length of the array WORK. LWORK >= max(1,2*N-1).
137*> For optimal efficiency, LWORK >= (NB+1)*N,
138*> where NB is the blocksize for ZHETRD returned by ILAENV.
139*>
140*> If LWORK = -1, then a workspace query is assumed; the routine
141*> only calculates the optimal size of the WORK array, returns
142*> this value as the first entry of the WORK array, and no error
143*> message related to LWORK is issued by XERBLA.
144*> \endverbatim
145*>
146*> \param[out] RWORK
147*> \verbatim
148*> RWORK is DOUBLE PRECISION array, dimension (max(1, 3*N-2))
149*> \endverbatim
150*>
151*> \param[out] INFO
152*> \verbatim
153*> INFO is INTEGER
154*> = 0: successful exit
155*> < 0: if INFO = -i, the i-th argument had an illegal value
156*> > 0: ZPOTRF or ZHEEV returned an error code:
157*> <= N: if INFO = i, ZHEEV failed to converge;
158*> i off-diagonal elements of an intermediate
159*> tridiagonal form did not converge to zero;
160*> > N: if INFO = N + i, for 1 <= i <= N, then the leading
161*> principal minor of order i of B is not positive.
162*> The factorization of B could not be completed and
163*> no eigenvalues or eigenvectors were computed.
164*> \endverbatim
165*
166* Authors:
167* ========
168*
169*> \author Univ. of Tennessee
170*> \author Univ. of California Berkeley
171*> \author Univ. of Colorado Denver
172*> \author NAG Ltd.
173*
174*> \ingroup hegv
175*
176* =====================================================================
177 SUBROUTINE zhegv( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W,
178 $ WORK,
179 $ LWORK, RWORK, INFO )
180*
181* -- LAPACK driver routine --
182* -- LAPACK is a software package provided by Univ. of Tennessee, --
183* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
184*
185* .. Scalar Arguments ..
186 CHARACTER JOBZ, UPLO
187 INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
188* ..
189* .. Array Arguments ..
190 DOUBLE PRECISION RWORK( * ), W( * )
191 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
192* ..
193*
194* =====================================================================
195*
196* .. Parameters ..
197 COMPLEX*16 ONE
198 PARAMETER ( ONE = ( 1.0d+0, 0.0d+0 ) )
199* ..
200* .. Local Scalars ..
201 LOGICAL LQUERY, UPPER, WANTZ
202 CHARACTER TRANS
203 INTEGER LWKOPT, NB, NEIG
204* ..
205* .. External Functions ..
206 LOGICAL LSAME
207 INTEGER ILAENV
208 EXTERNAL lsame, ilaenv
209* ..
210* .. External Subroutines ..
211 EXTERNAL xerbla, zheev, zhegst, zpotrf, ztrmm,
212 $ ztrsm
213* ..
214* .. Intrinsic Functions ..
215 INTRINSIC max
216* ..
217* .. Executable Statements ..
218*
219* Test the input parameters.
220*
221 wantz = lsame( jobz, 'V' )
222 upper = lsame( uplo, 'U' )
223 lquery = ( lwork.EQ.-1 )
224*
225 info = 0
226 IF( itype.LT.1 .OR. itype.GT.3 ) THEN
227 info = -1
228 ELSE IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
229 info = -2
230 ELSE IF( .NOT.( upper .OR. lsame( uplo, 'L' ) ) ) THEN
231 info = -3
232 ELSE IF( n.LT.0 ) THEN
233 info = -4
234 ELSE IF( lda.LT.max( 1, n ) ) THEN
235 info = -6
236 ELSE IF( ldb.LT.max( 1, n ) ) THEN
237 info = -8
238 END IF
239*
240 IF( info.EQ.0 ) THEN
241 nb = ilaenv( 1, 'ZHETRD', uplo, n, -1, -1, -1 )
242 lwkopt = max( 1, ( nb + 1 )*n )
243 work( 1 ) = lwkopt
244*
245 IF( lwork.LT.max( 1, 2*n - 1 ) .AND. .NOT.lquery ) THEN
246 info = -11
247 END IF
248 END IF
249*
250 IF( info.NE.0 ) THEN
251 CALL xerbla( 'ZHEGV ', -info )
252 RETURN
253 ELSE IF( lquery ) THEN
254 RETURN
255 END IF
256*
257* Quick return if possible
258*
259 IF( n.EQ.0 )
260 $ RETURN
261*
262* Form a Cholesky factorization of B.
263*
264 CALL zpotrf( uplo, n, b, ldb, info )
265 IF( info.NE.0 ) THEN
266 info = n + info
267 RETURN
268 END IF
269*
270* Transform problem to standard eigenvalue problem and solve.
271*
272 CALL zhegst( itype, uplo, n, a, lda, b, ldb, info )
273 CALL zheev( jobz, uplo, n, a, lda, w, work, lwork, rwork,
274 $ info )
275*
276 IF( wantz ) THEN
277*
278* Backtransform eigenvectors to the original problem.
279*
280 neig = n
281 IF( info.GT.0 )
282 $ neig = info - 1
283 IF( itype.EQ.1 .OR. itype.EQ.2 ) THEN
284*
285* For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
286* backtransform eigenvectors: x = inv(L)**H *y or inv(U)*y
287*
288 IF( upper ) THEN
289 trans = 'N'
290 ELSE
291 trans = 'C'
292 END IF
293*
294 CALL ztrsm( 'Left', uplo, trans, 'Non-unit', n, neig,
295 $ one,
296 $ b, ldb, a, lda )
297*
298 ELSE IF( itype.EQ.3 ) THEN
299*
300* For B*A*x=(lambda)*x;
301* backtransform eigenvectors: x = L*y or U**H *y
302*
303 IF( upper ) THEN
304 trans = 'C'
305 ELSE
306 trans = 'N'
307 END IF
308*
309 CALL ztrmm( 'Left', uplo, trans, 'Non-unit', n, neig,
310 $ one,
311 $ b, ldb, a, lda )
312 END IF
313 END IF
314*
315 work( 1 ) = lwkopt
316*
317 RETURN
318*
319* End of ZHEGV
320*
321 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zheev(jobz, uplo, n, a, lda, w, work, lwork, rwork, info)
ZHEEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices
Definition zheev.f:138
subroutine zhegst(itype, uplo, n, a, lda, b, ldb, info)
ZHEGST
Definition zhegst.f:126
subroutine zhegv(itype, jobz, uplo, n, a, lda, b, ldb, w, work, lwork, rwork, info)
ZHEGV
Definition zhegv.f:180
subroutine zpotrf(uplo, n, a, lda, info)
ZPOTRF
Definition zpotrf.f:105
subroutine ztrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRMM
Definition ztrmm.f:177
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM
Definition ztrsm.f:180