3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DSYGV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsygv.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsygv.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsygv.f">
21 * SUBROUTINE DSYGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
24 * .. Scalar Arguments ..
25 * CHARACTER JOBZ, UPLO
26 * INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
28 * .. Array Arguments ..
29 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * )
38 *> DSYGV computes all the eigenvalues, and optionally, the eigenvectors
39 *> of a real generalized symmetric-definite eigenproblem, of the form
40 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
41 *> Here A and B are assumed to be symmetric and B is also
51 *> Specifies the problem type to be solved:
52 *> = 1: A*x = (lambda)*B*x
53 *> = 2: A*B*x = (lambda)*x
54 *> = 3: B*A*x = (lambda)*x
59 *> JOBZ is CHARACTER*1
60 *> = 'N': Compute eigenvalues only;
61 *> = 'V': Compute eigenvalues and eigenvectors.
66 *> UPLO is CHARACTER*1
67 *> = 'U': Upper triangles of A and B are stored;
68 *> = 'L': Lower triangles of A and B are stored.
74 *> The order of the matrices A and B. N >= 0.
79 *> A is DOUBLE PRECISION array, dimension (LDA, N)
80 *> On entry, the symmetric matrix A. If UPLO = 'U', the
81 *> leading N-by-N upper triangular part of A contains the
82 *> upper triangular part of the matrix A. If UPLO = 'L',
83 *> the leading N-by-N lower triangular part of A contains
84 *> the lower triangular part of the matrix A.
86 *> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
87 *> matrix Z of eigenvectors. The eigenvectors are normalized
89 *> if ITYPE = 1 or 2, Z**T*B*Z = I;
90 *> if ITYPE = 3, Z**T*inv(B)*Z = I.
91 *> If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
92 *> or the lower triangle (if UPLO='L') of A, including the
93 *> diagonal, is destroyed.
99 *> The leading dimension of the array A. LDA >= max(1,N).
104 *> B is DOUBLE PRECISION array, dimension (LDB, N)
105 *> On entry, the symmetric positive definite matrix B.
106 *> If UPLO = 'U', the leading N-by-N upper triangular part of B
107 *> contains the upper triangular part of the matrix B.
108 *> If UPLO = 'L', the leading N-by-N lower triangular part of B
109 *> contains the lower triangular part of the matrix B.
111 *> On exit, if INFO <= N, the part of B containing the matrix is
112 *> overwritten by the triangular factor U or L from the Cholesky
113 *> factorization B = U**T*U or B = L*L**T.
119 *> The leading dimension of the array B. LDB >= max(1,N).
124 *> W is DOUBLE PRECISION array, dimension (N)
125 *> If INFO = 0, the eigenvalues in ascending order.
130 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
131 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
137 *> The length of the array WORK. LWORK >= max(1,3*N-1).
138 *> For optimal efficiency, LWORK >= (NB+2)*N,
139 *> where NB is the blocksize for DSYTRD returned by ILAENV.
141 *> If LWORK = -1, then a workspace query is assumed; the routine
142 *> only calculates the optimal size of the WORK array, returns
143 *> this value as the first entry of the WORK array, and no error
144 *> message related to LWORK is issued by XERBLA.
150 *> = 0: successful exit
151 *> < 0: if INFO = -i, the i-th argument had an illegal value
152 *> > 0: DPOTRF or DSYEV returned an error code:
153 *> <= N: if INFO = i, DSYEV failed to converge;
154 *> i off-diagonal elements of an intermediate
155 *> tridiagonal form did not converge to zero;
156 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading
157 *> minor of order i of B is not positive definite.
158 *> The factorization of B could not be completed and
159 *> no eigenvalues or eigenvectors were computed.
165 *> \author Univ. of Tennessee
166 *> \author Univ. of California Berkeley
167 *> \author Univ. of Colorado Denver
170 *> \date November 2015
172 *> \ingroup doubleSYeigen
174 * =====================================================================
175 SUBROUTINE DSYGV( ITYPE, JOBZ, UPLO, N, A, LDA, B, LDB, W, WORK,
178 * -- LAPACK driver routine (version 3.6.0) --
179 * -- LAPACK is a software package provided by Univ. of Tennessee, --
180 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
183 * .. Scalar Arguments ..
185 INTEGER INFO, ITYPE, LDA, LDB, LWORK, N
187 * .. Array Arguments ..
188 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), W( * ), WORK( * )
191 * =====================================================================
195 PARAMETER ( ONE = 1.0D+0 )
197 * .. Local Scalars ..
198 LOGICAL LQUERY, UPPER, WANTZ
200 INTEGER LWKMIN, LWKOPT, NB, NEIG
202 * .. External Functions ..
205 EXTERNAL LSAME, ILAENV
207 * .. External Subroutines ..
208 EXTERNAL DPOTRF, DSYEV, DSYGST, DTRMM, DTRSM, XERBLA
210 * .. Intrinsic Functions ..
213 * .. Executable Statements ..
215 * Test the input parameters.
217 WANTZ = LSAME( JOBZ, 'V' )
218 UPPER = LSAME( UPLO, 'U' )
219 LQUERY = ( LWORK.EQ.-1 )
222 IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
224 ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
226 ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
228 ELSE IF( N.LT.0 ) THEN
230 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
232 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
237 LWKMIN = MAX( 1, 3*N - 1 )
238 NB = ILAENV( 1, 'DSYTRD', UPLO, N, -1, -1, -1 )
239 LWKOPT = MAX( LWKMIN, ( NB + 2 )*N )
242 IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY ) THEN
248 CALL XERBLA( 'DSYGV ', -INFO )
250 ELSE IF( LQUERY ) THEN
254 * Quick return if possible
259 * Form a Cholesky factorization of B.
261 CALL DPOTRF( UPLO, N, B, LDB, INFO )
267 * Transform problem to standard eigenvalue problem and solve.
269 CALL DSYGST( ITYPE, UPLO, N, A, LDA, B, LDB, INFO )
270 CALL DSYEV( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, INFO )
274 * Backtransform eigenvectors to the original problem.
279 IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
281 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
282 * backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y
290 CALL DTRSM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,
293 ELSE IF( ITYPE.EQ.3 ) THEN
295 * For B*A*x=(lambda)*x;
296 * backtransform eigenvectors: x = L*y or U**T*y
304 CALL DTRMM( 'Left', UPLO, TRANS, 'Non-unit', N, NEIG, ONE,